diff options
Diffstat (limited to 'usr.sbin/smtpd/smtpd.c')
-rw-r--r-- | usr.sbin/smtpd/smtpd.c | 55 |
1 files changed, 41 insertions, 14 deletions
diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c index 2ed5eaa0549..0a701fa6f7b 100644 --- a/usr.sbin/smtpd/smtpd.c +++ b/usr.sbin/smtpd/smtpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.c,v 1.62 2009/05/20 14:29:44 gilles Exp $ */ +/* $OpenBSD: smtpd.c,v 1.63 2009/05/20 16:07:26 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -176,25 +176,32 @@ parent_send_config_ruleset(struct smtpd *env, int proc) struct rule *r; struct cond *cond; struct map *m; - + struct mapel *mapel; + log_debug("parent_send_config_ruleset: reloading rules and maps"); imsg_compose(env->sc_ibufs[proc], IMSG_CONF_START, 0, 0, -1, NULL, 0); - + + TAILQ_FOREACH(m, env->sc_maps, m_entry) { + imsg_compose(env->sc_ibufs[proc], IMSG_CONF_MAP, + 0, 0, -1, m, sizeof(*m)); + TAILQ_FOREACH(mapel, &m->m_contents, me_entry) { + imsg_compose(env->sc_ibufs[proc], IMSG_CONF_MAP_CONTENT, + 0, 0, -1, mapel, sizeof(*mapel)); + } + } + TAILQ_FOREACH(r, env->sc_rules, r_entry) { imsg_compose(env->sc_ibufs[proc], IMSG_CONF_RULE, 0, 0, -1, r, sizeof(*r)); + imsg_compose(env->sc_ibufs[proc], IMSG_CONF_RULE_SOURCE, + 0, 0, -1, &r->r_sources->m_name, sizeof(r->r_sources->m_name)); TAILQ_FOREACH(cond, &r->r_conditions, c_entry) { imsg_compose(env->sc_ibufs[proc], IMSG_CONF_CONDITION, 0, 0, -1, cond, sizeof(*cond)); } } - - TAILQ_FOREACH(m, env->sc_maps, m_entry) { - imsg_compose(env->sc_ibufs[proc], IMSG_CONF_MAP, - 0, 0, -1, m, sizeof(*m)); - } - + imsg_compose(env->sc_ibufs[proc], IMSG_CONF_END, 0, 0, -1, NULL, 0); } @@ -633,11 +640,27 @@ parent_dispatch_control(int sig, short event, void *p) switch (imsg.hdr.type) { case IMSG_CONF_RELOAD: { - parent_send_config_ruleset(env, PROC_MFA); - parent_send_config_ruleset(env, PROC_LKA); - imsg_compose(env->sc_ibufs[PROC_SMTP], - IMSG_CONF_RELOAD, 0, 0, -1, NULL, 0); - imsg_compose(ibuf, IMSG_CONF_RELOAD, 0, 0, -1, NULL, 0); + struct reload *r = imsg.data; + struct smtpd newenv; + + r->ret = 0; + if (parse_config(&newenv, env->sc_config, 0) == 0) { + + (void)strlcpy(env->sc_hostname, newenv.sc_hostname, + sizeof(env->sc_hostname)); + env->sc_listeners = newenv.sc_listeners; + env->sc_maps = newenv.sc_maps; + env->sc_rules = newenv.sc_rules; + env->sc_rules = newenv.sc_rules; + env->sc_ssl = newenv.sc_ssl; + + parent_send_config_ruleset(env, PROC_MFA); + parent_send_config_ruleset(env, PROC_LKA); + imsg_compose(env->sc_ibufs[PROC_SMTP], + IMSG_CONF_RELOAD, 0, 0, -1, NULL, 0); + r->ret = 1; + } + imsg_compose(ibuf, IMSG_CONF_RELOAD, 0, 0, -1, r, sizeof(*r)); break; } case IMSG_STATS: { @@ -812,6 +835,10 @@ main(int argc, char *argv[]) if (parse_config(&env, conffile, opts)) exit(1); + if (strlcpy(env.sc_config, conffile, MAXPATHLEN) >= MAXPATHLEN) + errx(1, "config file exceeds MAXPATHLEN"); + + if (env.sc_opts & SMTPD_OPT_NOACTION) { fprintf(stderr, "configuration OK\n"); exit(0); |