diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/src/acl.c | 3 | ||||
-rw-r--r-- | src/src/functions.h | 7 | ||||
-rw-r--r-- | src/src/globals.c | 9 | ||||
-rw-r--r-- | src/src/globals.h | 2 | ||||
-rw-r--r-- | src/src/log.c | 42 | ||||
-rw-r--r-- | src/src/macros.h | 1 | ||||
-rw-r--r-- | src/src/spool_in.c | 10 | ||||
-rw-r--r-- | src/src/spool_out.c | 6 |
8 files changed, 57 insertions, 23 deletions
diff --git a/src/src/acl.c b/src/src/acl.c index e2356e188..fb78a7b5f 100644 --- a/src/src/acl.c +++ b/src/src/acl.c @@ -3481,8 +3481,7 @@ for (; cb; cb = cb->next) case CONTROL_DEBUG: { - uschar * debug_tag = NULL; - uschar * debug_opts = NULL; + uschar * debug_tag = NULL, * debug_opts = NULL; BOOL kill = FALSE, stop = FALSE; while (*p == '/') diff --git a/src/src/functions.h b/src/src/functions.h index 07df8755b..224666cb1 100644 --- a/src/src/functions.h +++ b/src/src/functions.h @@ -187,7 +187,8 @@ extern void daemon_go(void); extern int dcc_process(uschar **); #endif -extern void debug_logging_activate(uschar *, uschar *); +extern void debug_logging_activate(const uschar *, const uschar *); +extern void debug_logging_from_spool(const uschar *); extern void debug_logging_stop(BOOL); extern void debug_print_argv(const uschar **); extern void debug_print_ids(uschar *); @@ -201,7 +202,7 @@ extern void debug_print_socket(int); extern void debug_trigger_fire(void); extern void decode_bits(unsigned int *, size_t, int *, - uschar *, bit_table *, int, uschar *, int); + const uschar *, bit_table *, int, uschar *, int); extern void delete_pid_file(void); extern void deliver_local(address_item *, BOOL); extern address_item *deliver_make_addr(uschar *, BOOL); @@ -323,7 +324,7 @@ extern int ip_streamsocket(const uschar *, uschar **, int, host_item *); extern int ipv6_nmtoa(int *, uschar *); extern uschar *local_part_quote(uschar *); -extern int log_open_as_exim(uschar * const); +extern int log_open_as_exim(const uschar * const); extern void log_close_all(void); extern macro_item * macro_create(const uschar *, const uschar *, BOOL); diff --git a/src/src/globals.c b/src/src/globals.c index 918b2c304..ff246feb4 100644 --- a/src/src/globals.c +++ b/src/src/globals.c @@ -814,10 +814,11 @@ bit_table debug_options[] = { /* must be in alphabetical order and use BIT_TABLE(D, uid), BIT_TABLE(D, verify), }; -int debug_options_count = nelem(debug_options); -unsigned debug_pretrigger_bsize= 0; -uschar * debug_pretrigger_buf = NULL; -unsigned int debug_selector = 0; +int debug_options_count = nelem(debug_options); +uschar debuglog_name[LOG_NAME_SIZE] = {0}; +unsigned debug_pretrigger_bsize = 0; +uschar * debug_pretrigger_buf = NULL; +unsigned int debug_selector = 0; int delay_warning[DELAY_WARNING_SIZE] = { DELAY_WARNING_SIZE, 1, 24*60*60 }; uschar *delay_warning_condition= diff --git a/src/src/globals.h b/src/src/globals.h index f2de276f3..fe099e402 100644 --- a/src/src/globals.h +++ b/src/src/globals.h @@ -493,6 +493,8 @@ extern int debug_options_count; /* Size of table */ extern unsigned debug_pretrigger_bsize; extern uschar *debug_pretrigger_buf; /* circular buffer for precapture */ extern BOOL debug_store; /* Do extra checks on store_reset */ +extern uschar debuglog_name[LOG_NAME_SIZE]; /* ACL-init debug */ + extern int delay_warning[]; /* Times between warnings */ extern uschar *delay_warning_condition; /* Condition string for warnings */ extern BOOL delivery_date_remove; /* Remove delivery-date headers */ diff --git a/src/src/log.c b/src/src/log.c index 18ea3e0cf..8ca973f2d 100644 --- a/src/src/log.c +++ b/src/src/log.c @@ -12,7 +12,6 @@ log files was originally contributed by Tony Sheen. */ #include "exim.h" -#define LOG_NAME_SIZE 256 #define MAX_SYSLOG_LEN 870 #define LOG_MODE_FILE 1 @@ -30,7 +29,6 @@ static uschar *log_names[] = { US"main", US"reject", US"panic", US"debug" }; static uschar mainlog_name[LOG_NAME_SIZE]; static uschar rejectlog_name[LOG_NAME_SIZE]; -static uschar debuglog_name[LOG_NAME_SIZE]; static uschar *mainlog_datestamp = NULL; static uschar *rejectlog_datestamp = NULL; @@ -268,7 +266,7 @@ Returns: a file descriptor, or < 0 on failure (errno set) */ static int -log_open_already_exim(uschar * const name) +log_open_already_exim(const uschar * const name) { int fd = -1; const int flags = O_WRONLY | O_APPEND | O_CREAT | O_NONBLOCK; @@ -392,7 +390,7 @@ Returns: a file descriptor, or < 0 on failure (errno set) */ int -log_open_as_exim(uschar * const name) +log_open_as_exim(const uschar * const name) { int fd = -1; const uid_t euid = geteuid(); @@ -475,7 +473,7 @@ Returns: nothing */ static void -open_log(int *fd, int type, uschar *tag) +open_log(int * fd, int type, const uschar * tag) { uid_t euid; BOOL ok, ok2; @@ -531,8 +529,8 @@ switch (type) default: /* Remove any datestamp if this is the panic log. This is rare, so there's no - need to optimize getting the datestamp length. We remove one non-alphanumeric - char afterwards if at the start, otherwise one before. */ + need to optimize getting the datestamp length. We remove one non-alphanumeric + char afterwards if at the start, otherwise one before. */ if (string_datestamp_offset >= 0) { uschar * from = buffer + string_datestamp_offset; @@ -1365,8 +1363,9 @@ Returns: nothing on success - bomb out on failure */ void -decode_bits(unsigned int *selector, size_t selsize, int *notall, - uschar *string, bit_table *options, int count, uschar *which, int flags) +decode_bits(unsigned int * selector, size_t selsize, int * notall, + const uschar * string, bit_table * options, int count, uschar * which, + int flags) { uschar *errmsg; if (!string) return; @@ -1375,7 +1374,7 @@ if (*string == '=') { char *end; /* Not uschar */ memset(selector, 0, sizeof(*selector)*selsize); - *selector = strtoul(CS string+1, &end, 0); + *selector = strtoul(CCS string+1, &end, 0); if (!*end) return; errmsg = string_sprintf("malformed numeric %s_selector setting: %s", which, string); @@ -1387,9 +1386,9 @@ if (*string == '=') else for(;;) { BOOL adding; - uschar *s; + const uschar * s; int len; - bit_table *start, *end; + bit_table * start, * end; Uskip_whitespace(&string); if (!*string) return; @@ -1485,7 +1484,7 @@ immediately but only upon a trigger - but we'd need another cmdline option to pass the name through child_exxec_exim(). */ void -debug_logging_activate(uschar *tag_name, uschar *opts) +debug_logging_activate(const uschar * tag_name, const uschar * opts) { if (debug_file) { @@ -1522,6 +1521,23 @@ else void +debug_logging_from_spool(const uschar * filename) +{ +if (debug_fd < 0) + { + Ustrncpy(debuglog_name, filename, sizeof(debuglog_name)); + if ((debug_fd = log_open_as_exim(filename)) >= 0) + debug_file = fdopen(debug_fd, "w"); + DEBUG(D_deliver) debug_printf("debug enabled by spoolfile\n"); + } +/* +else DEBUG(D_deliver) + debug_printf("debug already active; ignoring spoolfile '%s'\n", filename); +*/ +} + + +void debug_logging_stop(BOOL kill) { debug_pretrigger_discard(); diff --git a/src/src/macros.h b/src/src/macros.h index 304e45d33..fa89de12d 100644 --- a/src/src/macros.h +++ b/src/src/macros.h @@ -105,6 +105,7 @@ don't make the file descriptors two-way. */ /* Debugging control */ +#define LOG_NAME_SIZE 256 #define DEBUG(x) if (debug_selector & (x)) #define HDEBUG(x) if (host_checking || debug_selector & (x)) diff --git a/src/src/spool_in.c b/src/src/spool_in.c index 82885db56..2aa0b0b55 100644 --- a/src/src/spool_in.c +++ b/src/src/spool_in.c @@ -300,6 +300,9 @@ message_smtputf8 = FALSE; message_utf8_downconvert = 0; #endif +#ifndef COMPILE_UTILITY +debuglog_name[0] = '\0'; +#endif dsn_ret = 0; dsn_envid = NULL; } @@ -594,11 +597,16 @@ for (;;) case 'd': if (Ustrcmp(p, "eliver_firsttime") == 0) f.deliver_firsttime = TRUE; - /* Check if the dsn flags have been set in the header file */ else if (Ustrncmp(p, "sn_ret", 6) == 0) dsn_ret= atoi(CS var + 7); else if (Ustrncmp(p, "sn_envid", 8) == 0) dsn_envid = string_copy_taint(var + 10, proto_mem); +#ifndef COMPILE_UTILITY + else if (Ustrncmp(p, "ebug_selector ", 14) == 0) + debug_selector = strtol(CS var + 15, NULL, 0); + else if (Ustrncmp(p, "ebuglog_name ", 13) == 0) + debug_logging_from_spool(var + 14); +#endif break; case 'f': diff --git a/src/src/spool_out.c b/src/src/spool_out.c index e04917ca5..713584091 100644 --- a/src/src/spool_out.c +++ b/src/src/spool_out.c @@ -230,6 +230,12 @@ tree_walk(acl_var_m, &acl_var_write, fp); /* Now any other data that needs to be remembered. */ +if (*debuglog_name) + { + fprintf(fp, "-debug_selector 0x%x\n", debug_selector); + fprintf(fp, "-debuglog_name %s\n", debuglog_name); + } + if (f.spool_file_wireformat) fprintf(fp, "-spool_file_wireformat\n"); else |