summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Lebl <jirka@5z.com>2003-08-04 20:48:20 +0000
committerGeorge Lebl <jirka@src.gnome.org>2003-08-04 20:48:20 +0000
commit0003ff1bcc03288889582ab1c75197054f83d313 (patch)
tree46a1ddc0e1deb02297b0e4c99f0b4acf7cc47d37
parentecd67810edcfb68aa07bd08cef131cc6bfd31a0f (diff)
downloadgdm-0003ff1bcc03288889582ab1c75197054f83d313.tar.gz
Fixed #118878 by actually ensuring the /tmp/.ICE-unix permissions.
Mon Aug 04 13:43:29 2003 George Lebl <jirka@5z.com> * daemon/misc.c: Fixed #118878 by actually ensuring the /tmp/.ICE-unix permissions.
-rw-r--r--ChangeLog5
-rw-r--r--daemon/misc.c33
2 files changed, 29 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 403ceee8..7af65dd4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Aug 04 13:43:29 2003 George Lebl <jirka@5z.com>
+
+ * daemon/misc.c: Fixed #118878 by actually ensuring the /tmp/.ICE-unix
+ permissions.
+
Mon Aug 04 09:33:46 2003 George Lebl <jirka@5z.com>
* daemon/auth.[ch], daemon/errorgui.[ch], daemon/slave.c,
diff --git a/daemon/misc.c b/daemon/misc.c
index aea74d63..103da560 100644
--- a/daemon/misc.c
+++ b/daemon/misc.c
@@ -752,27 +752,42 @@ void
gdm_ensure_sanity (void)
{
mode_t old_umask;
+ uid_t old_euid;
+ gid_t old_egid;
+
+ old_euid = geteuid ();
+ old_egid = getegid ();
+
+ seteuid (0);
+ setegid (0);
/* The /tmp/.ICE-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 (mkdir ("/tmp/.ICE-unix", 0777) == 0) {
- /* Make sure it is root */
- if (chown ("/tmp/.ICE-unix", 0, 0) == 0)
- chmod ("/tmp/.ICE-unix", 01777);
- } else {
+ if (mkdir ("/tmp/.ICE-unix", 01777) != 0) {
+ /* if we can't create it, perhaps it
+ already exists, in which case ensure the
+ correct permissions */
struct stat s;
- if (lstat ("/tmp/.ICE-unix", &s) == 0 &&
- S_ISDIR (s.st_mode)) {
+ int r;
+ IGNORE_EINTR (r = lstat ("/tmp/.ICE-unix", &s));
+ if (r == 0 && S_ISDIR (s.st_mode)) {
/* Make sure it is root and sticky */
- if (chown ("/tmp/.ICE-unix", 0, 0) == 0)
- chmod ("/tmp/.ICE-unix", 01777);
+ IGNORE_EINTR (chown ("/tmp/.ICE-unix", 0, 0));
+ IGNORE_EINTR (chmod ("/tmp/.ICE-unix", 01777));
+ } else {
+ /* There is a file/link/whatever called .ICE-unix? whack and try mkdir */
+ unlink ("/tmp/.ICE-unix");
+ mkdir ("/tmp/.ICE-unix", 01777);
}
}
umask (old_umask);
+
+ seteuid (old_euid);
+ setegid (old_egid);
}
const GList *