diff options
author | George Lebl <jirka@5z.com> | 2003-07-22 21:35:37 +0000 |
---|---|---|
committer | George Lebl <jirka@src.gnome.org> | 2003-07-22 21:35:37 +0000 |
commit | e0e338c65360de407b7f04037cf5a4e486345f6d (patch) | |
tree | d56fecbedcc2d4a5c5e7a28f406c380b5b01c91c /daemon/errorgui.c | |
parent | 0b5502a6649ff621d26cd8d7d12a8d7b872b4c88 (diff) | |
download | gdm-e0e338c65360de407b7f04037cf5a4e486345f6d.tar.gz |
Set XAUTHORITY to GDM_AUTHFILE always for root processes. Also make sure
Tue Jul 22 14:31:25 2003 George Lebl <jirka@5z.com>
* daemon/auth.c, daemon/slave.c, daemon/server.c:
Set XAUTHORITY to GDM_AUTHFILE always for root processes.
Also make sure not to set it if it's NULL already.
* daemon/auth.[ch], daemon/slave.c, daemon/server.c: use
XSetAuthority instead of XAUTHORITY env var as that is
more failsafe
* daemon/errorgui.c: set the DISPLAY and use XSetAuthority
instead of relying on XAUTHORITY/DISPLAY being set right
(which they not always are). Also cleanup the dialog
startup a bit.
* daemon/slave.c, daemon/errorgui.c: chmod the authfile
to 640 before a session and back to 644 afterwards. This
reduces the risk from gdm user breakage. In case someone
breaks the gdm user they can't connect to existing
user sessions, only new ones.
* daemon/misc.h, daemon/server.c, daemon/slave.c: redo the
reinit stuff. Don't close the display before we reinit
and then do a nice setjmp hack to notice when the server
got reinited. This avoids races, avoids an extra process
for figuring out the reinit and as icing on the cake it
is also about 4-5 seconds faster to reinit not (and the
server is reinited just once instead of thrice which
might have been causing some X server whackiness)
* daemon/server.c: be careful in the log directory as well
when opening files and do safer moves there as well
for the rotation.
* daemon/slave.c: whack the stupid extra XOpenDisplay,
this is apparently only a workaround for some whacky
streams X server connection which we don't support.
And this takes up quite a bit of time on startup
it turns out. Also related we'll set the cursor
to pointer before we fork so that we don't need to
do yet another XOpenDisplay. This speeds up startup
yet some more.
* daemon/slave.c: when reading the session .desktop file
_get it rather then _new it so that we do less reading/parsing
on session startup.
* daemon/slave.c: some cleanup of session ends
Diffstat (limited to 'daemon/errorgui.c')
-rw-r--r-- | daemon/errorgui.c | 217 |
1 files changed, 49 insertions, 168 deletions
diff --git a/daemon/errorgui.c b/daemon/errorgui.c index 6cc79538..33cdb95c 100644 --- a/daemon/errorgui.c +++ b/daemon/errorgui.c @@ -32,6 +32,7 @@ #include <sys/stat.h> #include "gdm.h" #include "misc.h" +#include "auth.h" #include <vicious.h> @@ -183,6 +184,50 @@ get_error_text_view (const char *details) return sw; } +static void +setup_dialog (GdmDisplay *d, const char *name, int closefdexcept) +{ + int argc = 1; + char **argv; + + closelog (); + + gdm_close_all_descriptors (0 /* from */, closefdexcept /* except */); + + /* No error checking here - if it's messed the best response + * is to ignore & try to continue */ + gdm_open_dev_null (O_RDONLY); /* open stdin - fd 0 */ + gdm_open_dev_null (O_RDWR); /* open stdout - fd 1 */ + gdm_open_dev_null (O_RDWR); /* open stderr - fd 2 */ + + setgid (GdmGroupId); + initgroups (GdmUser, GdmGroupId); + setuid (GdmUserId); + + gdm_desetuid (); + + /* restore initial environment */ + gdm_restoreenv (); + + openlog ("gdm", LOG_PID, LOG_DAEMON); + + ve_setenv ("DISPLAY", d->name, TRUE); + ve_unsetenv ("XAUTHORITY"); + + gdm_auth_set_local_auth (d); + + /* sanity env stuff */ + ve_setenv ("SHELL", "/bin/sh", TRUE); + ve_setenv ("HOME", ve_sure_string (GdmServAuthDir), TRUE); + + argv = g_new0 (char *, 2); + argv[0] = (char *)name; + + gtk_init (&argc, &argv); + + get_screen_size (d); +} + void gdm_error_box_full (GdmDisplay *d, GtkMessageType type, const char *error, const char *details_label, const char *details_file) @@ -193,13 +238,9 @@ gdm_error_box_full (GdmDisplay *d, GtkMessageType type, const char *error, if (pid == 0) { guint sid; - int argc = 1; - char **argv; GtkWidget *dlg; GtkWidget *button; char *loc; - char *display; - char *xauthority; char *details; /* First read the details if they exist */ @@ -253,44 +294,7 @@ gdm_error_box_full (GdmDisplay *d, GtkMessageType type, const char *error, details = NULL; } - closelog (); - - gdm_close_all_descriptors (0 /* from */, -1 /* except */); - - /* No error checking here - if it's messed the best response - * is to ignore & try to continue */ - gdm_open_dev_null (O_RDONLY); /* open stdin - fd 0 */ - gdm_open_dev_null (O_RDWR); /* open stdout - fd 1 */ - gdm_open_dev_null (O_RDWR); /* open stderr - fd 2 */ - - setgid (GdmGroupId); - initgroups (GdmUser, GdmGroupId); - setuid (GdmUserId); - - gdm_desetuid (); - - display = g_strdup (g_getenv ("DISPLAY")); - xauthority = g_strdup (g_getenv ("XAUTHORITY")); - - /* restore initial environment */ - gdm_restoreenv (); - - if (display != NULL) - ve_setenv ("DISPLAY", display, TRUE); - if (xauthority != NULL) - ve_setenv ("XAUTHORITY", xauthority, TRUE); - /* sanity env stuff */ - ve_setenv ("SHELL", "/bin/sh", TRUE); - ve_setenv ("HOME", ve_sure_string (GdmServAuthDir), TRUE); - - openlog ("gdm", LOG_PID, LOG_DAEMON); - - argv = g_new0 (char *, 2); - argv[0] = "gtk-error-box"; - - gtk_init (&argc, &argv); - - get_screen_size (d); + setup_dialog (d, "gtk-error-box", -1); loc = gdm_locale_to_utf8 (error); @@ -398,51 +402,10 @@ gdm_failsafe_question (GdmDisplay *d, pid = gdm_fork_extra (); if (pid == 0) { guint sid; - int argc = 1; - char **argv; GtkWidget *dlg, *label, *entry; char *loc; - char *display; - char *xauthority; - - closelog (); - - gdm_close_all_descriptors (0 /* from */, p[1] /* except */); - - /* No error checking here - if it's messed the best response - * is to ignore & try to continue */ - gdm_open_dev_null (O_RDONLY); /* open stdin - fd 0 */ - gdm_open_dev_null (O_RDWR); /* open stdout - fd 1 */ - gdm_open_dev_null (O_RDWR); /* open stderr - fd 2 */ - setgid (GdmGroupId); - initgroups (GdmUser, GdmGroupId); - setuid (GdmUserId); - - gdm_desetuid (); - - display = g_strdup (g_getenv ("DISPLAY")); - xauthority = g_strdup (g_getenv ("XAUTHORITY")); - - /* restore initial environment */ - gdm_restoreenv (); - - if (display != NULL) - ve_setenv ("DISPLAY", display, TRUE); - if (xauthority != NULL) - ve_setenv ("XAUTHORITY", xauthority, TRUE); - /* sanity env stuff */ - ve_setenv ("SHELL", "/bin/sh", TRUE); - ve_setenv ("HOME", ve_sure_string (GdmServAuthDir), TRUE); - - openlog ("gdm", LOG_PID, LOG_DAEMON); - - argv = g_new0 (char *, 2); - argv[0] = "gtk-failsafe-question"; - - gtk_init (&argc, &argv); - - get_screen_size (d); + setup_dialog (d, "gtk-failsafe-question", p[1]); loc = gdm_locale_to_utf8 (question); @@ -543,51 +506,10 @@ gdm_failsafe_yesno (GdmDisplay *d, pid = gdm_fork_extra (); if (pid == 0) { guint sid; - int argc = 1; - char **argv; GtkWidget *dlg; char *loc; - char *display; - char *xauthority; - - closelog (); - - gdm_close_all_descriptors (0 /* from */, p[1] /* except */); - - /* No error checking here - if it's messed the best response - * is to ignore & try to continue */ - gdm_open_dev_null (O_RDONLY); /* open stdin - fd 0 */ - gdm_open_dev_null (O_RDWR); /* open stdout - fd 1 */ - gdm_open_dev_null (O_RDWR); /* open stderr - fd 2 */ - - setgid (GdmGroupId); - initgroups (GdmUser, GdmGroupId); - setuid (GdmUserId); - - gdm_desetuid (); - - display = g_strdup (g_getenv ("DISPLAY")); - xauthority = g_strdup (g_getenv ("XAUTHORITY")); - - /* restore initial environment */ - gdm_restoreenv (); - if (display != NULL) - ve_setenv ("DISPLAY", display, TRUE); - if (xauthority != NULL) - ve_setenv ("XAUTHORITY", xauthority, TRUE); - /* sanity env stuff */ - ve_setenv ("SHELL", "/bin/sh", TRUE); - ve_setenv ("HOME", ve_sure_string (GdmServAuthDir), TRUE); - - openlog ("gdm", LOG_PID, LOG_DAEMON); - - argv = g_new0 (char *, 2); - argv[0] = "gtk-failsafe-yesno"; - - gtk_init (&argc, &argv); - - get_screen_size (d); + setup_dialog (d, "gtk-failsafe-yesno", p[1]); loc = gdm_locale_to_utf8 (question); @@ -673,51 +595,10 @@ gdm_failsafe_ask_buttons (GdmDisplay *d, if (pid == 0) { int i; guint sid; - int argc = 1; - char **argv; GtkWidget *dlg; char *loc; - char *display; - char *xauthority; - - closelog (); - - gdm_close_all_descriptors (0 /* from */, p[1] /* except */); - - /* No error checking here - if it's messed the best response - * is to ignore & try to continue */ - gdm_open_dev_null (O_RDONLY); /* open stdin - fd 0 */ - gdm_open_dev_null (O_RDWR); /* open stdout - fd 1 */ - gdm_open_dev_null (O_RDWR); /* open stderr - fd 2 */ - - setgid (GdmGroupId); - initgroups (GdmUser, GdmGroupId); - setuid (GdmUserId); - - gdm_desetuid (); - - display = g_strdup (g_getenv ("DISPLAY")); - xauthority = g_strdup (g_getenv ("XAUTHORITY")); - - /* restore initial environment */ - gdm_restoreenv (); - - if (display != NULL) - ve_setenv ("DISPLAY", display, TRUE); - if (xauthority != NULL) - ve_setenv ("XAUTHORITY", xauthority, TRUE); - /* sanity env stuff */ - ve_setenv ("SHELL", "/bin/sh", TRUE); - ve_setenv ("HOME", ve_sure_string (GdmServAuthDir), TRUE); - - openlog ("gdm", LOG_PID, LOG_DAEMON); - - argv = g_new0 (char *, 2); - argv[0] = "gtk-failsafe-ask-buttons"; - - gtk_init (&argc, &argv); - get_screen_size (d); + setup_dialog (d, "gtk-failsafe-ask-buttons", p[1]); loc = gdm_locale_to_utf8 (question); |