summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreric <eric@openbsd.org>2012-09-21 19:37:08 +0000
committereric <eric@openbsd.org>2012-09-21 19:37:08 +0000
commit62969e16f71f2976703255ca478978d93add64f5 (patch)
treeb15568069465dd5e5d98463b5d37466ff5e344fc
parentwrap expandtree into a "struct expand". (diff)
downloadwireguard-openbsd-62969e16f71f2976703255ca478978d93add64f5.tar.xz
wireguard-openbsd-62969e16f71f2976703255ca478978d93add64f5.zip
Do not pass the username to forwards_get() which does not have to care about
this. Instead, set the username on the expand context, and copy it on the expand nodes as they are inserted. ok gilles@
-rw-r--r--usr.sbin/smtpd/aliases.c4
-rw-r--r--usr.sbin/smtpd/expand.c6
-rw-r--r--usr.sbin/smtpd/forward.c6
-rw-r--r--usr.sbin/smtpd/lka_session.c6
-rw-r--r--usr.sbin/smtpd/smtpd.h5
5 files changed, 15 insertions, 12 deletions
diff --git a/usr.sbin/smtpd/aliases.c b/usr.sbin/smtpd/aliases.c
index 9a9aa9b6080..59bf4c4206b 100644
--- a/usr.sbin/smtpd/aliases.c
+++ b/usr.sbin/smtpd/aliases.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aliases.c,v 1.55 2012/09/21 16:40:20 eric Exp $ */
+/* $OpenBSD: aliases.c,v 1.56 2012/09/21 19:37:08 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -56,7 +56,6 @@ aliases_get(objid_t mapid, struct expand *expand, const char *username)
/* foreach node in map_alias expandtree, we merge */
nbaliases = 0;
RB_FOREACH(xn, expandtree, &map_alias->expand.tree) {
- strlcpy(xn->as_user, SMTPD_USER, sizeof (xn->as_user));
if (xn->type == EXPAND_INCLUDE)
nbaliases += aliases_expand_include(expand, xn->u.buffer);
else {
@@ -98,7 +97,6 @@ aliases_virtual_get(objid_t mapid, struct expand *expand,
/* foreach node in map_virtual expand, we merge */
nbaliases = 0;
RB_FOREACH(xn, expandtree, &map_virtual->expand.tree) {
- strlcpy(xn->as_user, SMTPD_USER, sizeof (xn->as_user));
if (xn->type == EXPAND_INCLUDE)
nbaliases += aliases_expand_include(expand, xn->u.buffer);
else {
diff --git a/usr.sbin/smtpd/expand.c b/usr.sbin/smtpd/expand.c
index a3c9b9733eb..c7798e08bdf 100644
--- a/usr.sbin/smtpd/expand.c
+++ b/usr.sbin/smtpd/expand.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: expand.c,v 1.15 2012/09/21 16:40:20 eric Exp $ */
+/* $OpenBSD: expand.c,v 1.16 2012/09/21 19:37:08 eric Exp $ */
/*
* Copyright (c) 2009 Gilles Chehade <gilles@openbsd.org>
@@ -46,6 +46,10 @@ expand_insert(struct expand *expand, struct expandnode *node)
return;
xn = xmemdup(node, sizeof *xn, "expand_insert");
+
+ /* copy expansion context on node */
+ strlcpy(xn->as_user, expand->user, sizeof xn->as_user);
+
RB_INSERT(expandtree, &expand->tree, xn);
}
diff --git a/usr.sbin/smtpd/forward.c b/usr.sbin/smtpd/forward.c
index ce8938f3e95..55d15682818 100644
--- a/usr.sbin/smtpd/forward.c
+++ b/usr.sbin/smtpd/forward.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: forward.c,v 1.29 2012/09/21 16:40:20 eric Exp $ */
+/* $OpenBSD: forward.c,v 1.30 2012/09/21 19:37:08 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -34,7 +34,7 @@
#include "log.h"
int
-forwards_get(int fd, struct expand *expand, const char *as_user)
+forwards_get(int fd, struct expand *expand)
{
FILE *fp;
char *buf, *lbuf, *p, *cp;
@@ -93,8 +93,6 @@ forwards_get(int fd, struct expand *expand, const char *as_user)
continue;
}
- (void)strlcpy(xn.as_user, as_user, sizeof(xn.as_user));
-
expand_insert(expand, &xn);
nbaliases++;
} while (*cp != '\0');
diff --git a/usr.sbin/smtpd/lka_session.c b/usr.sbin/smtpd/lka_session.c
index ee77d3a3498..5f6342b29f5 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.32 2012/09/21 16:40:20 eric Exp $ */
+/* $OpenBSD: lka_session.c,v 1.33 2012/09/21 19:37:08 eric Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org>
@@ -193,7 +193,9 @@ lka_session_forward_reply(struct forward_req *fwreq, int fd)
if (fd != -1) {
/* opened .forward okay */
- if (! forwards_get(fd, &lks->expand, fwreq->as_user)) {
+ strlcpy(lks->expand.user, fwreq->as_user,
+ sizeof lks->expand.user);
+ if (! forwards_get(fd, &lks->expand)) {
lks->ss.code = 530;
lks->flags |= F_ERROR;
}
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index 28cd955fb0e..0bc17424876 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.365 2012/09/21 16:40:20 eric Exp $ */
+/* $OpenBSD: smtpd.h,v 1.366 2012/09/21 19:37:08 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -378,6 +378,7 @@ struct expandnode {
struct expand {
RB_HEAD(expandtree, expandnode) tree;
+ char user[MAXLOGNAME];
};
#define SMTPD_ENVELOPE_VERSION 1
@@ -981,7 +982,7 @@ void expand_free(struct expand *);
RB_PROTOTYPE(expandtree, expandnode, nodes, expand_cmp);
/* forward.c */
-int forwards_get(int, struct expand *, const char *);
+int forwards_get(int, struct expand *);
/* lka.c */