Gitweb:
http://git.exim.org/exim.git/commitdiff/cd59ab18b06626887aecef760c416ae7936924da
Commit: cd59ab18b06626887aecef760c416ae7936924da
Parent: 0dda43406a4b207504213c58f668de9354ea915e
Author: Phil Pennock <pdp@???>
AuthorDate: Sun Feb 20 23:28:45 2011 -0500
Committer: Phil Pennock <pdp@???>
CommitDate: Sun Feb 20 23:30:09 2011 -0500
Minor robustness fixes for debugging.
sig_atomic_t for signal-handlers.
getgroups() return value checking.
Developed for bug 927.
---
doc/doc-txt/ChangeLog | 5 +++++
src/src/daemon.c | 4 ++--
src/src/exim.c | 10 +++++++++-
src/src/globals.c | 2 +-
src/src/globals.h | 8 +++++++-
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 3f7a38c..862f1b8 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 3db9be3..c11e2ed 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 cf48c04..c368e59 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 3882a30..60ef8e0 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 cc9021e..1f04632 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 36860a8..abf1f53 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