X-Git-Url: https://vcs.fsf.org/?p=exim.git;a=blobdiff_plain;f=src%2Fsrc%2Freadconf.c;h=2dfc9af8ee8cbd4f93b7d53cedc581c2ac1f531f;hp=dfede671e6b73eae8baab6049e66b5899bbbd9e5;hb=38d85dd18239ac5951fae2c61dcf7c037c666f00;hpb=846430d945e9056842ad7f12f85d43435d78baf0 diff --git a/src/src/readconf.c b/src/src/readconf.c index dfede671e..2dfc9af8e 100644 --- a/src/src/readconf.c +++ b/src/src/readconf.c @@ -2,7 +2,7 @@ * Exim - an Internet mail transport agent * *************************************************/ -/* Copyright (c) University of Cambridge 1995 - 2014 */ +/* Copyright (c) University of Cambridge 1995 - 2015 */ /* See the file NOTICE for conditions of use and distribution. */ /* Functions for reading the configuration file, and for displaying @@ -12,7 +12,9 @@ implementation of the conditional .ifdef etc. */ #include "exim.h" static void fn_smtp_receive_timeout(const uschar * name, const uschar * str); - +static void save_config_line(const uschar* line); +static void save_config_position(const uschar *file, int line); +static void print_config(BOOL admin); #define CSTATE_STACK_SIZE 10 @@ -26,6 +28,15 @@ typedef struct config_file_item { int lineno; } config_file_item; +/* Structure for chain of configuration lines (-bP config) */ + +typedef struct config_line_item { + struct config_line_item *next; + uschar *line; +} config_line_item; + +static config_line_item* config_lines; + /* Structure of table of conditional words and their state transitions */ typedef struct cond_item { @@ -43,6 +54,8 @@ typedef struct syslog_fac_item { int value; } syslog_fac_item; +/* constants */ +static const char * const hidden = ""; /* Static variables */ @@ -181,6 +194,7 @@ static optionlist optionlist_config[] = { { "bounce_message_file", opt_stringptr, &bounce_message_file }, { "bounce_message_text", opt_stringptr, &bounce_message_text }, { "bounce_return_body", opt_bool, &bounce_return_body }, + { "bounce_return_linesize_limit", opt_mkint, &bounce_return_linesize_limit }, { "bounce_return_message", opt_bool, &bounce_return_message }, { "bounce_return_size_limit", opt_mkint, &bounce_return_size_limit }, { "bounce_sender_authentication",opt_stringptr,&bounce_sender_authentication }, @@ -228,6 +242,7 @@ static optionlist optionlist_config[] = { { "dns_ipv4_lookup", opt_stringptr, &dns_ipv4_lookup }, { "dns_retrans", opt_time, &dns_retrans }, { "dns_retry", opt_int, &dns_retry }, + { "dns_trust_aa", opt_stringptr, &dns_trust_aa }, { "dns_use_edns0", opt_int, &dns_use_edns0 }, /* This option is now a no-op, retained for compability */ { "drop_cr", opt_bool, &drop_cr }, @@ -237,7 +252,7 @@ static optionlist optionlist_config[] = { { "envelope_to_remove", opt_bool, &envelope_to_remove }, { "errors_copy", opt_stringptr, &errors_copy }, { "errors_reply_to", opt_stringptr, &errors_reply_to }, -#ifdef EXPERIMENTAL_EVENT +#ifndef DISABLE_EVENT { "event_action", opt_stringptr, &event_action }, #endif { "exim_group", opt_gid, &exim_gid }, @@ -271,6 +286,9 @@ static optionlist optionlist_config[] = { { "host_lookup_order", opt_stringptr, &host_lookup_order }, { "host_reject_connection", opt_stringptr, &host_reject_connection }, { "hosts_connection_nolog", opt_stringptr, &hosts_connection_nolog }, +#ifdef SUPPORT_PROXY + { "hosts_proxy", opt_stringptr, &hosts_proxy }, +#endif { "hosts_treat_as_local", opt_stringptr, &hosts_treat_as_local }, #ifdef LOOKUP_IBASE { "ibase_servers", opt_stringptr, &ibase_servers }, @@ -326,6 +344,7 @@ static optionlist optionlist_config[] = { #ifdef EXIM_PERL { "perl_at_start", opt_bool, &opt_perl_at_start }, { "perl_startup", opt_stringptr, &opt_perl_startup }, + { "perl_taintmode", opt_bool, &opt_perl_taintmode }, #endif #ifdef LOOKUP_PGSQL { "pgsql_servers", opt_stringptr, &pgsql_servers }, @@ -340,9 +359,6 @@ static optionlist optionlist_config[] = { { "print_topbitchars", opt_bool, &print_topbitchars }, { "process_log_path", opt_stringptr, &process_log_path }, { "prod_requires_admin", opt_bool, &prod_requires_admin }, -#ifdef EXPERIMENTAL_PROXY - { "proxy_required_hosts", opt_stringptr, &proxy_required_hosts }, -#endif { "qualify_domain", opt_stringptr, &qualify_domain_sender }, { "qualify_recipient", opt_stringptr, &qualify_domain_recipient }, { "queue_domains", opt_stringptr, &queue_domains }, @@ -361,7 +377,7 @@ static optionlist optionlist_config[] = { { "recipient_unqualified_hosts", opt_stringptr, &recipient_unqualified_hosts }, { "recipients_max", opt_int, &recipients_max }, { "recipients_max_reject", opt_bool, &recipients_max_reject }, -#ifdef EXPERIMENTAL_REDIS +#ifdef LOOKUP_REDIS { "redis_servers", opt_stringptr, &redis_servers }, #endif { "remote_max_parallel", opt_int, &remote_max_parallel }, @@ -399,7 +415,7 @@ static optionlist optionlist_config[] = { { "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 EXPERIMENTAL_INTERNATIONAL +#ifdef SUPPORT_I18N { "smtputf8_advertise_hosts", opt_stringptr, &smtputf8_advertise_hosts }, #endif #ifdef WITH_CONTENT_SCAN @@ -442,12 +458,13 @@ static optionlist optionlist_config[] = { #endif { "timeout_frozen_after", opt_time, &timeout_frozen_after }, { "timezone", opt_stringptr, &timezone_string }, -#ifdef SUPPORT_TLS { "tls_advertise_hosts", opt_stringptr, &tls_advertise_hosts }, +#ifdef SUPPORT_TLS { "tls_certificate", opt_stringptr, &tls_certificate }, { "tls_crl", opt_stringptr, &tls_crl }, { "tls_dh_max_bits", opt_int, &tls_dh_max_bits }, { "tls_dhparam", opt_stringptr, &tls_dhparam }, + { "tls_eccurve", opt_stringptr, &tls_eccurve }, # ifndef DISABLE_OCSP { "tls_ocsp_file", opt_stringptr, &tls_ocsp_file }, # endif @@ -695,6 +712,8 @@ for (;;) config_filename = config_file_stack->filename; config_lineno = config_file_stack->lineno; config_file_stack = config_file_stack->next; + if (config_lines) + save_config_position(config_filename, config_lineno); continue; } @@ -712,6 +731,9 @@ for (;;) config_lineno++; newlen = len + Ustrlen(big_buffer + len); + if (config_lines && config_lineno == 1) + save_config_position(config_filename, config_lineno); + /* Handle pathologically long physical lines - yes, it did happen - by extending big_buffer at this point. The code also copes with very long logical lines. */ @@ -900,6 +922,8 @@ for (;;) if (include_if_exists != 0 && (Ustat(ss, &statbuf) != 0)) continue; + if (config_lines) + save_config_position(config_filename, config_lineno); save = store_get(sizeof(config_file_item)); save->next = config_file_stack; config_file_stack = save; @@ -956,6 +980,10 @@ next_section, truncate it. It will be unrecognized later, because all the known section names do fit. Leave space for pluralizing. */ s = big_buffer + startoffset; /* First non-space character */ + +if (config_lines) + save_config_line(s); + if (strncmpic(s, US"begin ", 6) == 0) { s += 6; @@ -2244,7 +2272,6 @@ if (ol == NULL) if (!admin_user && (ol->type & opt_secure) != 0) { - const char * const hidden = ""; if (no_labels) printf("%s\n", hidden); else @@ -2509,7 +2536,9 @@ causes the value of any main configuration variable to be output if the second argument is NULL. There are some special values: all print all main configuration options - configure_file print the name of the configuration file + config_file print the name of the configuration file + (configure_file will still work, for backward + compatibility) routers print the routers' configurations transports print the transports' configuration authenticators print the authenticators' configuration @@ -2520,6 +2549,7 @@ second argument is NULL. There are some special values: macro_list print a list of macro names +name print a named list item local_scan print the local_scan options + config print the configuration as it is parsed If the second argument is not NULL, it must be one of "router", "transport", "authenticator" or "macro" in which case the first argument identifies the @@ -2576,7 +2606,8 @@ if (type == NULL) return; } - if (Ustrcmp(name, "configure_file") == 0) + if ( Ustrcmp(name, "configure_file") == 0 + ||Ustrcmp(name, "config_file") == 0) { printf("%s\n", CS config_main_filename); return; @@ -2610,6 +2641,12 @@ if (type == NULL) return; } + if (Ustrcmp(name, "config") == 0) + { + print_config(admin_user); + return; + } + if (Ustrcmp(name, "routers") == 0) { type = US"router"; @@ -2893,6 +2930,18 @@ pid_t pid; int rc, status; void (*oldsignal)(int); +/* If TLS will never be used, no point checking ciphers */ + +if ( !tls_advertise_hosts + || !*tls_advertise_hosts + || Ustrcmp(tls_advertise_hosts, ":") == 0 + ) + return TRUE; +else if (!tls_certificate) + log_write(0, LOG_MAIN|LOG_PANIC, + "Warning: No server certificate defined; TLS connections will fail.\n" + " Suggested action: either install a certificate or change tls_advertise_hosts option"); + oldsignal = signal(SIGCHLD, SIG_DFL); fflush(NULL); @@ -3038,7 +3087,7 @@ if (config_file != NULL) config_filename = config_main_filename = string_copy(filename); p = Ustrrchr(filename, '/'); - config_main_directory = p ? string_copyn(filename, p - filename) + config_main_directory = p ? string_copyn(filename, p - filename) : string_copy(US"."); } else @@ -4183,6 +4232,121 @@ while(next_section[0] != 0) (void)fclose(config_file); } +/* Init the storage for the pre-parsed config lines */ +void +readconf_save_config(const uschar *s) +{ + save_config_line(string_sprintf("# Exim Configuration (%s)", + running_in_test_harness ? US"X" : s)); +} + +static void +save_config_position(const uschar *file, int line) +{ + save_config_line(string_sprintf("# %d \"%s\"", line, file)); +} + +/* Append a pre-parsed logical line to the config lines store, +this operates on a global (static) list that holds all the pre-parsed +config lines, we do no further processing here, output formatting and +honouring of or macros will be done during output */ +static void +save_config_line(const uschar* line) +{ +static config_line_item *current; +config_line_item *next; + +next = (config_line_item*) store_get(sizeof(config_line_item)); +next->line = string_copy(line); +next->next = NULL; + +if (!config_lines) config_lines = next; +else current->next = next; + +current = next; +} + +/* List the parsed config lines, care about nice formatting and +hide the values unless we're the admin user */ +void +print_config(BOOL admin) +{ +config_line_item *i; +const int TS = 2; +int indent = 0; + +for (i = config_lines; i; i = i->next) + { + uschar *current; + uschar *p; + + /* skip over to the first non-space */ + for (current = i->line; *current && isspace(*current); ++current) + ; + + if (*current == '\0') + 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) + { + uschar *next; + if (!isspace(*p)) continue; + if (*p != ' ') *p = ' '; + + for (next = p; isspace(*next); ++next) + ; + + if (next - p > 1) + memmove(p+1, next, Ustrlen(next)+1); + + if (*next == '"' || *next == '\'' || *next == '$') + break; + } + + /* # lines */ + if (current[0] == '#') + puts(CCS current); + + /* begin lines are left aligned */ + else if (Ustrncmp(current, "begin", 5) == 0 && isspace(current[5])) + { + puts(""); + puts(CCS current); + indent = TS; + } + + /* router/acl/transport block names */ + else if (current[Ustrlen(current)-1] == ':' && !Ustrchr(current, '=')) + { + printf("\n%*s%s\n", TS, "", current); + indent = 2 * TS; + } + + /* hidden lines (all MACROS or lines prefixed with "hide") */ + else if ( !admin + && ( isupper(*current) + || Ustrncmp(current, "hide", 4) == 0 && isspace(current[4]) + ) + ) + { + if ((p = Ustrchr(current, '='))) + { + *p = '\0'; + printf("%*s%s= %s\n", indent, "", current, hidden); + } + /* e.g.: hide split_spool_directory */ + else + printf("%*s\n", indent, hidden); + } + + else + /* rest is public */ + printf("%*s%s\n", indent, "", current); + } +} + /* vi: aw ai sw=2 */ /* End of readconf.c */