From 157d73b585d3f7e0ae33a58b3e369b6ba6e6f7b6 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Sun, 14 Oct 2018 22:24:41 +0100 Subject: MacOS: support large group-membership counts --- src/OS/os.h-Darwin | 5 +++++ src/src/exim.c | 8 ++++---- src/src/exim.h | 6 ++++++ 3 files changed, 15 insertions(+), 4 deletions(-) (limited to 'src') 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 */ -- cgit v1.2.3