From dc8d3d50cbaca39447576ac0ac573ca8a84a2c05 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Sun, 22 Aug 2010 22:21:28 +0300 Subject: Fix starting of the default callout server. Reflect the actual server URL in callout_server_url. * mflib/callout.mf4 (callout_server_url): New variable. (begin): Provide a default for callout_server_url. (__callout_open_default): Return the fd. (callout): Use return from __callout_open_default as the first argument to callout_do. * mflib/poll.mf (__make_extra_arg): New static function. (_pollhost, _pollmx, stdpoll, strictpoll): Use return from __callout_open_default as the first argument to callout_do. Construct the rest of arguments using __make_extra_arg. * src/builtin/callout.bi (callout_server_url): Remove. (default_callout_server_url): New function. (MF_INIT): Remove initialization of callout_server_url. * src/mailfromd.h (default_callout_url): Rename to callout_server_url. * src/main.c (default_callout_url): Rename to callout_server_url. (provide_default_callout_server): Rewrite the condition. Don't try to reset the callout_server_url MFL variable: it is useless after compilation is finished. (mf_server_function): Fix the use of mu_list_locate. (main): Fix a typo in the server section label. * src/srvcfg.c (server_section_parser): Move the call to mf_server_function to the mu_cfg_section_end branch. --- src/builtin/callout.bi | 9 +++++++-- src/mailfromd.h | 2 +- src/main.c | 22 ++++++++-------------- src/srvcfg.c | 10 +++++----- 4 files changed, 21 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/builtin/callout.bi b/src/builtin/callout.bi index 9c8affeb..dd4a61ee 100644 --- a/src/builtin/callout.bi +++ b/src/builtin/callout.bi @@ -18,7 +18,6 @@ #include "filenames.h" #include "callout.h" -MF_VAR(callout_server_url, STRING, SYM_PRECIOUS); MF_VAR(ehlo_domain, STRING, SYM_PRECIOUS); MF_VAR(mailfrom_address, STRING, SYM_PRECIOUS); @@ -30,6 +29,13 @@ MF_PRAGMA(provide-callout, 1, 1) provide_callout = 1; } +MF_DEFUN(default_callout_server_url, STRING) +{ + MF_RETURN_STRING(callout_server_url ? + callout_server_url : DEFAULT_CALLOUT_SOCKET); +} +END + static void initvar(const char *name, const char *str) { @@ -41,7 +47,6 @@ initvar(const char *name, const char *str) } MF_INIT([< - initvar("callout_server_url", default_callout_url); if (ehlo_domain) initvar("ehlo_domain", ehlo_domain); if (mailfrom_address) diff --git a/src/mailfromd.h b/src/mailfromd.h index 6fcc628f..37aa1c83 100644 --- a/src/mailfromd.h +++ b/src/mailfromd.h @@ -139,7 +139,7 @@ extern int script_dump_macros; extern int script_dump_xref; extern int stack_trace_option; extern const char *program_version; -extern char *default_callout_url; +extern char *callout_server_url; extern size_t stack_size; extern size_t stack_max_size; diff --git a/src/main.c b/src/main.c index ccd31e69..1620fa2b 100644 --- a/src/main.c +++ b/src/main.c @@ -78,7 +78,7 @@ int stack_trace_option; /* Print stack traces on runtime errors */ size_t max_match_mx = MAXMXCOUNT; char *main_function_name = "main"; -char *default_callout_url = DEFAULT_CALLOUT_SOCKET; +char *callout_server_url; /* Preprocessor helper function */ @@ -894,9 +894,8 @@ struct mu_cfg_param mf_cfg_param[] = { { "milter-timeout", mu_cfg_callback, NULL, 0, cb_milter_timeout, N_("Set milter timeout."), N_("time") }, - { "callout-url", mu_cfg_string, &default_callout_url, 0, NULL, - N_("Sets the URL of the default callout server. " - "Deprecated. Use `setvar callout_server_url ;' instead."), + { "callout-url", mu_cfg_string, &callout_server_url, 0, NULL, + N_("Sets the URL of the default callout server."), N_("url") }, { "include-path", mu_cfg_callback, NULL, 0, cb_include_path, N_("Add directories to the list of directories to be searched for " @@ -1104,16 +1103,11 @@ provide_default_callout_server() struct variable *var; if (provide_callout && + !callout_server_url && (!(var = variable_lookup("callout_server_url")) || (var->sym.flags & SYM_REFERENCED) && !(var->sym.flags & SYM_INITIALIZED))) { - struct value val; - - val.type = dtype_string; - val.v.literal = string_alloc(DEFAULT_CALLOUT_SOCKET, - sizeof(DEFAULT_CALLOUT_SOCKET)-1); - ensure_initialized_variable("callout_server_url", &val); - mf_srvcfg_add("callout", val.v.literal->text); + mf_srvcfg_add("callout", DEFAULT_CALLOUT_SOCKET); } } @@ -1134,8 +1128,8 @@ mf_server_function(const char *key, struct mf_srvcfg *cfg) else if (strcmp(key, "callout") == 0) { cfg->server = callout_session_server; if (cfg->defopt || - mu_list_locate(cfg->options, "default", NULL)) - default_callout_url = + mu_list_locate(cfg->options, "default", NULL) == 0) + callout_server_url = xstrdup(mu_url_to_string(cfg->url)); } else return 1; @@ -1184,7 +1178,7 @@ main(int argc, char **argv) mu_acl_cfg_init(); database_cfg_init(); srvman_init(); - mf_srvcfg_init(N_("(milter | server)")); + mf_srvcfg_init(N_("(milter | callout)")); mu_argp_init(program_version, "<" PACKAGE_BUGREPORT ">"); mu_app_rcfile = DEFAULT_CONFIG_FILE; diff --git a/src/srvcfg.c b/src/srvcfg.c index 26f7fdd1..af444bfa 100644 --- a/src/srvcfg.c +++ b/src/srvcfg.c @@ -449,9 +449,12 @@ server_section_parser(enum mu_cfg_section_stage stage, case mu_cfg_section_start: memset(&server_config_stmt, 0, sizeof(server_config_stmt)); server_config_stmt.reuseaddr = 1; - if (mu_cfg_assert_value_type (node->label, MU_CFG_STRING, - tree->debug)) + if (mu_cfg_assert_value_type(node->label, MU_CFG_STRING, + tree->debug)) return 1; + break; + + case mu_cfg_section_end: if (server_config_stmt.options) mu_list_set_comparator(server_config_stmt.options, mf_list_compare_string); @@ -469,9 +472,6 @@ server_section_parser(enum mu_cfg_section_stage stage, __FILE__, __LINE__); return 1; } - break; - - case mu_cfg_section_end: if (!server_config_stmt.id) server_config_stmt.id = next_server_id(); if (server_config_stmt.url && server_config_stmt.server) { -- cgit v1.2.1