sig_atomic_t for signal-handlers.
getgroups() return value checking.
Developed for bug 927.
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
-----------------
* 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;
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");
}
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
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;
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
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 */
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