git://git.exim.org
/
exim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add retry type "lookup". Bug 1566
[exim.git]
/
src
/
src
/
readconf.c
diff --git
a/src/src/readconf.c
b/src/src/readconf.c
index 31a4f2da48ca35c56eec37f450e6de86405217bd..e2d3c518f4e1e40d647752f63a0eec06b72fea85 100644
(file)
--- a/
src/src/readconf.c
+++ b/
src/src/readconf.c
@@
-1085,7
+1085,7
@@
Returns: the value, or -1 on error
*/
static int
*/
static int
-readconf_readfixed(uschar *s, int terminator)
+readconf_readfixed(
const
uschar *s, int terminator)
{
int yield = 0;
int value, count;
{
int yield = 0;
int value, count;
@@
-1191,7
+1191,7
@@
Returns: doesn't return; dies
*/
static void
*/
static void
-extra_chars_error(
uschar *s, uschar *t1, uschar *t2,
uschar *t3)
+extra_chars_error(
const uschar *s, const uschar *t1, const uschar *t2, const
uschar *t3)
{
uschar *comment = US"";
if (*s == '#') comment = US" (# is comment only at line start)";
{
uschar *comment = US"";
if (*s == '#') comment = US" (# is comment only at line start)";
@@
-1227,7
+1227,7
@@
Returns: the control block for the parsed rule.
*/
static rewrite_rule *
*/
static rewrite_rule *
-readconf_one_rewrite(uschar *p, int *existflags, BOOL isglobal)
+readconf_one_rewrite(
const
uschar *p, int *existflags, BOOL isglobal)
{
rewrite_rule *next = store_get(sizeof(rewrite_rule));
{
rewrite_rule *next = store_get(sizeof(rewrite_rule));
@@
-1333,10
+1333,10
@@
Returns: pointer to the string
*/
static uschar *
*/
static uschar *
-read_string(
uschar *s,
uschar *name)
+read_string(
const uschar *s, const
uschar *name)
{
uschar *yield;
{
uschar *yield;
-uschar *ss;
+
const
uschar *ss;
if (*s != '\"') return string_copy(s);
if (*s != '\"') return string_copy(s);
@@
-1359,8
+1359,6
@@
return yield;
static void
fn_smtp_receive_timeout(const uschar * name, const uschar * str)
{
static void
fn_smtp_receive_timeout(const uschar * name, const uschar * str)
{
-int value;
-
if (*str == '$')
smtp_receive_timeout_s = string_copy(str);
else
if (*str == '$')
smtp_receive_timeout_s = string_copy(str);
else
@@
-1599,7
+1597,7
@@
switch (type)
{
uschar sep_o = Ustrncmp(name, "headers_add", 11)==0 ? '\n' : ':';
int sep_i = -(int)sep_o;
{
uschar sep_o = Ustrncmp(name, "headers_add", 11)==0 ? '\n' : ':';
int sep_i = -(int)sep_o;
- uschar * list = sptr;
+
const
uschar * list = sptr;
uschar * s;
uschar * list_o = *str_target;
uschar * s;
uschar * list_o = *str_target;
@@
-1649,8
+1647,7
@@
switch (type)
flagptr = (int *)((uschar *)data_block + (long int)(ol3->value));
}
flagptr = (int *)((uschar *)data_block + (long int)(ol3->value));
}
- while ((p = string_nextinlist(&sptr, &sep, big_buffer, BIG_BUFFER_SIZE))
- != NULL)
+ while ((p = string_nextinlist(CUSS &sptr, &sep, big_buffer, BIG_BUFFER_SIZE)))
{
rewrite_rule *next = readconf_one_rewrite(p, flagptr, FALSE);
*chain = next;
{
rewrite_rule *next = readconf_one_rewrite(p, flagptr, FALSE);
*chain = next;
@@
-1774,8
+1771,8
@@
switch (type)
int count = 1;
uid_t *list;
int ptr = 0;
int count = 1;
uid_t *list;
int ptr = 0;
- uschar *p;
- uschar *op = expand_string (sptr);
+
const
uschar *p;
+
const
uschar *op = expand_string (sptr);
if (op == NULL)
log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "failed to expand %s: %s",
if (op == NULL)
log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "failed to expand %s: %s",
@@
-1815,8
+1812,8
@@
switch (type)
int count = 1;
gid_t *list;
int ptr = 0;
int count = 1;
gid_t *list;
int ptr = 0;
- uschar *p;
- uschar *op = expand_string (sptr);
+
const
uschar *p;
+
const
uschar *op = expand_string (sptr);
if (op == NULL)
log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "failed to expand %s: %s",
if (op == NULL)
log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "failed to expand %s: %s",
@@
-2966,7
+2963,7
@@
readconf_main(void)
int sep = 0;
struct stat statbuf;
uschar *s, *filename;
int sep = 0;
struct stat statbuf;
uschar *s, *filename;
-uschar *list = config_main_filelist;
+
const
uschar *list = config_main_filelist;
/* Loop through the possible file names */
/* Loop through the possible file names */
@@
-3138,7
+3135,7
@@
don't force the case. */
if (primary_hostname == NULL)
{
if (primary_hostname == NULL)
{
- uschar *hostname;
+
const
uschar *hostname;
struct utsname uts;
if (uname(&uts) < 0)
log_write(0, LOG_MAIN|LOG_PANIC_DIE, "uname() failed to yield host name");
struct utsname uts;
if (uname(&uts) < 0)
log_write(0, LOG_MAIN|LOG_PANIC_DIE, "uname() failed to yield host name");
@@
-3151,8
+3148,8
@@
if (primary_hostname == NULL)
#if HAVE_IPV6
if (!disable_ipv6 && (dns_ipv4_lookup == NULL ||
#if HAVE_IPV6
if (!disable_ipv6 && (dns_ipv4_lookup == NULL ||
- match_isinlist(hostname,
&dns_ipv4_lookup, 0, NULL, NULL, MCL_DOMAIN
,
- TRUE, NULL) != OK))
+ match_isinlist(hostname,
CUSS &dns_ipv4_lookup, 0, NULL, NULL
,
+
MCL_DOMAIN,
TRUE, NULL) != OK))
af = AF_INET6;
#else
af = AF_INET;
af = AF_INET6;
#else
af = AF_INET;
@@
-3212,7
+3209,7
@@
or %M. However, it must NOT contain % followed by anything else. */
if (*log_file_path != 0)
{
if (*log_file_path != 0)
{
- uschar *ss, *sss;
+
const
uschar *ss, *sss;
int sep = ':'; /* Fixed for log file path */
s = expand_string(log_file_path);
if (s == NULL)
int sep = ':'; /* Fixed for log file path */
s = expand_string(log_file_path);
if (s == NULL)
@@
-3699,10
+3696,11
@@
Returns: NULL if decoded correctly; else points to error text
*/
uschar *
*/
uschar *
-readconf_retry_error(uschar *pp, uschar *p, int *basic_errno, int *more_errno)
+readconf_retry_error(const uschar *pp, const uschar *p,
+ int *basic_errno, int *more_errno)
{
int len;
{
int len;
-uschar *q = pp;
+
const
uschar *q = pp;
while (q < p && *q != '_') q++;
len = q - pp;
while (q < p && *q != '_') q++;
len = q - pp;
@@
-3731,7
+3729,7
@@
else if (len == 7 && strncmpic(pp, US"timeout", len) == 0)
{
int i;
int xlen = p - q - 1;
{
int i;
int xlen = p - q - 1;
- uschar *x = q + 1;
+
const
uschar *x = q + 1;
static uschar *extras[] =
{ US"A", US"MX", US"connect", US"connect_A", US"connect_MX" };
static uschar *extras[] =
{ US"A", US"MX", US"connect", US"connect_A", US"connect_MX" };
@@
-3739,24
+3737,19
@@
else if (len == 7 && strncmpic(pp, US"timeout", len) == 0)
{ 'A', 'M', RTEF_CTOUT, RTEF_CTOUT|'A', RTEF_CTOUT|'M' };
for (i = 0; i < sizeof(extras)/sizeof(uschar *); i++)
{ 'A', 'M', RTEF_CTOUT, RTEF_CTOUT|'A', RTEF_CTOUT|'M' };
for (i = 0; i < sizeof(extras)/sizeof(uschar *); i++)
- {
if (strncmpic(x, extras[i], xlen) == 0)
{
*more_errno = values[i];
break;
}
if (strncmpic(x, extras[i], xlen) == 0)
{
*more_errno = values[i];
break;
}
- }
if (i >= sizeof(extras)/sizeof(uschar *))
if (i >= sizeof(extras)/sizeof(uschar *))
- {
if (strncmpic(x, US"DNS", xlen) == 0)
if (strncmpic(x, US"DNS", xlen) == 0)
- {
log_write(0, LOG_MAIN|LOG_PANIC, "\"timeout_dns\" is no longer "
"available in retry rules (it has never worked) - treated as "
"\"timeout\"");
log_write(0, LOG_MAIN|LOG_PANIC, "\"timeout_dns\" is no longer "
"available in retry rules (it has never worked) - treated as "
"\"timeout\"");
- }
- else return US"\"A\", \"MX\", or \"connect\" expected after \"timeout\"";
- }
+ else
+ return US"\"A\", \"MX\", or \"connect\" expected after \"timeout\"";
}
}
}
}
@@
-3783,8
+3776,8
@@
else if (strncmpic(pp, US"mail_4", 6) == 0 ||
return string_sprintf("%.4s_4 must be followed by xx, dx, or dd, where "
"x is literal and d is any digit", pp);
return string_sprintf("%.4s_4 must be followed by xx, dx, or dd, where "
"x is literal and d is any digit", pp);
- *basic_errno =
(*pp == 'm')
? ERRNO_MAIL4XX :
-
(*pp == 'r')
? ERRNO_RCPT4XX : ERRNO_DATA4XX;
+ *basic_errno =
*pp == 'm'
? ERRNO_MAIL4XX :
+
*pp == 'r'
? ERRNO_RCPT4XX : ERRNO_DATA4XX;
*more_errno = x << 8;
}
*more_errno = x << 8;
}
@@
-3798,6
+3791,9
@@
else if (strncmpic(pp, US"lost_connection", p - pp) == 0)
else if (strncmpic(pp, US"tls_required", p - pp) == 0)
*basic_errno = ERRNO_TLSREQUIRED;
else if (strncmpic(pp, US"tls_required", p - pp) == 0)
*basic_errno = ERRNO_TLSREQUIRED;
+else if (strncmpic(pp, US"lookup", p - pp) == 0)
+ *basic_errno = ERRNO_UNKNOWNHOST;
+
else if (len != 1 || Ustrncmp(pp, "*", 1) != 0)
return string_sprintf("unknown or malformed retry error \"%.*s\"", (int) (p-pp), pp);
else if (len != 1 || Ustrncmp(pp, "*", 1) != 0)
return string_sprintf("unknown or malformed retry error \"%.*s\"", (int) (p-pp), pp);
@@
-3835,10
+3831,10
@@
Returns: time in seconds or fixed point number * 1000
*/
static int
*/
static int
-retry_arg(uschar **paddr, int type)
+retry_arg(
const
uschar **paddr, int type)
{
{
-uschar *p = *paddr;
-uschar *pp;
+
const
uschar *p = *paddr;
+
const
uschar *pp;
if (*p++ != ',') log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "comma expected");
if (*p++ != ',') log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "comma expected");
@@
-3852,10
+3848,8
@@
if (*p != 0 && !isspace(*p) && *p != ',' && *p != ';')
*paddr = p;
switch (type)
{
*paddr = p;
switch (type)
{
- case 0:
- return readconf_readtime(pp, *p, FALSE);
- case 1:
- return readconf_readfixed(pp, *p);
+ case 0: return readconf_readtime(pp, *p, FALSE);
+ case 1: return readconf_readfixed(pp, *p);
}
return 0; /* Keep picky compilers happy */
}
}
return 0; /* Keep picky compilers happy */
}
@@
-3867,12
+3861,13
@@
readconf_retries(void)
{
retry_config **chain = &retries;
retry_config *next;
{
retry_config **chain = &retries;
retry_config *next;
-uschar *p;
+
const
uschar *p;
-while ((p = get_config_line())
!= NULL
)
+while ((p = get_config_line()))
{
retry_rule **rchain;
{
retry_rule **rchain;
- uschar *pp, *error;
+ const uschar *pp;
+ uschar *error;
next = store_get(sizeof(retry_config));
next->next = NULL;
next = store_get(sizeof(retry_config));
next->next = NULL;
@@
-3892,8
+3887,8
@@
while ((p = get_config_line()) != NULL)
/* Test error names for things we understand. */
/* Test error names for things we understand. */
- if ((error = readconf_retry_error(pp, p, &
(next->basic_errno)
,
- &
(next->more_errno))) != NULL
)
+ if ((error = readconf_retry_error(pp, p, &
next->basic_errno
,
+ &
next->more_errno))
)
log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "%s", error);
/* There may be an optional address list of senders to be used as another
log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "%s", error);
/* There may be an optional address list of senders to be used as another
@@
-3930,18
+3925,18
@@
while ((p = get_config_line()) != NULL)
switch (rule->rule)
{
case 'F': /* Fixed interval */
switch (rule->rule)
{
case 'F': /* Fixed interval */
- rule->p1 = retry_arg(&p, 0);
- break;
+
rule->p1 = retry_arg(&p, 0);
+
break;
case 'G': /* Geometrically increasing intervals */
case 'H': /* Ditto, but with randomness */
case 'G': /* Geometrically increasing intervals */
case 'H': /* Ditto, but with randomness */
- rule->p1 = retry_arg(&p, 0);
- rule->p2 = retry_arg(&p, 1);
- break;
+
rule->p1 = retry_arg(&p, 0);
+
rule->p2 = retry_arg(&p, 1);
+
break;
default:
default:
- log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "unknown retry rule letter");
- break;
+
log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "unknown retry rule letter");
+
break;
}
if (rule->timeout <= 0 || rule->p1 <= 0 ||
}
if (rule->timeout <= 0 || rule->p1 <= 0 ||