summaryrefslogtreecommitdiffabout
path: root/src/main.c
authorSergey Poznyakoff <gray@gnu.org.ua>2010-08-21 20:20:18 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2010-08-21 20:20:31 (GMT)
commit9b94887be08f9b32c720155693430e4ee575aad3 (patch) (side-by-side diff)
tree341cc08bc31cbc10183cf69ced6bfa486b445ea3 /src/main.c
parentf654375862adbc6882d2f4b189f86dbc225be78f (diff)
downloadmailfromd-9b94887be08f9b32c720155693430e4ee575aad3.tar.gz
mailfromd-9b94887be08f9b32c720155693430e4ee575aad3.tar.bz2
Restore some cfg statements for backward compatibility.
* src/srvcfg.h: Add copyleft header. (DEFAULT_PIDFILE): Move to lib/filenames.h. (mf_srvcfg): New struct. (mf_server_function): New proto. (parse_milter_url): New proto. * lib/filenames.h: Add copyleft header. (DEFAULT_PIDFILE): New define. * src/gram.y: Use mf_list_compare_string comparator. (initialize_variable): Avoid coredump if locus==NULL. * mailfromd.h (default_callout_url): New extern. (compare_string): Remove proto. * src/main.c (default_callout_url): New function. (compare_string): Remove function. All callers use mf_list_compare_string instead. (mf_cfg_param): Remove ehlo-domain and mail-from-address statements (duplicated in srvcfg.c) Restore the callout-url statement. (mf_server_function): Change signature. Check for "option default" for callout servers. (main): Move call to mf_srvcfg_flush several lines up, before processing the filter script. * src/srvcfg.c (parse_milter_url): Remove static qualifier. (mf_srvcfg_add, server_section_parser): Use the new calling scheme of mf_server_function. (server_config_stmt): Remove struct. (server_config_stmt):Change type struct mf_srvcfg. (server_section_param) <option>: New statement. <default>: Restore statement. * src/calloutd.c (mf_server_function): Change signature. * lib/libmf.h (mf_list_compare_string): New function. * lib/utils.c: Likewise. * mflib/callout.mf4 (ehlo_domain, mailfrom_address): Comment out. See callout.bi. (callout_open): Comment out sending the SET commands. * mflib/spf.mf: Remove dependency on phased-out mydomain.mf. (check_host): Revert to using ehlo_domain. * src/builtin/callout.bi (ehlo_domain, mailfrom_address): Define here (again). (MF_INIT): Initialize callout_server_url, ehlo_domain and mailfrom_address.
Diffstat (limited to 'src/main.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/main.c78
1 files changed, 17 insertions, 61 deletions
diff --git a/src/main.c b/src/main.c
index ba36fd9..ccd31e6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -78,6 +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;
/* Preprocessor helper function */
@@ -178,12 +179,6 @@ log_status(sfsistat status, SMFICTX *ctx)
static mu_list_t domain_list;
-int
-compare_string(const void *item, const void *value)
-{
- return strcmp(item, value);
-}
-
/* Read domains from sendmail-style domain file NAME and store them in
DOMAIN_LIST */
int
@@ -202,7 +197,7 @@ read_domain_file(mu_debug_t err, const char *name)
if (!domain_list) {
mu_list_create(&domain_list);
- mu_list_set_comparator(domain_list, compare_string);
+ mu_list_set_comparator(domain_list, mf_list_compare_string);
}
while (p = fgets(buf, sizeof buf, fp)) {
@@ -795,40 +790,6 @@ cb_set_variable(mu_debug_t err, void *data, mu_config_value_t *arg)
}
static int
-cb_ehlo_domain(mu_debug_t err, void *data, mu_config_value_t *arg)
-{
- if (mu_cfg_assert_value_type(arg, MU_CFG_STRING, err))
- return 1;
- defer_initialize_variable("ehlo_domain", arg->v.string);
- return 0;
-}
-
-static int
-mf_option_mailfrom(mu_debug_t err, const char *arg)
-{
- int rc;
- mu_address_t addr;
-
- rc = mu_address_create(&addr, arg);
- if (rc) {
- mf_error_on_locus(err, _("cannot create address `%s': %s"),
- arg, mu_strerror(rc));
- return 1;
- }
- mu_address_destroy(&addr);
- defer_initialize_variable("mailfrom_address", arg);
- return 0;
-}
-
-static int
-cb_mail_from_address(mu_debug_t err, void *data, mu_config_value_t *arg)
-{
- if (mu_cfg_assert_value_type(arg, MU_CFG_STRING, err))
- return 1;
- return mf_option_mailfrom(err, arg->v.string);
-}
-
-static int
cb_include_path(mu_debug_t err, void *data, mu_config_value_t *val)
{
int i, rc = 0;
@@ -933,21 +894,10 @@ struct mu_cfg_param mf_cfg_param[] = {
{ "milter-timeout", mu_cfg_callback, NULL, 0, cb_milter_timeout,
N_("Set milter timeout."),
N_("time") },
-#if 0
- /* FIXME */
- { "io-timeout", mu_cfg_callback, &io_timeout, 0, cb_timeout,
- N_("Timeout for all SMTP I/O operations."),
- N_("time") },
-#endif
-
- { "ehlo-domain", mu_cfg_callback, NULL, 0, cb_ehlo_domain,
- N_("Set the domain name for EHLO command.") },
- { "mail-from-address", mu_cfg_callback, NULL, 0, cb_mail_from_address,
- N_("Set email address for use in SMTP `MAIL FROM' command. "
- "Argument is an email address or a comma-separated list of "
- "addresses. Use <> for null address. Other addresses can "
- "be given without angle brackets."),
- N_("addr") },
+ { "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."),
+ N_("url") },
{ "include-path", mu_cfg_callback, NULL, 0, cb_include_path,
N_("Add directories to the list of directories to be searched for "
"header files. Argument is a list of directory names "
@@ -1177,12 +1127,18 @@ static char *modnames[] = {
int
-mf_server_function(const char *key, mfd_server_func_t *pret)
+mf_server_function(const char *key, struct mf_srvcfg *cfg)
{
if (!key || strcmp(key, "default") == 0 || strcmp(key, "milter") == 0)
- *pret = milter_session_server;
- else if (strcmp(key, "callout") == 0)
- *pret = callout_session_server;
+ cfg->server = milter_session_server;
+ else if (strcmp(key, "callout") == 0) {
+ cfg->server = callout_session_server;
+ if (cfg->defopt ||
+ mu_list_locate(cfg->options, "default", NULL))
+ default_callout_url =
+ xstrdup(mu_url_to_string(cfg->url));
+ } else
+ return 1;
return 0;
}
@@ -1238,6 +1194,7 @@ main(int argc, char **argv)
if (rc)
exit(EX_CONFIG);
flush_arguments(&args);
+ mf_srvcfg_flush();
alloc_ext_pp();
@@ -1282,7 +1239,6 @@ main(int argc, char **argv)
if (parse_program(script_file, script_ydebug))
exit(EX_CONFIG);
}
- mf_srvcfg_flush();
fixup_create_script();

Return to:

Send suggestions and report system problems to the System administrator.