diff options
author | Jeremy Harris <jgh146exb@wizmail.org> | 2018-10-21 14:01:57 +0100 |
---|---|---|
committer | Jeremy Harris <jgh146exb@wizmail.org> | 2018-10-21 14:01:57 +0100 |
commit | 3b7ac02caeb878252361e602dc46e96104f773a9 (patch) | |
tree | f54f735fad9bfe574f195d3ac3115a33a112ab43 | |
parent | 157d73b585d3f7e0ae33a58b3e369b6ba6e6f7b6 (diff) |
MacOS: fix egid problem
-rw-r--r-- | src/src/exim.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/src/exim.c b/src/src/exim.c index 75282f173..b6d926b50 100644 --- a/src/src/exim.c +++ b/src/src/exim.c @@ -1492,6 +1492,7 @@ int recipients_arg = argc; int sender_address_domain = 0; int test_retry_arg = -1; int test_rewrite_arg = -1; +gid_t original_egid; BOOL arg_queue_only = FALSE; BOOL bi_option = FALSE; BOOL checking = FALSE; @@ -1818,6 +1819,7 @@ if ((namelen == 10 && Ustrcmp(argv[0], "newaliases") == 0) || normally be root, but in some esoteric environments it may not be. */ original_euid = geteuid(); +original_egid = getegid(); /* Get the real uid and gid. If the caller is root, force the effective uid/gid to be the same as the real ones. This makes a difference only if Exim is setuid @@ -3546,6 +3548,11 @@ over a single group - the current group, which is always the first group in the list. Calling setgroups() with zero groups on a "different" system results in an error return. The following code should cope with both types of system. + Unfortunately, recent MacOS, which should be a FreeBSD, "helpfully" succeeds + the "setgroups() with zero groups" - and changes the egid. + Thanks to that we had to stash the original_egid above, for use below + in the call to exim_setugid(). + However, if this process isn't running as root, setgroups() can't be used since you have to be root to run it, even if throwing away groups. Not being root here happens only in some unusual configurations. We just ignore the @@ -3605,7 +3612,7 @@ the real uid to the effective so that subsequent re-execs of Exim are done by a privileged user. */ else - exim_setugid(geteuid(), getegid(), FALSE, US"forcing real = effective"); + exim_setugid(geteuid(), original_egid, FALSE, US"forcing real = effective"); /* If testing a filter, open the file(s) now, before wasting time doing other setups and reading the message. */ |