summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--mflib/callout.mf413
-rw-r--r--mflib/poll.mf31
-rw-r--r--src/builtin/callout.bi9
-rw-r--r--src/mailfromd.h2
-rw-r--r--src/main.c22
-rw-r--r--src/srvcfg.c10
6 files changed, 55 insertions, 32 deletions
diff --git a/mflib/callout.mf4 b/mflib/callout.mf4
index ba19b1e..6dcf6df 100644
--- a/mflib/callout.mf4
+++ b/mflib/callout.mf4
@@ -138,5 +138,14 @@ done
#pragma provide-callout
+precious string callout_server_url
precious number __callout_fd -1
+begin
+do
+ if callout_server_url == ""
+ set callout_server_url default_callout_server_url()
+ fi
+done
+
func __callout_open_default()
+ returns number
do
@@ -145,2 +154,3 @@ do
fi
+ return __callout_fd
done
@@ -150,4 +160,3 @@ func callout(string email)
do
- __callout_open_default()
- return callout_do(__callout_fd, email)
+ return callout_do(__callout_open_default(), email)
done
diff --git a/mflib/poll.mf b/mflib/poll.mf
index d05a6f8..2ce6ad7 100644
--- a/mflib/poll.mf
+++ b/mflib/poll.mf
@@ -19,2 +19,14 @@ require 'callout'
+static func __make_extra_arg(string arg, string ehlo, string mailfrom)
+ returns string
+do
+ if ehlo != ""
+ set arg arg . " EHLO=%ehlo"
+ fi
+ if mailfrom != ""
+ set arg arg . " MAILFROM=%mailfrom"
+ fi
+ return arg
+done
+
func _pollhost(string ip, string email, string domain, string mailfrom)
@@ -22,4 +34,5 @@ func _pollhost(string ip, string email, string domain, string mailfrom)
do
- __callout_open_default()
- return callout_do(__callout_fd, email, "MODE=hostonly HOST=%ip EHLO=%domain MAILFROM=%mailfrom")
+ return callout_do(__callout_open_default(), email,
+ __make_extra_arg("MODE=hostonly HOST=%ip",
+ domain, mailfrom))
done
@@ -29,4 +42,5 @@ func _pollmx (string domain, string email, string ehlo, string mailfrom)
do
- __callout_open_default()
- return callout_do(__callout_fd, email, "MODE=mxonly HOST=%domain EHLO=%ehlo MAILFROM=%mailfrom")
+ return callout_do(__callout_open_default(), email,
+ __make_extra_arg("MODE=mxonly HOST=%domain",
+ ehlo, mailfrom))
done
@@ -36,4 +50,4 @@ func stdpoll(string email, string ehlo, string mailfrom)
do
- __callout_open_default()
- return callout_do(__callout_fd, email, "MODE=mxfirst EHLO=%ehlo MAILFROM=%mailfrom")
+ return callout_do(__callout_open_default(), email,
+ __make_extra_arg("MODE=mxfirst", ehlo, mailfrom))
done
@@ -43,4 +57,5 @@ func strictpoll(string host, string email, string ehlo, string mailfrom)
do
- __callout_open_default()
- return callout_do(__callout_fd, email, "MODE=hostfirst EHLO=%ehlo MAILFROM=%mailfrom")
+ return callout_do(__callout_open_default(), email,
+ __make_extra_arg("MODE=hostfirst HOST=%host",
+ ehlo, mailfrom))
done
diff --git a/src/builtin/callout.bi b/src/builtin/callout.bi
index 9c8affe..dd4a61e 100644
--- a/src/builtin/callout.bi
+++ b/src/builtin/callout.bi
@@ -20,3 +20,2 @@
-MF_VAR(callout_server_url, STRING, SYM_PRECIOUS);
MF_VAR(ehlo_domain, STRING, SYM_PRECIOUS);
@@ -32,2 +31,9 @@ MF_PRAGMA(provide-callout, 1, 1)
+MF_DEFUN(default_callout_server_url, STRING)
+{
+ MF_RETURN_STRING(callout_server_url ?
+ callout_server_url : DEFAULT_CALLOUT_SOCKET);
+}
+END
+
static void
@@ -43,3 +49,2 @@ initvar(const char *name, const char *str)
MF_INIT([<
- initvar("callout_server_url", default_callout_url);
if (ehlo_domain)
diff --git a/src/mailfromd.h b/src/mailfromd.h
index 6fcc628..37aa1c8 100644
--- a/src/mailfromd.h
+++ b/src/mailfromd.h
@@ -141,3 +141,3 @@ extern int stack_trace_option;
extern const char *program_version;
-extern char *default_callout_url;
+extern char *callout_server_url;
diff --git a/src/main.c b/src/main.c
index ccd31e6..1620fa2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -80,3 +80,3 @@ size_t max_match_mx = MAXMXCOUNT;
char *main_function_name = "main";
-char *default_callout_url = DEFAULT_CALLOUT_SOCKET;
+char *callout_server_url;
@@ -896,5 +896,4 @@ struct mu_cfg_param mf_cfg_param[] = {
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 <url>;' instead."),
+ { "callout-url", mu_cfg_string, &callout_server_url, 0, NULL,
+ N_("Sets the URL of the default callout server."),
N_("url") },
@@ -1106,2 +1105,3 @@ provide_default_callout_server()
if (provide_callout &&
+ !callout_server_url &&
(!(var = variable_lookup("callout_server_url")) ||
@@ -1109,9 +1109,3 @@ provide_default_callout_server()
!(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);
}
@@ -1136,4 +1130,4 @@ mf_server_function(const char *key, struct mf_srvcfg *cfg)
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));
@@ -1186,3 +1180,3 @@ main(int argc, char **argv)
srvman_init();
- mf_srvcfg_init(N_("(milter | server)"));
+ mf_srvcfg_init(N_("(milter | callout)"));
diff --git a/src/srvcfg.c b/src/srvcfg.c
index 26f7fdd..af444bf 100644
--- a/src/srvcfg.c
+++ b/src/srvcfg.c
@@ -451,5 +451,8 @@ server_section_parser(enum mu_cfg_section_stage stage,
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)
@@ -471,5 +474,2 @@ server_section_parser(enum mu_cfg_section_stage stage,
}
- break;
-
- case mu_cfg_section_end:
if (!server_config_stmt.id)

Return to:

Send suggestions and report system problems to the System administrator.