hi

the call to setsid() must be after setgid()/setgroups() because if it's before, those 
calls return with -1, errno gets EPERM (=the user is not the super-user)
this way distccd can actually start for me..

against distcc-2.12


rgds
-daniel

ps: please cc, i'm not subscribed


--- setuid.c-old        2003-12-28 21:51:36.000000000 +0100
+++ setuid.c    2003-12-28 21:52:03.000000000 +0100
@@ -108,11 +108,6 @@
      * permanently discard privileges: both the real and effective uid are
      * set. */
 
-    if (setuid(uid)) {
-        rs_log_error("setuid(%d) failed: %s", (int) uid, strerror(errno));
-        return EXIT_SETUID_FAILED;
-    }
-
     if (setgid(gid)) {
         rs_log_error("setgid(%d) failed: %s", (int) gid, strerror(errno));
         return EXIT_SETUID_FAILED;
@@ -128,6 +123,11 @@
     }
 #endif
 
+    if (setuid(uid)) {
+        rs_log_error("setuid(%d) failed: %s", (int) uid, strerror(errno));
+        return EXIT_SETUID_FAILED;
+    }
+
     if (getuid() == 0  ||  geteuid() == 0) {
         rs_log_crit("still have root privileges after trying to discard them!");
         return EXIT_SETUID_FAILED;

__ 
distcc mailing list            http://distcc.samba.org/
To unsubscribe or change options: 
http://lists.samba.org/mailman/listinfo/distcc

Reply via email to