MacOS: support large group-membership counts
authorJeremy Harris <jgh146exb@wizmail.org>
Sun, 14 Oct 2018 21:24:41 +0000 (22:24 +0100)
committerJeremy Harris <jgh146exb@wizmail.org>
Sun, 21 Oct 2018 12:17:10 +0000 (13:17 +0100)
src/OS/os.h-Darwin
src/src/exim.c
src/src/exim.h

index f3f22f084ac9d9791237402442b8ed8b8fcd8ffe..b597f9da30a965d330311e69bb4175e520e9cb94 100644 (file)
@@ -48,4 +48,9 @@ updating Exim to use the newer interface. */
 /* seems arpa/nameser.h does not define this */
 #define NS_MAXMSG 65535
 
+/* There may be very many supplementary groups for the user. See notes
+in "man 2 getgroups". */
+#define _DARWIN_UNLIMITED_GETGROUPS
+#define EXIM_GROUPLIST_SIZE 64
+
 /* End */
index 198e81d892c43588841e270cb2f25c58780a841c..75282f17301a408ea278885ae60cec92ac1113f9 100644 (file)
@@ -628,10 +628,10 @@ if (euid == root_uid || euid != uid || egid != gid || igflag)
 DEBUG(D_uid)
   {
   int group_count, save_errno;
-  gid_t group_list[NGROUPS_MAX];
+  gid_t group_list[EXIM_GROUPLIST_SIZE];
   debug_printf("changed uid/gid: %s\n  uid=%ld gid=%ld pid=%ld\n", msg,
     (long int)geteuid(), (long int)getegid(), (long int)getpid());
-  group_count = getgroups(NGROUPS_MAX, group_list);
+  group_count = getgroups(nelem(group_list), group_list);
   save_errno = errno;
   debug_printf("  auxiliary group list:");
   if (group_count > 0)
@@ -1541,7 +1541,7 @@ struct passwd *pw;
 struct stat statbuf;
 pid_t passed_qr_pid = (pid_t)0;
 int passed_qr_pipe = -1;
-gid_t group_list[NGROUPS_MAX];
+gid_t group_list[EXIM_GROUPLIST_SIZE];
 
 /* For the -bI: flag */
 enum commandline_info info_flag = CMDINFO_NONE;
@@ -3532,7 +3532,7 @@ check on the additional groups for the admin user privilege - can't do that
 till after reading the config, which might specify the exim gid. Therefore,
 save the group list here first. */
 
-if ((group_count = getgroups(NGROUPS_MAX, group_list)) < 0)
+if ((group_count = getgroups(nelem(group_list), group_list)) < 0)
   exim_fail("exim: getgroups() failed: %s\n", strerror(errno));
 
 /* There is a fundamental difference in some BSD systems in the matter of
index ca6221ffd5dbfeb89e130713ceb7975dfa282a74..79d1acf135c19d887e3765bf8e9182fa0020efba 100644 (file)
@@ -591,5 +591,11 @@ default to EDQUOT if it exists, otherwise ENOSPC. */
 # define POLLRDHUP (POLLIN | POLLHUP)
 #endif
 
+/* Some platforms (Darwin) have to define a larger limit on groups membership */
+
+#ifndef EXIM_GROUPLIST_SIZE
+# define EXIM_GROUPLIST_SIZE NGROUPS_MAX
+#endif
+
 #endif
 /* End of exim.h */