No longer permit the exim user to be root. Fixes: #752
authorPhil Pennock <pdp@exim.org>
Sun, 6 Jun 2010 02:46:13 +0000 (02:46 +0000)
committerPhil Pennock <pdp@exim.org>
Sun, 6 Jun 2010 02:46:13 +0000 (02:46 +0000)
doc/doc-txt/ChangeLog
doc/doc-txt/NewStuff
src/src/EDITME
src/src/buildconfig.c
src/src/exim.c

index 85edf47d1041f4d0a6bde47508379d4f4dff9a0e..8c88085f84394f8943fb2ba2f970ac59e83d2040 100644 (file)
@@ -1,4 +1,4 @@
-$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.625 2010/06/06 02:08:50 pdp Exp $
+$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.626 2010/06/06 02:46:13 pdp Exp $
 
 Change log file for Exim from version 4.21
 -------------------------------------------
 
 Change log file for Exim from version 4.21
 -------------------------------------------
@@ -40,6 +40,8 @@ PP/11 Bugzilla 922: Documentation dusting, patch provided by John Horne.
 
 PP/12 Bugzilla 973: Implement --version.
 
 
 PP/12 Bugzilla 973: Implement --version.
 
+PP/13 Bugzilla 752: Refuse to build/run if Exim user is root/0.
+
 
 Exim version 4.72
 -----------------
 
 Exim version 4.72
 -----------------
index fb7e9528ce5772603e54f40fa2586c15ad47994f..03c0d4833f900ccface38360850b478b91295712 100644 (file)
@@ -1,4 +1,4 @@
-$Cambridge: exim/doc/doc-txt/NewStuff,v 1.171 2010/06/06 01:35:41 pdp Exp $
+$Cambridge: exim/doc/doc-txt/NewStuff,v 1.172 2010/06/06 02:46:13 pdp Exp $
 
 New Features in Exim
 --------------------
 
 New Features in Exim
 --------------------
@@ -63,6 +63,18 @@ Version 4.73
       control = debug/opts=+expand+acl
       control = debug/tag=.$message_exim_id/opts=+expand
 
       control = debug/opts=+expand+acl
       control = debug/tag=.$message_exim_id/opts=+expand
 
+ 7. It has always been implicit in the design and the documentation that
+    "the Exim user" is not root.  src/EDITME said that using root was
+    "very strongly discouraged".  This is not enough to keep people from
+    shooting themselves in the foot in days when many don't configure Exim
+    themselves but via package build managers.  The security consequences of
+    running various bits of network code are severe if there should be bugs in
+    them.  As such, the Exim user may no longer be root.  If configured
+    statically, Exim will refuse to build.  If configured as ref:user then Exim
+    will exit shortly after start-up.  If you must shoot yourself in the foot,
+    then henceforth you will have to maintain your own local patches to strip
+    the safeties off.
+
 
 Version 4.72
 ------------
 
 Version 4.72
 ------------
index 85922f8aaa975f88a96b0cf6e59b807bb126b2da..7f7f6b3a44e7c033124513f618251731f085779a 100644 (file)
@@ -1,4 +1,4 @@
-# $Cambridge: exim/src/src/EDITME,v 1.25 2010/06/05 11:13:29 pdp Exp $
+# $Cambridge: exim/src/src/EDITME,v 1.26 2010/06/06 02:46:13 pdp Exp $
 
 ##################################################
 #          The Exim mail transport agent         #
 
 ##################################################
 #          The Exim mail transport agent         #
@@ -131,8 +131,7 @@ CONFIGURE_FILE=/usr/exim/configure
 # group that is used for Exim processes when they no longer need to be root. In
 # particular, this applies when receiving messages and when doing remote
 # deliveries. (Local deliveries run as various non-root users, typically as the
 # group that is used for Exim processes when they no longer need to be root. In
 # particular, this applies when receiving messages and when doing remote
 # deliveries. (Local deliveries run as various non-root users, typically as the
-# owner of a local mailbox.) Specifying these values as root is very strongly
-# discouraged.
+# owner of a local mailbox.) Specifying these values as root is not supported.
 
 EXIM_USER=
 
 
 EXIM_USER=
 
index 51fe026181bffdf95eeba48eb8174e41621fcd8d..36561a968c00590466d678282f46ba3b67116573 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/buildconfig.c,v 1.15 2009/11/16 19:50:36 nm4 Exp $ */
+/* $Cambridge: exim/src/src/buildconfig.c,v 1.16 2010/06/06 02:46:13 pdp Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -356,6 +356,7 @@ while (fgets(buffer, sizeof(buffer), base) != NULL)
     uid_t uid = 0;
     gid_t gid = 0;
     int gid_set = 0;
     uid_t uid = 0;
     gid_t gid = 0;
     int gid_set = 0;
+    int uid_not_set = 0;
     char *username = NULL;
     char *groupname = NULL;
     char *s;
     char *username = NULL;
     char *groupname = NULL;
     char *s;
@@ -410,6 +411,7 @@ while (fgets(buffer, sizeof(buffer), base) != NULL)
       while (isspace(*user)) user++;
       username = user;
       gid_set = 1;
       while (isspace(*user)) user++;
       username = user;
       gid_set = 1;
+      uid_not_set = 1;
       }
 
     else
       }
 
     else
@@ -503,6 +505,18 @@ while (fgets(buffer, sizeof(buffer), base) != NULL)
       return 1;
       }
 
       return 1;
       }
 
+    /* security sanity checks
+    if ref: is being used, we can never be sure, but we can take reasonable
+    steps to filter out the most obvious ones.  */
+
+    if ((!uid_not_set && uid == 0) ||
+        (strcmp(username, "root") == 0) ||
+        (strcmp(username, "toor") == 0) )
+      {
+      printf("\n*** Exim's internal user must not be root.\n\n");
+      return 1;
+      }
+
     /* Output user and group names or uid/gid. When names are set, uid/gid
     are set to zero but will be replaced at runtime. */
 
     /* Output user and group names or uid/gid. When names are set, uid/gid
     are set to zero but will be replaced at runtime. */
 
index 36f7a1b3d648b3d67acc5f3ae96d623baa5c4bb0..a68a06227e1b5bca2d31193e323d553052b14a27 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/exim.c,v 1.68 2010/06/06 02:08:50 pdp Exp $ */
+/* $Cambridge: exim/src/src/exim.c,v 1.69 2010/06/06 02:46:13 pdp Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -1234,6 +1234,12 @@ This is a feature to make the lives of binary distributors easier. */
 #ifdef EXIM_USERNAME
 if (route_finduser(US EXIM_USERNAME, &pw, &exim_uid))
   {
 #ifdef EXIM_USERNAME
 if (route_finduser(US EXIM_USERNAME, &pw, &exim_uid))
   {
+  if (exim_uid == 0)
+    {
+    fprintf(stderr, "exim: refusing to run with uid 0 for \"%s\"\n",
+      EXIM_USERNAME);
+    exit(EXIT_FAILURE);
+    }
   exim_gid = pw->pw_gid;
   }
 else
   exim_gid = pw->pw_gid;
   }
 else