summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/lka.c
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2009-05-20 16:07:27 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2009-05-20 16:07:27 +0000
commit997e558b09911ee188083c1d0c85aba8bada05d9 (patch)
tree866396359302b66bc173448ca4426153e2c0e245 /usr.sbin/smtpd/lka.c
parent1a4a31345f0ba791a2de3f5e7f0a11e528dc4243 (diff)
previous commit to add reload support was missing some code, this diffs
contains the missing parts + a memleak plug
Diffstat (limited to 'usr.sbin/smtpd/lka.c')
-rw-r--r--usr.sbin/smtpd/lka.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/usr.sbin/smtpd/lka.c b/usr.sbin/smtpd/lka.c
index 9e8b19952a6..2a622f6ad99 100644
--- a/usr.sbin/smtpd/lka.c
+++ b/usr.sbin/smtpd/lka.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lka.c,v 1.49 2009/05/20 14:36:55 gilles Exp $ */
+/* $OpenBSD: lka.c,v 1.50 2009/05/20 16:07:26 gilles Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -147,6 +147,7 @@ lka_dispatch_parent(int sig, short event, void *p)
fatal("mfa_dispatch_parent: calloc");
*rule = *(struct rule *)imsg.data;
+ TAILQ_INIT(&rule->r_conditions);
TAILQ_INSERT_TAIL(env->sc_rules_reload, rule, r_entry);
break;
}
@@ -174,13 +175,43 @@ lka_dispatch_parent(int sig, short event, void *p)
fatal("mfa_dispatch_parent: calloc");
*m = *(struct map *)imsg.data;
+ TAILQ_INIT(&m->m_contents);
TAILQ_INSERT_TAIL(env->sc_maps_reload, m, m_entry);
break;
}
+ case IMSG_CONF_RULE_SOURCE: {
+ struct rule *rule = TAILQ_LAST(env->sc_rules_reload, rulelist);
+ char *sourcemap = imsg.data;
+ void *temp = env->sc_maps;
+
+ /* map lookup must be done in the reloaded conf */
+ env->sc_maps = env->sc_maps_reload;
+ rule->r_sources = map_findbyname(env, sourcemap);
+ if (rule->r_sources == NULL)
+ fatalx("maps inconsistency");
+ env->sc_maps = temp;
+ break;
+ }
+ case IMSG_CONF_MAP_CONTENT: {
+ struct map *m = TAILQ_LAST(env->sc_maps_reload, maplist);
+ struct mapel *mapel = imsg.data;
+
+ IMSG_SIZE_CHECK(mapel);
+
+ mapel = calloc(1, sizeof(*mapel));
+ if (mapel == NULL)
+ fatal("mfa_dispatch_parent: calloc");
+ *mapel = *(struct mapel *)imsg.data;
+
+ TAILQ_INSERT_TAIL(&m->m_contents, mapel, me_entry);
+ break;
+ }
case IMSG_CONF_END: {
void *temp;
struct rule *r;
+ struct cond *cond;
struct map *m;
+ struct mapel *mapel;
/* switch and destroy old ruleset */
temp = env->sc_rules;
@@ -194,6 +225,10 @@ lka_dispatch_parent(int sig, short event, void *p)
if (env->sc_rules_reload) {
while ((r = TAILQ_FIRST(env->sc_rules_reload))) {
TAILQ_REMOVE(env->sc_rules_reload, r, r_entry);
+ while ((cond = TAILQ_FIRST(&r->r_conditions))) {
+ TAILQ_REMOVE(&r->r_conditions, cond, c_entry);
+ free(cond);
+ }
free(r);
}
free(env->sc_rules_reload);
@@ -203,6 +238,10 @@ lka_dispatch_parent(int sig, short event, void *p)
if (env->sc_maps_reload) {
while ((m = TAILQ_FIRST(env->sc_maps_reload))) {
TAILQ_REMOVE(env->sc_maps_reload, m, m_entry);
+ while ((mapel = TAILQ_FIRST(&m->m_contents))) {
+ TAILQ_REMOVE(&m->m_contents, mapel, me_entry);
+ free(mapel);
+ }
free(m);
}
free(env->sc_maps_reload);