diff options
author | Jeremy Harris <jgh146exb@wizmail.org> | 2015-01-12 16:01:38 +0000 |
---|---|---|
committer | Jeremy Harris <jgh146exb@wizmail.org> | 2015-01-13 11:02:02 +0000 |
commit | 1ad6489edabbfce85ee7362370cee4b34739c234 (patch) | |
tree | 8ad8fb24714607d286a4efe997156ccd33b5f4bf /src | |
parent | 0ad2e0fcde2f23e3809687095bddb31f9af4896e (diff) |
Make smtp_receive_timeout main option expanded. Bug 564
Diffstat (limited to 'src')
-rw-r--r-- | src/src/functions.h | 2 | ||||
-rw-r--r-- | src/src/globals.c | 1 | ||||
-rw-r--r-- | src/src/globals.h | 1 | ||||
-rw-r--r-- | src/src/macros.h | 2 | ||||
-rw-r--r-- | src/src/readconf.c | 39 | ||||
-rw-r--r-- | src/src/smtp_in.c | 13 |
6 files changed, 51 insertions, 7 deletions
diff --git a/src/src/functions.h b/src/src/functions.h index a906e921f..2e18fd963 100644 --- a/src/src/functions.h +++ b/src/src/functions.h @@ -292,7 +292,7 @@ extern void readconf_main(void); extern void readconf_print(uschar *, uschar *, BOOL); extern uschar *readconf_printtime(int); extern uschar *readconf_readname(uschar *, int, uschar *); -extern int readconf_readtime(uschar *, int, BOOL); +extern int readconf_readtime(const uschar *, int, BOOL); extern void readconf_rest(); extern uschar *readconf_retry_error(uschar *, uschar *, int *, int *); extern void read_message_body(BOOL); diff --git a/src/src/globals.c b/src/src/globals.c index 85d2e5c36..a8670e414 100644 --- a/src/src/globals.c +++ b/src/src/globals.c @@ -1254,6 +1254,7 @@ uschar *smtp_ratelimit_mail = NULL; uschar *smtp_ratelimit_rcpt = NULL; uschar *smtp_read_error = US""; int smtp_receive_timeout = 5*60; +uschar *smtp_receive_timeout_s = NULL; uschar *smtp_reserve_hosts = NULL; BOOL smtp_return_error_details = FALSE; int smtp_rlm_base = 0; diff --git a/src/src/globals.h b/src/src/globals.h index 7ca07d56c..5495f54db 100644 --- a/src/src/globals.h +++ b/src/src/globals.h @@ -801,6 +801,7 @@ extern uschar *smtp_ratelimit_mail; /* Parameters for MAIL limiting */ extern uschar *smtp_ratelimit_rcpt; /* Parameters for RCPT limiting */ extern uschar *smtp_read_error; /* Message for SMTP input error */ extern int smtp_receive_timeout; /* Applies to each received line */ +extern uschar *smtp_receive_timeout_s; /* ... expandable version */ extern uschar *smtp_reserve_hosts; /* Hosts for reserved slots */ extern BOOL smtp_return_error_details; /* TRUE to return full info */ extern int smtp_rlm_base; /* Base interval for MAIL rate limit */ diff --git a/src/src/macros.h b/src/src/macros.h index 2085c3f41..43179a531 100644 --- a/src/src/macros.h +++ b/src/src/macros.h @@ -629,7 +629,7 @@ can be easily tested as a group. That is the only use of opt_bool_last. */ enum { opt_bit = 32, opt_bool_verify, opt_bool_set, opt_expand_bool, opt_bool_last, opt_rewrite, opt_timelist, opt_uid, opt_gid, opt_uidlist, opt_gidlist, - opt_expand_uid, opt_expand_gid, opt_void }; + opt_expand_uid, opt_expand_gid, opt_func, opt_void }; /* There's a high-ish bit which is used to flag duplicate options, kept for compatibility, which shouldn't be output. Also used for hidden options diff --git a/src/src/readconf.c b/src/src/readconf.c index 687b35223..60df37afc 100644 --- a/src/src/readconf.c +++ b/src/src/readconf.c @@ -11,6 +11,9 @@ implementation of the conditional .ifdef etc. */ #include "exim.h" +static void fn_smtp_receive_timeout(const uschar * name, const uschar * str); + + #define CSTATE_STACK_SIZE 10 @@ -392,7 +395,7 @@ static optionlist optionlist_config[] = { { "smtp_ratelimit_hosts", opt_stringptr, &smtp_ratelimit_hosts }, { "smtp_ratelimit_mail", opt_stringptr, &smtp_ratelimit_mail }, { "smtp_ratelimit_rcpt", opt_stringptr, &smtp_ratelimit_rcpt }, - { "smtp_receive_timeout", opt_time, &smtp_receive_timeout }, + { "smtp_receive_timeout", opt_func, &fn_smtp_receive_timeout }, { "smtp_reserve_hosts", opt_stringptr, &smtp_reserve_hosts }, { "smtp_return_error_details",opt_bool, &smtp_return_error_details }, #ifdef WITH_CONTENT_SCAN @@ -1027,7 +1030,7 @@ Returns: the time value, or -1 on syntax error */ int -readconf_readtime(uschar *s, int terminator, BOOL return_msec) +readconf_readtime(const uschar *s, int terminator, BOOL return_msec) { int yield = 0; for (;;) @@ -1036,7 +1039,7 @@ for (;;) double fraction; if (!isdigit(*s)) return -1; - (void)sscanf(CS s, "%d%n", &value, &count); + (void)sscanf(CCS s, "%d%n", &value, &count); s += count; switch (*s) @@ -1050,7 +1053,7 @@ for (;;) case '.': if (!return_msec) return -1; - (void)sscanf(CS s, "%lf%n", &fraction, &count); + (void)sscanf(CCS s, "%lf%n", &fraction, &count); s += count; if (*s++ != 's') return -1; yield += (int)(fraction * 1000.0); @@ -1351,6 +1354,26 @@ return yield; /************************************************* +* Custom-handler options * +*************************************************/ +static void +fn_smtp_receive_timeout(const uschar * name, const uschar * str) +{ +int value; + +if (*str == '$') + smtp_receive_timeout_s = string_copy(str); +else + { + /* "smtp_receive_timeout", opt_time, &smtp_receive_timeout */ + smtp_receive_timeout = readconf_readtime(str, 0, FALSE); + if (smtp_receive_timeout < 0) + log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "invalid time value for %s", + name); + } +} + +/************************************************* * Handle option line * *************************************************/ @@ -2116,9 +2139,15 @@ switch (type) name); if (count > 0 && list[2] == 0) count = 0; list[1] = count; + break; } - break; + case opt_func: + { + void (*fn)() = ol->value; + fn(name, s); + break; + } } return TRUE; diff --git a/src/src/smtp_in.c b/src/src/smtp_in.c index d646fe0bd..4fc2cfd41 100644 --- a/src/src/smtp_in.c +++ b/src/src/smtp_in.c @@ -2129,6 +2129,19 @@ if (!sender_host_unknown) set_process_info("handling incoming connection from %s", host_and_ident(FALSE)); + /* Expand smtp_receive_timeout, if needed */ + + if (smtp_receive_timeout_s) + { + uschar * exp; + if ( !(exp = expand_string(smtp_receive_timeout_s)) + || !(*exp) + || (smtp_receive_timeout = readconf_readtime(exp, 0, FALSE)) < 0 + ) + log_write(0, LOG_MAIN|LOG_PANIC, + "bad value for smtp_receive_timeout: '%s'", exp ? exp : US""); + } + /* Start up TLS if tls_on_connect is set. This is for supporting the legacy smtps port for use with older style SSL MTAs. */ |