[exim-cvs] MacOS: support large group-membership counts

Kezdőlap
Üzenet törlése
Válasz az üzenetre
Szerző: Exim Git Commits Mailing List
Dátum:  
Címzett: exim-cvs
Tárgy: [exim-cvs] MacOS: support large group-membership counts
Gitweb: https://git.exim.org/exim.git/commitdiff/157d73b585d3f7e0ae33a58b3e369b6ba6e6f7b6
Commit:     157d73b585d3f7e0ae33a58b3e369b6ba6e6f7b6
Parent:     9af3c5495821f33fc0bdd09375ff246120b6ca99
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Sun Oct 14 22:24:41 2018 +0100
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Sun Oct 21 13:17:10 2018 +0100


    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(-)


diff --git a/src/OS/os.h-Darwin b/src/OS/os.h-Darwin
index f3f22f0..b597f9d 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 198e81d..75282f1 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 ca6221f..79d1acf 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 */