summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2011-05-21 18:04:52 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2011-05-21 18:04:52 +0000
commitd2953cf429d3f22943f876b8925884b25b9ee519 (patch)
tree0524c4667de69f6c76fea28ee0c780efe7526887 /usr.sbin/smtpd
parent8cc1923c13f01aa636b3836e0617dad0bcfa91af (diff)
when a user add himself to his own ~/.forward, the delivery method was not
reset by ruleset matching and since it was cleared upon entering lka_session_resolve_node(), it would trigger a fatal().
Diffstat (limited to 'usr.sbin/smtpd')
-rw-r--r--usr.sbin/smtpd/lka_session.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/usr.sbin/smtpd/lka_session.c b/usr.sbin/smtpd/lka_session.c
index c2d280cabfc..a3157efdd1a 100644
--- a/usr.sbin/smtpd/lka_session.c
+++ b/usr.sbin/smtpd/lka_session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lka_session.c,v 1.4 2011/05/17 18:54:32 gilles Exp $ */
+/* $OpenBSD: lka_session.c,v 1.5 2011/05/21 18:04:51 gilles Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org>
@@ -116,9 +116,12 @@ lka_session_envelope_expand(struct lka_session *lks, struct envelope *ep)
(void)strlcpy(ep->delivery.agent.mda.as_user, u.username,
sizeof (ep->delivery.agent.mda.as_user));
+ log_debug("###1");
+
ep->delivery.type = D_MDA;
switch (ep->rule.r_action) {
case A_MBOX:
+ log_debug("###1.1");
ep->delivery.agent.mda.method = A_MBOX;
(void)strlcpy(ep->delivery.agent.mda.to.user,
u.username,
@@ -127,6 +130,7 @@ lka_session_envelope_expand(struct lka_session *lks, struct envelope *ep)
case A_MAILDIR:
case A_FILENAME:
case A_EXT:
+ log_debug("###1.2");
ep->delivery.agent.mda.method = ep->rule.r_action;
(void)strlcpy(ep->delivery.agent.mda.to.buffer,
ep->rule.r_value.buffer,
@@ -136,6 +140,8 @@ lka_session_envelope_expand(struct lka_session *lks, struct envelope *ep)
fatalx("lka_session_envelope_expand: unexpected rule action");
return 0;
}
+
+ log_debug("###2");
lka_session_request_forwardfile(lks, ep, u.username);
return 1;
}
@@ -168,6 +174,7 @@ lka_session_forward_reply(struct forward_req *fwreq, int fd)
lks->pending--;
ep = &fwreq->envelope;
+
if (fd != -1) {
/* opened .forward okay */
if (! forwards_get(fd, &lks->expandtree, fwreq->as_user)) {
@@ -236,7 +243,7 @@ lka_session_pickup(struct lka_session *lks, struct envelope *ep)
if (lks->pending)
return;
-
+ log_debug("#2plop: %d", ep->delivery.agent.mda.method);
lka_session_done(lks);
}
@@ -246,6 +253,8 @@ lka_session_resume(struct lka_session *lks, struct envelope *ep)
struct expandnode *xn;
u_int8_t done = 1;
+ log_debug("#1plop: %d", ep->delivery.agent.mda.method);
+
RB_FOREACH(xn, expandtree, &lks->expandtree) {
/* this node has already been expanded, skip */
@@ -397,8 +406,10 @@ int
lka_session_resolve_node(struct envelope *ep, struct expandnode *xn)
{
struct delivery *dlv;
+ struct delivery olddlv;
dlv = &ep->delivery;
+ memcpy(&olddlv, dlv, sizeof (*dlv));
bzero(&dlv->agent, sizeof (dlv->agent));
switch (xn->type) {
@@ -438,8 +449,10 @@ lka_session_resolve_node(struct envelope *ep, struct expandnode *xn)
ep->rule.r_condition.c_type = C_DOM;
/* if expansion of a user results in same user ... deliver */
- if (strcmp(xn->u.user, xn->as_user) == 0)
+ if (strcmp(xn->u.user, xn->as_user) == 0) {
+ ep->delivery.agent.mda.method = olddlv.agent.mda.method;
break;
+ }
/* otherwise rewrite delivery user with expansion result */
(void)strlcpy(dlv->agent.mda.to.user, xn->u.user,