summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Harris <jgh146exb@wizmail.org>2018-10-14 22:24:41 +0100
committerJeremy Harris <jgh146exb@wizmail.org>2018-10-21 13:17:10 +0100
commit157d73b585d3f7e0ae33a58b3e369b6ba6e6f7b6 (patch)
treedf2951341b708a53f8859886fea0f60c84bb8146
parent9af3c5495821f33fc0bdd09375ff246120b6ca99 (diff)
MacOS: support large group-membership counts
-rw-r--r--src/OS/os.h-Darwin5
-rw-r--r--src/src/exim.c8
-rw-r--r--src/src/exim.h6
3 files changed, 15 insertions, 4 deletions
diff --git a/src/OS/os.h-Darwin b/src/OS/os.h-Darwin
index f3f22f084..b597f9da3 100644
--- a/src/OS/os.h-Darwin
+++ b/src/OS/os.h-Darwin
@@ -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 */
diff --git a/src/src/exim.c b/src/src/exim.c
index 198e81d89..75282f173 100644
--- a/src/src/exim.c
+++ b/src/src/exim.c
@@ -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
diff --git a/src/src/exim.h b/src/src/exim.h
index ca6221ffd..79d1acf13 100644
--- a/src/src/exim.h
+++ b/src/src/exim.h
@@ -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 */