summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2009-10-07 18:09:13 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2009-10-07 18:09:13 +0000
commit0bd78cb0adb577d00248762e6f5f78cb75047c48 (patch)
tree0c04a835617ce90af2b9aff1d62990eb09aa9412
parent622768b2cd479ad6bfdbf3d62078732df052ba87 (diff)
currently both mfa and lka perform ruleset matching for their own purposes.
make lka the only caller of ruleset_match(), mfa request match through imsg which will shrink its code and help me implement virtual domains properly. idea discussed with jacekm@
-rw-r--r--usr.sbin/smtpd/lka.c21
-rw-r--r--usr.sbin/smtpd/mfa.c35
-rw-r--r--usr.sbin/smtpd/smtpd.h8
3 files changed, 50 insertions, 14 deletions
diff --git a/usr.sbin/smtpd/lka.c b/usr.sbin/smtpd/lka.c
index 10214e0480f..a561a91b80e 100644
--- a/usr.sbin/smtpd/lka.c
+++ b/usr.sbin/smtpd/lka.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lka.c,v 1.64 2009/10/07 17:30:41 gilles Exp $ */
+/* $OpenBSD: lka.c,v 1.65 2009/10/07 18:09:12 gilles Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -344,6 +344,25 @@ lka_dispatch_mfa(int sig, short event, void *p)
break;
}
+ case IMSG_LKA_RULEMATCH: {
+ struct submit_status *ss = imsg.data;
+ struct rule *r;
+
+ IMSG_SIZE_CHECK(ss);
+
+ ss->code = 530;
+
+ r = ruleset_match(env, &ss->u.path, &ss->ss);
+ if (r != NULL) {
+ ss->code = 250;
+ ss->u.path.rule = *r;
+ }
+
+ imsg_compose_event(env->sc_ievs[PROC_MFA], IMSG_LKA_RULEMATCH, 0, 0, -1,
+ ss, sizeof(*ss));
+
+ break;
+ }
case IMSG_LKA_RCPT: {
struct submit_status *ss = imsg.data;
struct message message;
diff --git a/usr.sbin/smtpd/mfa.c b/usr.sbin/smtpd/mfa.c
index 50570c71ab7..59f968af1e2 100644
--- a/usr.sbin/smtpd/mfa.c
+++ b/usr.sbin/smtpd/mfa.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mfa.c,v 1.38 2009/10/07 17:30:41 gilles Exp $ */
+/* $OpenBSD: mfa.c,v 1.39 2009/10/07 18:09:12 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -45,6 +45,7 @@ void mfa_disable_events(struct smtpd *);
void mfa_test_mail(struct smtpd *, struct message *);
void mfa_test_rcpt(struct smtpd *, struct message *);
+void mfa_test_rcpt_resume(struct smtpd *, struct submit_status *);
int strip_source_route(char *, size_t);
@@ -311,6 +312,14 @@ mfa_dispatch_lka(int sig, short event, void *p)
0, 0, -1, ss, sizeof(*ss));
break;
}
+ case IMSG_LKA_RULEMATCH: {
+ struct submit_status *ss = imsg.data;
+
+ IMSG_SIZE_CHECK(ss);
+
+ mfa_test_rcpt_resume(env, ss);
+ break;
+ }
default:
log_warnx("mfa_dispatch_lka: got imsg %d",
imsg.hdr.type);
@@ -503,7 +512,6 @@ void
mfa_test_rcpt(struct smtpd *env, struct message *m)
{
struct submit_status ss;
- struct rule *r;
if (! valid_message_id(m->message_id))
fatalx("mfa_test_rcpt: received corrupted message_id");
@@ -524,22 +532,25 @@ mfa_test_rcpt(struct smtpd *env, struct message *m)
if (ss.flags & F_MESSAGE_AUTHENTICATED)
ss.u.path.flags |= F_PATH_AUTHENTICATED;
- r = ruleset_match(env, &ss.u.path, &ss.ss);
- if (r == NULL)
- goto refuse;
+ imsg_compose_event(env->sc_ievs[PROC_LKA], IMSG_LKA_RULEMATCH, 0, 0, -1,
+ &ss, sizeof(ss));
- ss.u.path.rule = *r;
- goto accept;
-
+ return;
refuse:
imsg_compose_event(env->sc_ievs[PROC_SMTP], IMSG_MFA_RCPT, 0, 0, -1, &ss,
sizeof(ss));
- return;
+}
+
+void
+mfa_test_rcpt_resume(struct smtpd *env, struct submit_status *ss) {
+ if (ss->code != 250) {
+ imsg_compose_event(env->sc_ievs[PROC_SMTP], IMSG_MFA_RCPT, 0, 0, -1, ss,
+ sizeof(*ss));
+ return;
+ }
-accept:
- ss.code = 250;
imsg_compose_event(env->sc_ievs[PROC_LKA], IMSG_LKA_RCPT, 0, 0, -1,
- &ss, sizeof(ss));
+ ss, sizeof(*ss));
}
int
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index f86c14ec146..e3ff31ea65d 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.144 2009/09/23 09:40:39 jacekm Exp $ */
+/* $OpenBSD: smtpd.h,v 1.145 2009/10/07 18:09:12 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -136,6 +136,7 @@ enum imsg_type {
IMSG_LKA_MAIL,
IMSG_LKA_RCPT,
IMSG_LKA_SECRET,
+ IMSG_LKA_RULEMATCH,
IMSG_MDA_FINALIZE,
IMSG_MFA_RCPT,
IMSG_MFA_MAIL,
@@ -699,6 +700,11 @@ struct secret {
char secret[MAX_LINE_SIZE];
};
+struct rulematch {
+ u_int64_t id;
+ struct submit_status ss;
+};
+
enum lkasession_flags {
F_ERROR = 0x1
};