diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-08-22 22:21:28 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-08-22 23:11:41 +0300 |
commit | dc8d3d50cbaca39447576ac0ac573ca8a84a2c05 (patch) | |
tree | d9a4f88f0fb0019a740d334d67a7215d66c0c8aa /src | |
parent | 84db5d2111b2f8ac9fd583ed13c106b620b8fefa (diff) | |
download | mailfromd-dc8d3d50cbaca39447576ac0ac573ca8a84a2c05.tar.gz mailfromd-dc8d3d50cbaca39447576ac0ac573ca8a84a2c05.tar.bz2 |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/builtin/callout.bi | 9 | ||||
-rw-r--r-- | src/mailfromd.h | 2 | ||||
-rw-r--r-- | src/main.c | 22 | ||||
-rw-r--r-- | src/srvcfg.c | 10 |
4 files changed, 21 insertions, 22 deletions
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 @@ | |||
18 | #include "filenames.h" | 18 | #include "filenames.h" |
19 | #include "callout.h" | 19 | #include "callout.h" |
20 | 20 | ||
21 | MF_VAR(callout_server_url, STRING, SYM_PRECIOUS); | ||
22 | MF_VAR(ehlo_domain, STRING, SYM_PRECIOUS); | 21 | MF_VAR(ehlo_domain, STRING, SYM_PRECIOUS); |
23 | MF_VAR(mailfrom_address, STRING, SYM_PRECIOUS); | 22 | MF_VAR(mailfrom_address, STRING, SYM_PRECIOUS); |
24 | 23 | ||
@@ -30,6 +29,13 @@ MF_PRAGMA(provide-callout, 1, 1) | |||
30 | provide_callout = 1; | 29 | provide_callout = 1; |
31 | } | 30 | } |
32 | 31 | ||
32 | MF_DEFUN(default_callout_server_url, STRING) | ||
33 | { | ||
34 | MF_RETURN_STRING(callout_server_url ? | ||
35 | callout_server_url : DEFAULT_CALLOUT_SOCKET); | ||
36 | } | ||
37 | END | ||
38 | |||
33 | static void | 39 | static void |
34 | initvar(const char *name, const char *str) | 40 | initvar(const char *name, const char *str) |
35 | { | 41 | { |
@@ -41,7 +47,6 @@ initvar(const char *name, const char *str) | |||
41 | } | 47 | } |
42 | 48 | ||
43 | MF_INIT([< | 49 | MF_INIT([< |
44 | initvar("callout_server_url", default_callout_url); | ||
45 | if (ehlo_domain) | 50 | if (ehlo_domain) |
46 | initvar("ehlo_domain", ehlo_domain); | 51 | initvar("ehlo_domain", ehlo_domain); |
47 | if (mailfrom_address) | 52 | 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; | |||
139 | extern int script_dump_xref; | 139 | extern int script_dump_xref; |
140 | extern int stack_trace_option; | 140 | extern int stack_trace_option; |
141 | extern const char *program_version; | 141 | extern const char *program_version; |
142 | extern char *default_callout_url; | 142 | extern char *callout_server_url; |
143 | 143 | ||
144 | extern size_t stack_size; | 144 | extern size_t stack_size; |
145 | extern size_t stack_max_size; | 145 | extern size_t stack_max_size; |
@@ -78,7 +78,7 @@ int stack_trace_option; /* Print stack traces on runtime errors */ | |||
78 | size_t max_match_mx = MAXMXCOUNT; | 78 | size_t max_match_mx = MAXMXCOUNT; |
79 | 79 | ||
80 | char *main_function_name = "main"; | 80 | char *main_function_name = "main"; |
81 | char *default_callout_url = DEFAULT_CALLOUT_SOCKET; | 81 | char *callout_server_url; |
82 | 82 | ||
83 | 83 | ||
84 | /* Preprocessor helper function */ | 84 | /* Preprocessor helper function */ |
@@ -894,9 +894,8 @@ struct mu_cfg_param mf_cfg_param[] = { | |||
894 | { "milter-timeout", mu_cfg_callback, NULL, 0, cb_milter_timeout, | 894 | { "milter-timeout", mu_cfg_callback, NULL, 0, cb_milter_timeout, |
895 | N_("Set milter timeout."), | 895 | N_("Set milter timeout."), |
896 | N_("time") }, | 896 | N_("time") }, |
897 | { "callout-url", mu_cfg_string, &default_callout_url, 0, NULL, | 897 | { "callout-url", mu_cfg_string, &callout_server_url, 0, NULL, |
898 | N_("Sets the URL of the default callout server. " | 898 | N_("Sets the URL of the default callout server."), |
899 | "Deprecated. Use `setvar callout_server_url <url>;' instead."), | ||
900 | N_("url") }, | 899 | N_("url") }, |
901 | { "include-path", mu_cfg_callback, NULL, 0, cb_include_path, | 900 | { "include-path", mu_cfg_callback, NULL, 0, cb_include_path, |
902 | N_("Add directories to the list of directories to be searched for " | 901 | N_("Add directories to the list of directories to be searched for " |
@@ -1104,16 +1103,11 @@ provide_default_callout_server() | |||
1104 | struct variable *var; | 1103 | struct variable *var; |
1105 | 1104 | ||
1106 | if (provide_callout && | 1105 | if (provide_callout && |
1106 | !callout_server_url && | ||
1107 | (!(var = variable_lookup("callout_server_url")) || | 1107 | (!(var = variable_lookup("callout_server_url")) || |
1108 | (var->sym.flags & SYM_REFERENCED) && | 1108 | (var->sym.flags & SYM_REFERENCED) && |
1109 | !(var->sym.flags & SYM_INITIALIZED))) { | 1109 | !(var->sym.flags & SYM_INITIALIZED))) { |
1110 | struct value val; | 1110 | mf_srvcfg_add("callout", DEFAULT_CALLOUT_SOCKET); |
1111 | |||
1112 | val.type = dtype_string; | ||
1113 | val.v.literal = string_alloc(DEFAULT_CALLOUT_SOCKET, | ||
1114 | sizeof(DEFAULT_CALLOUT_SOCKET)-1); | ||
1115 | ensure_initialized_variable("callout_server_url", &val); | ||
1116 | mf_srvcfg_add("callout", val.v.literal->text); | ||
1117 | } | 1111 | } |
1118 | } | 1112 | } |
1119 | 1113 | ||
@@ -1134,8 +1128,8 @@ mf_server_function(const char *key, struct mf_srvcfg *cfg) | |||
1134 | else if (strcmp(key, "callout") == 0) { | 1128 | else if (strcmp(key, "callout") == 0) { |
1135 | cfg->server = callout_session_server; | 1129 | cfg->server = callout_session_server; |
1136 | if (cfg->defopt || | 1130 | if (cfg->defopt || |
1137 | mu_list_locate(cfg->options, "default", NULL)) | 1131 | mu_list_locate(cfg->options, "default", NULL) == 0) |
1138 | default_callout_url = | 1132 | callout_server_url = |
1139 | xstrdup(mu_url_to_string(cfg->url)); | 1133 | xstrdup(mu_url_to_string(cfg->url)); |
1140 | } else | 1134 | } else |
1141 | return 1; | 1135 | return 1; |
@@ -1184,7 +1178,7 @@ main(int argc, char **argv) | |||
1184 | mu_acl_cfg_init(); | 1178 | mu_acl_cfg_init(); |
1185 | database_cfg_init(); | 1179 | database_cfg_init(); |
1186 | srvman_init(); | 1180 | srvman_init(); |
1187 | mf_srvcfg_init(N_("(milter | server)")); | 1181 | mf_srvcfg_init(N_("(milter | callout)")); |
1188 | 1182 | ||
1189 | mu_argp_init(program_version, "<" PACKAGE_BUGREPORT ">"); | 1183 | mu_argp_init(program_version, "<" PACKAGE_BUGREPORT ">"); |
1190 | mu_app_rcfile = DEFAULT_CONFIG_FILE; | 1184 | 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, | |||
449 | case mu_cfg_section_start: | 449 | case mu_cfg_section_start: |
450 | memset(&server_config_stmt, 0, sizeof(server_config_stmt)); | 450 | memset(&server_config_stmt, 0, sizeof(server_config_stmt)); |
451 | server_config_stmt.reuseaddr = 1; | 451 | server_config_stmt.reuseaddr = 1; |
452 | if (mu_cfg_assert_value_type (node->label, MU_CFG_STRING, | 452 | if (mu_cfg_assert_value_type(node->label, MU_CFG_STRING, |
453 | tree->debug)) | 453 | tree->debug)) |
454 | return 1; | 454 | return 1; |
455 | break; | ||
456 | |||
457 | case mu_cfg_section_end: | ||
455 | if (server_config_stmt.options) | 458 | if (server_config_stmt.options) |
456 | mu_list_set_comparator(server_config_stmt.options, | 459 | mu_list_set_comparator(server_config_stmt.options, |
457 | mf_list_compare_string); | 460 | mf_list_compare_string); |
@@ -469,9 +472,6 @@ server_section_parser(enum mu_cfg_section_stage stage, | |||
469 | __FILE__, __LINE__); | 472 | __FILE__, __LINE__); |
470 | return 1; | 473 | return 1; |
471 | } | 474 | } |
472 | break; | ||
473 | |||
474 | case mu_cfg_section_end: | ||
475 | if (!server_config_stmt.id) | 475 | if (!server_config_stmt.id) |
476 | server_config_stmt.id = next_server_id(); | 476 | server_config_stmt.id = next_server_id(); |
477 | if (server_config_stmt.url && server_config_stmt.server) { | 477 | if (server_config_stmt.url && server_config_stmt.server) { |