diff options
author | George Lebl <jirka@5z.com> | 2004-04-04 18:13:46 +0000 |
---|---|---|
committer | George Lebl <jirka@src.gnome.org> | 2004-04-04 18:13:46 +0000 |
commit | 6ee4fb112aac0c22f68385de657c3bb3e191c0cb (patch) | |
tree | ca4947fa7bee3aab38f90bf3ad58eb618b7532b9 /daemon | |
parent | 4dbb89ced99cf72e408e100d5269af0bc068ed7d (diff) | |
download | gdm-6ee4fb112aac0c22f68385de657c3bb3e191c0cb.tar.gz |
The ensure_sanity is now always called only from the main daemon on
Sun Apr 04 11:12:55 2004 George Lebl <jirka@5z.com>
* daemon/misc.c, daemon/slave.c, daemon/display.c, daemon/gdm.c:
The ensure_sanity is now always called only from the main daemon
on display_manage (to avoid stepping on ones toes) and also it
checks /tmp/.X11-unix to have correct permissions as well.
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/display.c | 4 | ||||
-rw-r--r-- | daemon/gdm.c | 3 | ||||
-rw-r--r-- | daemon/misc.c | 50 | ||||
-rw-r--r-- | daemon/slave.c | 3 |
4 files changed, 36 insertions, 24 deletions
diff --git a/daemon/display.c b/daemon/display.c index e2dd6f37..a738011b 100644 --- a/daemon/display.c +++ b/daemon/display.c @@ -269,6 +269,10 @@ gdm_display_manage (GdmDisplay *d) * that we are hanging */ whack_old_slave (d); + /* Ensure that /tmp/.ICE-unix and /tmp/.X11-unix exist and have the + * correct permissions */ + gdm_ensure_sanity (); + d->managetime = time (NULL); /* Fork slave process */ diff --git a/daemon/gdm.c b/daemon/gdm.c index 0f809574..f0010e98 100644 --- a/daemon/gdm.c +++ b/daemon/gdm.c @@ -2159,7 +2159,8 @@ main (int argc, char *argv[]) create_connections (); - /* make sure things (currently /tmp/.ICE-unix) are sane */ + /* make sure things (currently /tmp/.ICE-unix and /tmp/.X11-unix) + * are sane */ gdm_ensure_sanity () ; /* Start local X servers */ diff --git a/daemon/misc.c b/daemon/misc.c index 61f828dc..64042d15 100644 --- a/daemon/misc.c +++ b/daemon/misc.c @@ -842,45 +842,55 @@ gdm_wait_for_extra (int *status) gdm_sigchld_block_pop (); } -/* done before each login and on startup. This can do some - * sanity ensuring, one of the things it does now is make - * sure /tmp/.ICE-unix exists and has the correct permissions */ -void -gdm_ensure_sanity (void) +static void +ensure_tmp_socket_dir (const char *dir) { mode_t old_umask; - uid_t old_euid; - gid_t old_egid; - - old_euid = geteuid (); - old_egid = getegid (); - - NEVER_FAILS_root_set_euid_egid (0, 0); - /* The /tmp/.ICE-unix check, note that we do + /* The /tmp/.ICE-unix / .X11-unix check, note that we do * ignore errors, since it's not deadly to run * if we can't perform this task :) */ old_umask = umask (0); - if G_UNLIKELY (mkdir ("/tmp/.ICE-unix", 01777) != 0) { + if G_UNLIKELY (mkdir (dir, 01777) != 0) { /* if we can't create it, perhaps it already exists, in which case ensure the correct permissions */ struct stat s; int r; - VE_IGNORE_EINTR (r = lstat ("/tmp/.ICE-unix", &s)); + VE_IGNORE_EINTR (r = lstat (dir, &s)); if G_LIKELY (r == 0 && S_ISDIR (s.st_mode)) { /* Make sure it is root and sticky */ - VE_IGNORE_EINTR (chown ("/tmp/.ICE-unix", 0, 0)); - VE_IGNORE_EINTR (chmod ("/tmp/.ICE-unix", 01777)); + VE_IGNORE_EINTR (chown (dir, 0, 0)); + VE_IGNORE_EINTR (chmod (dir, 01777)); } else { - /* There is a file/link/whatever called .ICE-unix? whack and try mkdir */ - VE_IGNORE_EINTR (unlink ("/tmp/.ICE-unix")); - mkdir ("/tmp/.ICE-unix", 01777); + /* There is a file/link/whatever of the same name? + whack and try mkdir */ + VE_IGNORE_EINTR (unlink (dir)); + mkdir (dir, 01777); } } umask (old_umask); +} + +/* done on startup and when running display_manage + * This can do some sanity ensuring, one of the things it does now is make + * sure /tmp/.ICE-unix and /tmp/.X11-unix exist and have the correct + * permissions */ +void +gdm_ensure_sanity (void) +{ + uid_t old_euid; + gid_t old_egid; + + old_euid = geteuid (); + old_egid = getegid (); + + NEVER_FAILS_root_set_euid_egid (0, 0); + + ensure_tmp_socket_dir ("/tmp/.ICE-unix"); + ensure_tmp_socket_dir ("/tmp/.X11-unix"); NEVER_FAILS_root_set_euid_egid (old_euid, old_egid); } diff --git a/daemon/slave.c b/daemon/slave.c index f7cc73d4..9f55b907 100644 --- a/daemon/slave.c +++ b/daemon/slave.c @@ -3986,9 +3986,6 @@ gdm_slave_session_start (void) gdm_slave_whack_greeter (); } - /* Ensure some sanity in this world */ - gdm_ensure_sanity (); - if (GdmKillInitClients) gdm_server_whack_clients (d); |