Skip to content

Commit

Permalink
Avoid doing logging in signal-handlers. Bug 1007
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Harris committed Apr 15, 2018
1 parent d99f54e commit 9723f96
Show file tree
Hide file tree
Showing 42 changed files with 245 additions and 202 deletions.
7 changes: 6 additions & 1 deletion doc/doc-docbook/spec.xfpt
Original file line number Diff line number Diff line change
Expand Up @@ -32736,10 +32736,15 @@ code. The incident is logged on the main and reject logs.
.section "Building Exim to use a local scan function" "SECID207"
.cindex "&[local_scan()]& function" "building Exim to use"
To make use of the local scan function feature, you must tell Exim where your
function is before building Exim, by setting LOCAL_SCAN_SOURCE in your
function is before building Exim, by setting
.new
both HAVE_LOCAL_SCAN and
.wen
LOCAL_SCAN_SOURCE in your
&_Local/Makefile_&. A recommended place to put it is in the &_Local_&
directory, so you might set
.code
HAVE_LOCAL_SCAN=yes
LOCAL_SCAN_SOURCE=Local/local_scan.c
.endd
for example. The function must be called &[local_scan()]&. It is called by
Expand Down
7 changes: 7 additions & 0 deletions doc/doc-txt/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ options, and new features, see the NewStuff file next to this ChangeLog.
Exim version 4.92
-----------------

JH/01 Remove code calling the customisable local_scan function, unless a new
definition "HAVE_LOCAL_SCAN=yes" is present in the Local/Makefile.

JH/02 Bug 1007: Avoid doing logging from signal-handlers, as that can result in
non-signal-safe funxtions being used.


Exim version 4.91
-----------------

Expand Down
1 change: 1 addition & 0 deletions src/src/config.h.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Do not put spaces between # and the 'define'.
#define FIXED_NEVER_USERS "root"

#define HAVE_CRYPT16
#define HAVE_LOCAL_SCAN
#define HAVE_SA_LEN
#define HEADERS_CHARSET "ISO-8859-1"
#define HEADER_ADD_BUFFER_SIZE (8192 * 4)
Expand Down
2 changes: 2 additions & 0 deletions src/src/expand.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,9 @@ static var_entry var_table[] = {
{ "local_part_data", vtype_stringptr, &deliver_localpart_data },
{ "local_part_prefix", vtype_stringptr, &deliver_localpart_prefix },
{ "local_part_suffix", vtype_stringptr, &deliver_localpart_suffix },
#ifdef HAVE_LOCAL_SCAN
{ "local_scan_data", vtype_stringptr, &local_scan_data },
#endif
{ "local_user_gid", vtype_gid, &local_user_gid },
{ "local_user_uid", vtype_uid, &local_user_uid },
{ "localhost_number", vtype_int, &host_number },
Expand Down
4 changes: 4 additions & 0 deletions src/src/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,10 @@ extern int sieve_interpret(uschar *, int, uschar *, uschar *, uschar *,
extern void sigalrm_handler(int);
extern BOOL smtp_buffered(void);
extern void smtp_closedown(uschar *);
extern void smtp_command_timeout_exit(void);
extern void smtp_command_sigterm_exit(void);
extern void smtp_data_timeout_exit(void);
extern void smtp_data_sigint_exit(void);
extern uschar *smtp_cmd_hist(void);
extern int smtp_connect(host_item *, int, uschar *, int,
transport_instance *);
Expand Down
6 changes: 6 additions & 0 deletions src/src/globals.c
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,10 @@ uschar *gecos_name = NULL;
uschar *gecos_pattern = NULL;
rewrite_rule *global_rewrite_rules = NULL;

volatile sig_atomic_t had_command_timeout = 0;
volatile sig_atomic_t had_command_sigterm = 0;
volatile sig_atomic_t had_data_timeout = 0;
volatile sig_atomic_t had_data_sigint = 0;
uschar *headers_charset = US HEADERS_CHARSET;
int header_insert_maxlen = 64 * 1024;
header_line *header_last = NULL;
Expand Down Expand Up @@ -853,8 +857,10 @@ uschar *local_interfaces = US"<; ::0 ; 0.0.0.0";
uschar *local_interfaces = US"0.0.0.0";
#endif

#ifdef HAVE_LOCAL_SCAN
uschar *local_scan_data = NULL;
int local_scan_timeout = 5*60;
#endif
BOOL local_sender_retain = FALSE;
gid_t local_user_gid = (gid_t)(-1);
uid_t local_user_uid = (uid_t)(-1);
Expand Down
6 changes: 6 additions & 0 deletions src/src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,10 @@ extern uschar *gecos_name; /* To be expanded when pattern matches */
extern uschar *gecos_pattern; /* Pattern to match */
extern rewrite_rule *global_rewrite_rules; /* Chain of rewriting rules */

extern volatile sig_atomic_t had_command_timeout; /* Alarm sighandler called */
extern volatile sig_atomic_t had_command_sigterm; /* TERM sighandler called */
extern volatile sig_atomic_t had_data_timeout; /* Alarm sighandler called */
extern volatile sig_atomic_t had_data_sigint; /* TERM/INT sighandler called */
extern int header_insert_maxlen; /* Max for inserting headers */
extern int header_maxsize; /* Max total length for header */
extern int header_line_maxsize; /* Max for an individual line */
Expand Down Expand Up @@ -544,10 +548,12 @@ extern BOOL local_from_check; /* For adding Sender: (global value) */
extern uschar *local_from_prefix; /* Permitted prefixes */
extern uschar *local_from_suffix; /* Permitted suffixes */
extern uschar *local_interfaces; /* For forcing specific interfaces */
#ifdef HAVE_LOCAL_SCAN
extern uschar *local_scan_data; /* Text returned by local_scan() */
extern optionlist local_scan_options[];/* Option list for local_scan() */
extern int local_scan_options_count; /* Size of the list */
extern int local_scan_timeout; /* Timeout for local_scan() */
#endif
extern BOOL local_sender_retain; /* Retain Sender: (with no From: check) */
extern gid_t local_user_gid; /* As it says; may be set in routers */
extern uid_t local_user_uid; /* As it says; may be set in routers */
Expand Down
1 change: 1 addition & 0 deletions src/src/local_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ If you want to implement your own version, you should copy this file to, say
Local/local_scan.c, and edit the copy. To use your version instead of the
default, you must set
HAVE_LOCAL_SCAN=yes
LOCAL_SCAN_SOURCE=Local/local_scan.c
in your Local/Makefile. This makes it easy to copy your version for use with
Expand Down
2 changes: 2 additions & 0 deletions src/src/readconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ static optionlist optionlist_config[] = {
{ "local_from_prefix", opt_stringptr, &local_from_prefix },
{ "local_from_suffix", opt_stringptr, &local_from_suffix },
{ "local_interfaces", opt_stringptr, &local_interfaces },
#ifdef HAVE_LOCAL_SCAN
{ "local_scan_timeout", opt_time, &local_scan_timeout },
#endif
{ "local_sender_retain", opt_bool, &local_sender_retain },
{ "localhost_number", opt_stringptr, &host_number_string },
{ "log_file_path", opt_stringptr, &log_file_path },
Expand Down

0 comments on commit 9723f96

Please sign in to comment.