summaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
authorBrian Cameron <brian.cameron@sun.com>2007-02-09 01:44:34 +0000
committerBrian Cameron <bcameron@src.gnome.org>2007-02-09 01:44:34 +0000
commit40a6944a8ba3e940164b473cff64ed4eef61bed0 (patch)
treeeb679306ed18c2263195c32c7f44c277808990bd /daemon
parent84313044c828a7ddc8111a9d64d4c33e8558e75d (diff)
downloadgdm-40a6944a8ba3e940164b473cff64ed4eef61bed0.tar.gz
Add sockets command to start login procedure, to be used by
2007-02-09 Brian Cameron <brian.cameron@sun.com> * docs/C/gdm.xml, daemon/display.c, dameon/gdm.[ch], daemon/server.c, daemon/slave.c: Add sockets command to start login procedure, to be used by gnome-screensaver and Fast User Switch applet. Fixes enhancement request #335786. Patch by Matthias Clasen <mclasen@redhat.com>. svn path=/trunk/; revision=4572
Diffstat (limited to 'daemon')
-rw-r--r--daemon/display.c7
-rw-r--r--daemon/gdm.c65
-rw-r--r--daemon/gdm.h47
-rw-r--r--daemon/server.c1
-rw-r--r--daemon/slave.c7
5 files changed, 112 insertions, 15 deletions
diff --git a/daemon/display.c b/daemon/display.c
index 56263ff8..5878f5d3 100644
--- a/daemon/display.c
+++ b/daemon/display.c
@@ -1,4 +1,6 @@
-/* GDM - The GNOME Display Manager
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * GDM - The GNOME Display Manager
* Copyright (C) 1998, 1999, 2000 Martin K. Petersen <mkp@mkp.net>
*
* This program is free software; you can redistribute it and/or modify
@@ -531,6 +533,9 @@ gdm_display_dispose (GdmDisplay *d)
g_free (d->login);
d->login = NULL;
+ g_free (d->preset_user);
+ d->preset_user = NULL;
+
g_free (d->xsession_errors_filename);
d->xsession_errors_filename = NULL;
diff --git a/daemon/gdm.c b/daemon/gdm.c
index 1a7ba20d..964994cd 100644
--- a/daemon/gdm.c
+++ b/daemon/gdm.c
@@ -1,4 +1,6 @@
-/* GDM - The GNOME Display Manager
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * GDM - The GNOME Display Manager
* Copyright (C) 1998, 1999, 2000 Martin K. Petersen <mkp@mkp.net>
*
* This program is free software; you can redistribute it and/or modify
@@ -96,7 +98,8 @@ static void handle_flexi_server (GdmConnection *conn,
const gchar *xnest_disp,
uid_t xnest_uid,
const gchar *xnest_auth_file,
- const gchar *xnest_cookie);
+ const gchar *xnest_cookie,
+ const gchar *username);
static void custom_cmd_restart (long cmd_id);
static void custom_cmd_no_restart (long cmd_id);
@@ -2553,7 +2556,7 @@ gdm_handle_message (GdmConnection *conn, const char *msg, gpointer data)
handle_flexi_server (NULL, TYPE_FLEXI, gdm_get_value_string (GDM_KEY_STANDARD_XSERVER),
TRUE /* handled */,
FALSE /* chooser */,
- NULL, 0, NULL, NULL);
+ NULL, 0, NULL, NULL, NULL);
} else if (strncmp (msg, "opcode="GDM_SOP_SHOW_ERROR_DIALOG,
strlen ("opcode="GDM_SOP_SHOW_ERROR_DIALOG)) == 0) {
GdmDisplay *d;
@@ -2952,7 +2955,8 @@ handle_flexi_server (GdmConnection *conn, int type, const gchar *server,
gboolean chooser,
const gchar *xnest_disp, uid_t xnest_uid,
const gchar *xnest_auth_file,
- const gchar *xnest_cookie)
+ const gchar *xnest_cookie,
+ const gchar *username)
{
GdmDisplay *display;
gchar *bin;
@@ -3084,6 +3088,7 @@ handle_flexi_server (GdmConnection *conn, int type, const gchar *server,
flexi_servers++;
+ display->preset_user = g_strdup (username);
display->type = type;
display->socket_conn = conn;
display->parent_disp = g_strdup (xnest_disp);
@@ -3225,6 +3230,7 @@ static void
gdm_handle_user_message (GdmConnection *conn, const gchar *msg, gpointer data)
{
gint i;
+ gboolean has_user;
gdm_debug ("Handling user message: '%s'", msg);
@@ -3293,12 +3299,16 @@ gdm_handle_user_message (GdmConnection *conn, const gchar *msg, gpointer data)
handle_flexi_server (conn, TYPE_FLEXI, gdm_get_value_string (GDM_KEY_STANDARD_XSERVER),
TRUE /* handled */,
FALSE /* chooser */,
- NULL, 0, NULL, NULL);
- } else if (strncmp (msg, GDM_SUP_FLEXI_XSERVER " ",
- strlen (GDM_SUP_FLEXI_XSERVER " ")) == 0) {
+ NULL, 0, NULL, NULL, NULL);
+ } else if (((has_user = strncmp (msg, GDM_SUP_FLEXI_XSERVER_USER " ",
+ strlen (GDM_SUP_FLEXI_XSERVER_USER " "))) == 0) ||
+ (strncmp (msg, GDM_SUP_FLEXI_XSERVER " ",
+ strlen (GDM_SUP_FLEXI_XSERVER " ")) == 0)) {
gchar *name;
const gchar *command = NULL;
GdmXserver *svr;
+ const gchar *rest;
+ gchar *username, *end;
/* Only allow locally authenticated connections */
if ( ! GDM_CONN_AUTHENTICATED(conn)) {
@@ -3309,7 +3319,21 @@ gdm_handle_user_message (GdmConnection *conn, const gchar *msg, gpointer data)
return;
}
- name = g_strdup (&msg[strlen (GDM_SUP_FLEXI_XSERVER " ")]);
+ if (has_user == 0) {
+ rest = msg + strlen (GDM_SUP_FLEXI_XSERVER_USER " ");
+ end = strchr (rest, ' ');
+ if (end) {
+ username = g_strndup (rest, end - rest);
+ rest = end + 1;
+ } else {
+ username = g_strdup (rest);
+ rest = rest + strlen (rest);
+ }
+ } else {
+ rest = msg + strlen (GDM_SUP_FLEXI_XSERVER " ");
+ username = NULL;
+ }
+ name = g_strdup (rest);
g_strstrip (name);
if (ve_string_empty (name)) {
g_free (name);
@@ -3339,13 +3363,27 @@ gdm_handle_user_message (GdmConnection *conn, const gchar *msg, gpointer data)
oh well, this makes other things simpler */
svr->handled,
svr->chooser,
- NULL, 0, NULL, NULL);
- } else if (strncmp (msg, GDM_SUP_FLEXI_XNEST " ",
- strlen (GDM_SUP_FLEXI_XNEST " ")) == 0) {
+ NULL, 0, NULL, NULL, username);
+ g_free (username);
+ } else if (((has_user = strncmp (msg, GDM_SUP_FLEXI_XNEST_USER " ",
+ strlen (GDM_SUP_FLEXI_XNEST_USER " "))) == 0) ||
+ (strncmp (msg, GDM_SUP_FLEXI_XNEST " ",
+ strlen (GDM_SUP_FLEXI_XNEST " ")) == 0)) {
gchar *dispname = NULL, *xauthfile = NULL, *cookie = NULL;
uid_t uid;
+ const gchar *rest;
+ gchar *username, *end;
+
+ if (has_user == 0) {
+ rest = msg + strlen (GDM_SUP_FLEXI_XNEST_USER " ");
+ end = strchr (rest, ' ');
+ username = g_strndup (rest, end - rest);
+ } else {
+ rest = msg;
+ username = NULL;
+ }
- extract_dispname_uid_xauthfile_cookie (msg, &dispname, &uid,
+ extract_dispname_uid_xauthfile_cookie (rest, &dispname, &uid,
&xauthfile, &cookie);
if (dispname == NULL) {
@@ -3369,10 +3407,11 @@ gdm_handle_user_message (GdmConnection *conn, const gchar *msg, gpointer data)
handle_flexi_server (conn, TYPE_FLEXI_XNEST, gdm_get_value_string (GDM_KEY_XNEST),
TRUE /* handled */,
FALSE /* chooser */,
- dispname, uid, xauthfile, cookie);
+ dispname, uid, xauthfile, cookie, username);
g_free (dispname);
g_free (xauthfile);
+ g_free (username);
} else if ((strncmp (msg, GDM_SUP_ATTACHED_SERVERS,
strlen (GDM_SUP_ATTACHED_SERVERS)) == 0) ||
(strncmp (msg, GDM_SUP_CONSOLE_SERVERS,
diff --git a/daemon/gdm.h b/daemon/gdm.h
index e0c87c91..f0b72a03 100644
--- a/daemon/gdm.h
+++ b/daemon/gdm.h
@@ -557,6 +557,8 @@ struct _GdmDisplay {
gboolean logged_in; /* TRUE if someone is logged in */
char *login;
+ char *preset_user;
+
gboolean timed_login_ok;
int screenx;
@@ -870,6 +872,26 @@ void gdm_final_cleanup (void);
* 200 = Too many messages
* 999 = Unknown error
*/
+#define GDM_SUP_FLEXI_XSERVER_USER "FLEXI_XSERVER_USER" /* <username> <xserver type> */
+/* FLEXI_XSERVER_USER: Start a new X flexible display and initialize the
+ * greeter with the given username. Only supported on
+ * connection that passed AUTH_LOCAL
+ * Supported since: 2.17.7
+ * Arguments: <username> <xserver type>
+ * If no server type specified, starts the standard X server
+ * Answers:
+ * OK <display>
+ * ERROR <err number> <english error description>
+ * 0 = Not implemented
+ * 1 = No more flexi servers
+ * 2 = Startup errors
+ * 3 = X failed
+ * 4 = X too busy
+ * 6 = No server binary
+ * 100 = Not authenticated
+ * 200 = Too many messages
+ * 999 = Unknown error
+ */
#define GDM_SUP_FLEXI_XNEST "FLEXI_XNEST" /* <display> <uid> <xauth cookie> <xauth file> */
/* FLEXI_XNEXT: Start a new flexible Xnest display.
* Note: Supported on older versions from 2.2.4.0, later
@@ -905,6 +927,31 @@ void gdm_final_cleanup (void);
* 200 = Too many messages
* 999 = Unknown error
*/
+#define GDM_SUP_FLEXI_XNEST_USER "FLEXI_XNEST_USER" /* <username> <display> <uid> <xauth cookie> <xauth file> */
+/* FLEXI_XNEXT_USER: Start a new flexible Xnest display and
+ * initialize the greeter with the given username
+ * Note: The cookie should be the MIT-MAGIC-COOKIE-1,
+ * the first one gdm can find in the XAUTHORITY
+ * file for this display. If that's not what you
+ * use you should generate one first. The cookie
+ * should be in hex form.
+ * Supported since: 2.17.7
+ * Arguments: <username> <display to run on> <uid of requesting user>
+ * <xauth cookie for the display> <xauth file>
+ * Answers:
+ * OK <display>
+ * ERROR <err number> <english error description>
+ * 0 = Not implemented
+ * 1 = No more flexi servers
+ * 2 = Startup errors
+ * 3 = X failed
+ * 4 = X too busy
+ * 5 = Xnest can't connect
+ * 6 = No server binary
+ * 100 = Not authenticated
+ * 200 = Too many messages
+ * 999 = Unknown error
+ */
#define GDM_SUP_ADD_DYNAMIC_DISPLAY "ADD_DYNAMIC_DISPLAY"
/*
* ADD_DYNAMIC_DISPLAY: Create a new server definition that will
diff --git a/daemon/server.c b/daemon/server.c
index ac1f6f6b..e6135ba5 100644
--- a/daemon/server.c
+++ b/daemon/server.c
@@ -1439,6 +1439,7 @@ gdm_server_alloc (gint id, const gchar *command)
d->retry_count = 0;
d->sleep_before_run = 0;
d->login = NULL;
+ d->preset_user = NULL;
d->timed_login_ok = FALSE;
diff --git a/daemon/slave.c b/daemon/slave.c
index cc4797e8..9d3862bd 100644
--- a/daemon/slave.c
+++ b/daemon/slave.c
@@ -1942,6 +1942,7 @@ static void
gdm_slave_wait_for_login (void)
{
char *successsound;
+ char *username;
g_free (login);
login = NULL;
@@ -1966,10 +1967,14 @@ gdm_slave_wait_for_login (void)
NEVER_FAILS_root_set_euid_egid (0, 0);
gdm_debug ("gdm_slave_wait_for_login: In loop");
+ username = d->preset_user;
+ d->preset_user = NULL;
login = gdm_verify_user (d /* the display */,
- NULL /* username*/,
+ username /* username*/,
d->name /* display name */,
d->attached /* display attached? (bool) */);
+ g_free (username);
+
gdm_debug ("gdm_slave_wait_for_login: end verify for '%s'",
ve_sure_string (login));