summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2009-11-10 00:13:34 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2009-11-10 00:13:34 +0000
commit76c185eb6eafe7431ede912549c83da910e762ae (patch)
tree9dbb08c811aa43bbe5620f76daa2d9fbea06eca7 /usr.sbin/smtpd
parent9176eaf73c980dc840e80b461363bb98d81741c2 (diff)
introduce lka_session_fail() which factors a small piece of code used in
three places: set code to 530, send imsg to notify rejection, kill lkasession
Diffstat (limited to 'usr.sbin/smtpd')
-rw-r--r--usr.sbin/smtpd/lka.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/usr.sbin/smtpd/lka.c b/usr.sbin/smtpd/lka.c
index 6ca8521ee80..4de2db8847d 100644
--- a/usr.sbin/smtpd/lka.c
+++ b/usr.sbin/smtpd/lka.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lka.c,v 1.85 2009/11/09 23:49:34 gilles Exp $ */
+/* $OpenBSD: lka.c,v 1.86 2009/11/10 00:13:33 gilles Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -66,6 +66,7 @@ size_t lka_expand(char *, size_t, struct path *);
void lka_rcpt_action(struct smtpd *, char *, struct path *);
void lka_session_destroy(struct smtpd *, struct lkasession *);
void lka_expansion_done(struct smtpd *, struct lkasession *);
+void lka_session_fail(struct smtpd *, struct lkasession *, struct submit_status *);
void
lka_sig_handler(int sig, short event, void *p)
@@ -351,10 +352,7 @@ lka_dispatch_mfa(int sig, short event, void *p)
lkasession = lka_session_init(env, ss);
if (! lka_resolve_path(env, lkasession, path)) {
- ss->code = 530;
- imsg_compose_event(iev, IMSG_LKA_RCPT, 0, 0, -1,
- ss, sizeof(*ss));
- lka_session_destroy(env, lkasession);
+ lka_session_fail(env, lkasession, ss);
break;
}
@@ -371,10 +369,7 @@ lka_dispatch_mfa(int sig, short event, void *p)
if (path->flags & F_PATH_ALIAS) {
if (! aliases_get(env, ss->u.path.rule.r_amap,
&lkasession->expandtree, ss->u.path.user)) {
- ss->code = 530;
- imsg_compose_event(iev, IMSG_LKA_RCPT, 0, 0, -1,
- ss, sizeof(*ss));
- lka_session_destroy(env, lkasession);
+ lka_session_fail(env, lkasession, ss);
break;
}
}
@@ -382,10 +377,7 @@ lka_dispatch_mfa(int sig, short event, void *p)
if (path->flags & F_PATH_VIRTUAL) {
if (! aliases_virtual_get(env, ss->u.path.cond->c_map,
&lkasession->expandtree, &ss->u.path)) {
- ss->code = 530;
- imsg_compose_event(iev, IMSG_LKA_RCPT, 0, 0, -1,
- ss, sizeof(*ss));
- lka_session_destroy(env, lkasession);
+ lka_session_fail(env, lkasession, ss);
break;
}
}
@@ -1158,6 +1150,15 @@ lka_session_init(struct smtpd *env, struct submit_status *ss)
}
void
+lka_session_fail(struct smtpd *env, struct lkasession *lkasession, struct submit_status *ss)
+{
+ ss->code = 530;
+ imsg_compose_event(env->sc_ievs[PROC_MFA], IMSG_LKA_RCPT, 0, 0, -1,
+ ss, sizeof(*ss));
+ lka_session_destroy(env, lkasession);
+}
+
+void
lka_session_destroy(struct smtpd *env, struct lkasession *lkasession)
{
SPLAY_REMOVE(lkatree, &env->lka_sessions, lkasession);