diff options
author | Phil Pennock <pdp@exim.org> | 2011-02-20 23:28:45 -0500 |
---|---|---|
committer | Phil Pennock <pdp@exim.org> | 2011-02-20 23:30:09 -0500 |
commit | cd59ab18b06626887aecef760c416ae7936924da (patch) | |
tree | 10e1a33d52da2893c635beb7d64228dc342eac8b | |
parent | 0dda43406a4b207504213c58f668de9354ea915e (diff) |
Minor robustness fixes for debugging.
sig_atomic_t for signal-handlers.
getgroups() return value checking.
Developed for bug 927.
-rw-r--r-- | doc/doc-txt/ChangeLog | 5 | ||||
-rw-r--r-- | src/src/daemon.c | 4 | ||||
-rw-r--r-- | src/src/exim.c | 10 | ||||
-rw-r--r-- | src/src/globals.c | 2 | ||||
-rw-r--r-- | src/src/globals.h | 8 | ||||
-rw-r--r-- | src/src/mytypes.h | 4 |
6 files changed, 27 insertions, 6 deletions
diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index 3f7a38c56..862f1b887 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -55,6 +55,11 @@ PP/09 New lookups functionality failed to compile on old gcc which rejects extern declarations in function scope. Patch from Oliver Fleischmann +PP/10 Use sig_atomic_t for flags set from signal handlers. + Check getgroups() return and improve debugging. + Fixed developed for diagnosis in bug 927 (which turned out to be + a kernel bug). + Exim version 4.74 ----------------- diff --git a/src/src/daemon.c b/src/src/daemon.c index 3db9be374..c11e2ed0a 100644 --- a/src/src/daemon.c +++ b/src/src/daemon.c @@ -31,8 +31,8 @@ static smtp_slot empty_smtp_slot = { 0, NULL }; * Local static variables * *************************************************/ -static volatile BOOL sigchld_seen; -static volatile BOOL sighup_seen; +static SIGNAL_BOOL sigchld_seen; +static SIGNAL_BOOL sighup_seen; static int accept_retry_count = 0; static int accept_retry_errno; diff --git a/src/src/exim.c b/src/src/exim.c index cf48c04b3..c368e5906 100644 --- a/src/src/exim.c +++ b/src/src/exim.c @@ -570,17 +570,20 @@ if (euid == root_uid || euid != uid || egid != gid || igflag) DEBUG(D_uid) { - int group_count; + int group_count, save_errno; gid_t group_list[NGROUPS_MAX]; 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); + save_errno = errno; debug_printf(" auxiliary group list:"); if (group_count > 0) { int i; for (i = 0; i < group_count; i++) debug_printf(" %d", (int)group_list[i]); } + else if (group_count < 0) + debug_printf(" <error: %s>", strerror(save_errno)); else debug_printf(" <none>"); debug_printf("\n"); } @@ -3281,6 +3284,11 @@ till after reading the config, which might specify the exim gid. Therefore, save the group list here first. */ group_count = getgroups(NGROUPS_MAX, group_list); +if (group_count < 0) + { + fprintf(stderr, "exim: getgroups() failed: %s\n", strerror(errno)); + exit(EXIT_FAILURE); + } /* There is a fundamental difference in some BSD systems in the matter of groups. FreeBSD and BSDI are known to be different; NetBSD and OpenBSD are diff --git a/src/src/globals.c b/src/src/globals.c index 3882a3074..60ef8e0a8 100644 --- a/src/src/globals.c +++ b/src/src/globals.c @@ -1073,7 +1073,7 @@ int sender_verified_rc = -1; BOOL sender_verified_responded = FALSE; uschar *sending_ip_address = NULL; int sending_port = -1; -volatile BOOL sigalrm_seen = FALSE; +SIGNAL_BOOL sigalrm_seen = FALSE; uschar **sighup_argv = NULL; int smtp_accept_count = 0; BOOL smtp_accept_keepalive = TRUE; diff --git a/src/src/globals.h b/src/src/globals.h index cc9021e1b..1f0463264 100644 --- a/src/src/globals.h +++ b/src/src/globals.h @@ -18,6 +18,12 @@ local_scan.h header file. */ extern int h_errno; #endif +/* We need to be careful about width of int and atomicity in signal handlers, +especially with the rise of 64-bit systems breaking older assumptions. But +sig_atomic_t comes from signal.h so can't go into mytypes.h without including +signal support in local_scan, which seems precipitous. */ +typedef volatile sig_atomic_t SIGNAL_BOOL; + /* Now things that are present only when configured. */ #ifdef EXIM_PERL @@ -659,7 +665,7 @@ extern address_item *sender_verified_list; /* Saved chain of sender verifies */ extern address_item *sender_verified_failed; /* The one that caused denial */ extern uschar *sending_ip_address; /* Address of outgoing (SMTP) interface */ extern int sending_port; /* Port of outgoing interface */ -extern volatile BOOL sigalrm_seen; /* Flag for sigalrm_handler */ +extern SIGNAL_BOOL sigalrm_seen; /* Flag for sigalrm_handler */ extern uschar **sighup_argv; /* Args for re-execing after SIGHUP */ extern int smtp_accept_count; /* Count of connections */ extern BOOL smtp_accept_keepalive; /* Set keepalive on incoming */ diff --git a/src/src/mytypes.h b/src/src/mytypes.h index 36860a892..abf1f5333 100644 --- a/src/src/mytypes.h +++ b/src/src/mytypes.h @@ -42,8 +42,10 @@ the arguments of printf-like functions. This is done by a macro. */ the standard header files, so we use "uschar". Solaris has u_char in sys/types.h. This is just a typing convenience, of course. */ -typedef int BOOL; typedef unsigned char uschar; +typedef int BOOL; +/* We also have SIGNAL_BOOL, which requires signal.h be included, so is defined +elsewhere */ /* These macros save typing for the casting that is needed to cope with the |