If setrlimit() barfs at 1000 file descriptors, try for 256 to
[exim.git] / src / src / exim.c
index 37f206d26bfb02a966d5076e1ce4719af175cc03..dcf261879dc935280d8dde5b9f130ddb778c6a43 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/exim.c,v 1.2 2004/10/14 11:21:02 ph10 Exp $ */
+/* $Cambridge: exim/src/src/exim.c,v 1.4 2004/10/18 09:26:02 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -1234,7 +1234,7 @@ because some OS define it in /usr/include/unistd.h. */
 
 extern char **environ;
 
-/* If the Exim user and/or group and/or the configuration file owner were
+/* If the Exim user and/or group and/or the configuration file owner/group were
 defined by ref:name at build time, we must now find the actual uid/gid values.
 This is a feature to make the lives of binary distributors easier. */
 
@@ -1269,6 +1269,15 @@ if (!route_finduser(US CONFIGURE_OWNERNAME, NULL, &config_uid))
   }
 #endif
 
+#ifdef CONFIGURE_GROUPNAME
+if (!route_findgroup(US CONFIGURE_GROUPNAME, &config_gid))
+  {
+  fprintf(stderr, "exim: failed to find gid for group name \"%s\"\n",
+    CONFIGURE_GROUPNAME);
+  exit(EXIT_FAILURE);
+  }
+#endif
+
 /* In the Cygwin environment, some initialization needs doing. It is fudged
 in by means of this macro. */
 
@@ -2828,12 +2837,21 @@ else
       strerror(errno));
     rlp.rlim_cur = rlp.rlim_max = 0;
     }
+    
+  /* I originally chose 1000 as a nice big number that was unlikely to 
+  be exceeded. It turns out that some older OS have a fixed upper limit of
+  256. */
+     
   if (rlp.rlim_cur < 1000)
     {
     rlp.rlim_cur = rlp.rlim_max = 1000;
     if (setrlimit(RLIMIT_NOFILE, &rlp) < 0)
-      log_write(0, LOG_MAIN|LOG_PANIC, "setrlimit(RLIMIT_NOFILE) failed: %s",
-        strerror(errno));
+      { 
+      rlp.rlim_cur = rlp.rlim_max = 256;
+      if (setrlimit(RLIMIT_NOFILE, &rlp) < 0)
+        log_write(0, LOG_MAIN|LOG_PANIC, "setrlimit(RLIMIT_NOFILE) failed: %s",
+          strerror(errno));
+      } 
     }
   #endif