X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/2e84957ddc081264db2d49aac47504695cb4be6a..685bbd33eed692f3da8a92241b4cdce95d1792ab:/src/src/readconf.c diff --git a/src/src/readconf.c b/src/src/readconf.c index a18cb8bbb..907ffeb71 100644 --- a/src/src/readconf.c +++ b/src/src/readconf.c @@ -3,7 +3,7 @@ *************************************************/ /* Copyright (c) University of Cambridge 1995 - 2018 */ -/* Copyright (c) The Exim Maintainers 2020 */ +/* Copyright (c) The Exim Maintainers 2020 - 2021 */ /* See the file NOTICE for conditions of use and distribution. */ /* Functions for reading the configuration file, and for displaying @@ -183,6 +183,9 @@ static optionlist optionlist_config[] = { { "hosts_connection_nolog", opt_stringptr, {&hosts_connection_nolog} }, #ifdef SUPPORT_PROXY { "hosts_proxy", opt_stringptr, {&hosts_proxy} }, +#endif +#ifndef DISABLE_TLS + { "hosts_require_alpn", opt_stringptr, {&hosts_require_alpn} }, #endif { "hosts_require_helo", opt_stringptr, {&hosts_require_helo} }, { "hosts_treat_as_local", opt_stringptr, {&hosts_treat_as_local} }, @@ -378,6 +381,7 @@ static optionlist optionlist_config[] = { { "timezone", opt_stringptr, {&timezone_string} }, { "tls_advertise_hosts", opt_stringptr, {&tls_advertise_hosts} }, #ifndef DISABLE_TLS + { "tls_alpn", opt_stringptr, {&tls_alpn} }, { "tls_certificate", opt_stringptr, {&tls_certificate} }, { "tls_crl", opt_stringptr, {&tls_crl} }, { "tls_dh_max_bits", opt_int, {&tls_dh_max_bits} }, @@ -3011,12 +3015,7 @@ read_named_list(tree_node **anchorp, int *numberp, int max, uschar *s, BOOL forcecache = FALSE; uschar *ss; tree_node *t; -int old_pool = store_pool; -namedlist_block * nb; - -store_pool = POOL_PERM; -nb = store_get(sizeof(namedlist_block), FALSE); -store_pool = old_pool; +namedlist_block * nb = store_get_perm(sizeof(namedlist_block), FALSE); if (Ustrncmp(s, "_cache", 6) == 0) { @@ -3662,7 +3661,7 @@ for (driver_info * dd = drivers_available; dd->driver_name[0] != 0; { int len = dd->options_len; d->info = dd; - d->options_block = store_get(len, FALSE); + d->options_block = store_get_perm(len, FALSE); memcpy(d->options_block, dd->options_block, len); for (int i = 0; i < *(dd->options_count); i++) dd->options[i].type &= ~opt_set; @@ -3678,6 +3677,16 @@ return NULL; /* never obeyed */ +static void +driver_init_fini(driver_instance * d, const uschar * class) +{ +if (!d->driver_name) + log_write(0, LOG_PANIC_DIE|LOG_CONFIG, + "no driver defined for %s \"%s\"", class, d->name); +(d->info->init)(d); +} + + /************************************************* * Initialize driver list * *************************************************/ @@ -3738,11 +3747,8 @@ while ((buffer = get_config_line())) { if (d) { - if (!d->driver_name) - log_write(0, LOG_PANIC_DIE|LOG_CONFIG, - "no driver defined for %s \"%s\"", class, d->name); /* s is using big_buffer, so this call had better not */ - (d->info->init)(d); + driver_init_fini(d, class); d = NULL; } if (!macro_read_assignment(buffer)) exim_exit(EXIT_FAILURE); @@ -3758,12 +3764,7 @@ while ((buffer = get_config_line())) /* Finish off initializing the previous driver. */ if (d) - { - if (!d->driver_name) - log_write(0, LOG_PANIC_DIE|LOG_CONFIG, - "no driver defined for %s \"%s\"", class, d->name); - (d->info->init)(d); - } + driver_init_fini(d, class); /* Check that we haven't already got a driver of this name */ @@ -3775,12 +3776,7 @@ while ((buffer = get_config_line())) /* Set up a new driver instance data block on the chain, with its default values installed. */ - { - int old_pool = store_pool; - if (Ustrncmp(class, "router", 7) == 0) store_pool = POOL_PERM; - d = store_get(instance_size, FALSE); - store_pool = old_pool; - } + d = store_get_perm(instance_size, FALSE); memcpy(d, instance_default, instance_size); *p = d; p = &d->next; @@ -3832,12 +3828,7 @@ while ((buffer = get_config_line())) /* Run the initialization function for the final driver. */ if (d) - { - if (!d->driver_name) - log_write(0, LOG_PANIC_DIE|LOG_CONFIG, - "no driver defined for %s \"%s\"", class, d->name); - (d->info->init)(d); - } + driver_init_fini(d, class); } @@ -4199,11 +4190,12 @@ for (auth_instance * au = auths; au; au = au->next) for (auth_instance * bu = au->next; bu; bu = bu->next) if (strcmpic(au->public_name, bu->public_name) == 0) - if ((au->client && bu->client) || (au->server && bu->server)) + if ( au->client && bu->client + || au->server && bu->server) log_write(0, LOG_PANIC_DIE|LOG_CONFIG, "two %s authenticators " "(%s and %s) have the same public name (%s)", - au->client ? US"client" : US"server", au->name, bu->name, - au->public_name); + au->client && bu->client ? US"client" : US"server", + au->name, bu->name, au->public_name); #ifndef DISABLE_PIPE_CONNECT nauths++; #endif @@ -4270,7 +4262,7 @@ while(acl_line) if (*p != ':' || name[0] == 0) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "missing or malformed ACL name"); - node = store_get(sizeof(tree_node) + Ustrlen(name), is_tainted(name)); + node = store_get_perm(sizeof(tree_node) + Ustrlen(name), is_tainted(name)); Ustrcpy(node->name, name); if (!tree_insertnode(&acl_anchor, node)) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, @@ -4432,25 +4424,28 @@ print_config(BOOL admin, BOOL terse) { const int TS = terse ? 0 : 2; int indent = 0; +rmark r = NULL; -for (config_line_item * i = config_lines; i; i = i->next) +for (const config_line_item * i = config_lines; i; i = i->next) { - uschar *current; - uschar *p; + uschar * current, * p; + + if (r) store_reset(r); + r = store_mark(); /* skip over to the first non-space */ - for (current = i->line; *current && isspace(*current); ++current) + for (current = string_copy(i->line); *current && isspace(*current); ++current) ; - if (*current == '\0') + if (!*current) continue; /* Collapse runs of spaces. We stop this if we encounter one of the - * following characters: "'$, as this may indicate careful formatting */ - for (p = current; *p; ++p) + following characters: "'$, as this may indicate careful formatting */ + + for (p = current; *p; p++) if (isspace(*p)) { uschar *next; - if (!isspace(*p)) continue; if (*p != ' ') *p = ' '; for (next = p; isspace(*next); ++next) @@ -4504,6 +4499,7 @@ for (config_line_item * i = config_lines; i; i = i->next) /* rest is public */ printf("%*s%s\n", indent, "", current); } +if (r) store_reset(r); } #endif /*!MACRO_PREDEF*/