r3877 - in trunk: . launchers



Author: timj
Date: 2006-09-10 16:32:41 -0400 (Sun, 10 Sep 2006)
New Revision: 3877

Modified:
   trunk/ChangeLog
   trunk/launchers/suidmain.c
Log:
Wed Aug 30 21:57:32 2006  Tim Janik  <timj gtk org>

        * launchers/suidmain.c (main): abort the program if we failed to drop
        priviledges and continue to run suid (could happen due to user process
        limits being reached).




Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-09-10 20:28:15 UTC (rev 3876)
+++ trunk/ChangeLog	2006-09-10 20:32:41 UTC (rev 3877)
@@ -1,3 +1,9 @@
+Wed Aug 30 21:57:32 2006  Tim Janik  <timj gtk org>
+
+	* launchers/suidmain.c (main): abort the program if we failed to drop
+	priviledges and continue to run suid (could happen due to user process
+	limits being reached).
+
 Tue Aug 22 17:02:50 2006  Stefan Westerfeld  <stefan space twc de>
 
 	* docs/Makefile.am:

Modified: trunk/launchers/suidmain.c
===================================================================
--- trunk/launchers/suidmain.c	2006-09-10 20:28:15 UTC (rev 3876)
+++ trunk/launchers/suidmain.c	2006-09-10 20:32:41 UTC (rev 3877)
@@ -70,13 +70,19 @@
   /* drop root privileges if running setuid root as soon as possible */
   if (euid != uid)
     {
+      int err;
 #if     HAVE_SETEUID
-      seteuid (uid);
+      err = seteuid (uid);
 #elif   HAVE_SETREUID
-      setreuid (-1, uid);
+      err = setreuid (-1, uid);
 #else
 #error platform misses facility to drop privileges
 #endif
+      if (err != 0)
+        {
+          fprintf (stderr, "%s: failed to drop priviledges: %s\n", argv[0], strerror (errno));
+          _exit (2);
+        }
     }
 
   /* non-priviledged code */




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]