summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2009-11-08 23:08:57 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2009-11-08 23:08:57 +0000
commitcb89fc166cda202180868bdf62a4da204ddf2db0 (patch)
tree8264eb2c73180dda6142d65a3f6bef9c37cf49ff /usr.sbin
parent3c9d47f3b24544d8c15531bc7bec2541c36fbe8f (diff)
rework a bit expansion and data structures involved in the expansion so we
no longer have a direct mapping between structures saved in aliases/virtual db and structures used at runtime during expansion. side effects ? struct alias is smaller, databases are smaller and it is no longer necessary to rebuild aliases/virtual databases each time jacekm@ or I make changes to some obscure structure used indirectely during expansion rebuild databases, flush queues, make clean
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/smtpd/aliases.c122
-rw-r--r--usr.sbin/smtpd/forward.c17
-rw-r--r--usr.sbin/smtpd/lka.c109
-rw-r--r--usr.sbin/smtpd/makemap.c8
-rw-r--r--usr.sbin/smtpd/runner.c4
-rw-r--r--usr.sbin/smtpd/smtpd.h67
6 files changed, 173 insertions, 154 deletions
diff --git a/usr.sbin/smtpd/aliases.c b/usr.sbin/smtpd/aliases.c
index cca16116499..c23871a0f87 100644
--- a/usr.sbin/smtpd/aliases.c
+++ b/usr.sbin/smtpd/aliases.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aliases.c,v 1.26 2009/11/08 21:40:05 gilles Exp $ */
+/* $OpenBSD: aliases.c,v 1.27 2009/11/08 23:08:56 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -34,7 +34,7 @@
#include "smtpd.h"
-int aliases_expand_include(struct aliasestree *, char *);
+int aliases_expand_include(struct expandtree *, char *);
int alias_is_filter(struct alias *, char *, size_t);
int alias_is_username(struct alias *, char *, size_t);
int alias_is_address(struct alias *, char *, size_t);
@@ -75,7 +75,7 @@ aliases_exist(struct smtpd *env, objid_t mapid, char *username)
}
int
-aliases_get(struct smtpd *env, objid_t mapid, struct aliasestree *aliases, char *username)
+aliases_get(struct smtpd *env, objid_t mapid, struct expandtree *expandtree, char *username)
{
char buf[MAXLOGNAME];
int ret;
@@ -84,9 +84,9 @@ aliases_get(struct smtpd *env, objid_t mapid, struct aliasestree *aliases, char
DB *aliasesdb;
size_t nbaliases, nbsave;
struct alias alias;
- struct alias *aliasp;
struct alias *nextalias;
struct map *map;
+ struct expand_node *expnode;
map = map_find(env, mapid);
if (map == NULL)
@@ -120,15 +120,16 @@ aliases_get(struct smtpd *env, objid_t mapid, struct aliasestree *aliases, char
do {
alias = *nextalias;
++nextalias;
- if (alias.type == ALIAS_INCLUDE) {
- aliases_expand_include(aliases, alias.u.filename);
+ if (alias.type == EXPAND_INCLUDE) {
+ aliases_expand_include(expandtree, alias.u.filename);
}
else {
- aliasp = calloc(1, sizeof(struct alias));
- if (aliasp == NULL)
+ expnode = calloc(sizeof(struct expand_node), 1);
+ if (expnode == NULL)
fatal("aliases_get: calloc");
- *aliasp = alias;
- aliasestree_insert(aliases, aliasp);
+ expnode->type = alias.type;
+ expnode->u = alias.u;
+ expandtree_insert(expandtree, expnode);
}
} while (--nbaliases);
aliasesdb->close(aliasesdb);
@@ -229,7 +230,7 @@ aliases_virtual_exist(struct smtpd *env, objid_t mapid, struct path *path)
int
aliases_virtual_get(struct smtpd *env, objid_t mapid,
- struct aliasestree *aliases, struct path *path)
+ struct expandtree *expandtree, struct path *path)
{
int ret;
DBT key;
@@ -237,10 +238,10 @@ aliases_virtual_get(struct smtpd *env, objid_t mapid,
DB *aliasesdb;
size_t nbaliases, nbsave;
struct alias alias;
- struct alias *aliasp;
struct alias *nextalias;
struct map *map;
char strkey[MAX_LINE_SIZE];
+ struct expand_node *expnode;
map = map_find(env, mapid);
if (map == NULL)
@@ -295,15 +296,16 @@ aliases_virtual_get(struct smtpd *env, objid_t mapid,
do {
alias = *nextalias;
++nextalias;
- if (alias.type == ALIAS_INCLUDE) {
- aliases_expand_include(aliases, alias.u.filename);
+ if (alias.type == EXPAND_INCLUDE) {
+ aliases_expand_include(expandtree, alias.u.filename);
}
else {
- aliasp = calloc(1, sizeof(struct alias));
- if (aliasp == NULL)
+ expnode = calloc(sizeof(struct expand_node), 1);
+ if (expnode== NULL)
fatal("aliases_virtual_get: calloc");
- *aliasp = alias;
- aliasestree_insert(aliases, aliasp);
+ expnode->type = alias.type;
+ expnode->u = alias.u;
+ expandtree_insert(expandtree, expnode);
}
} while (--nbaliases);
aliasesdb->close(aliasesdb);
@@ -311,7 +313,7 @@ aliases_virtual_get(struct smtpd *env, objid_t mapid,
}
int
-aliases_expand_include(struct aliasestree *aliases, char *filename)
+aliases_expand_include(struct expandtree *expandtree, char *filename)
{
FILE *fp;
char *line;
@@ -319,7 +321,7 @@ aliases_expand_include(struct aliasestree *aliases, char *filename)
size_t lineno = 0;
char delim[] = { '\\', '#' };
struct alias alias;
- struct alias *aliasp;
+ struct expand_node *expnode;
fp = fopen(filename, "r");
if (fp == NULL) {
@@ -336,15 +338,16 @@ aliases_expand_include(struct aliasestree *aliases, char *filename)
log_warnx("could not parse include entry \"%s\".", line);
}
- if (alias.type == ALIAS_INCLUDE) {
+ if (alias.type == EXPAND_INCLUDE) {
log_warnx("nested inclusion is not supported.");
}
else {
- aliasp = calloc(1, sizeof(struct alias));
- if (aliasp == NULL)
- fatal("aliases_expand_include: calloc");
- *aliasp = alias;
- aliasestree_insert(aliases, aliasp);
+ expnode = calloc(sizeof(struct expand_node), 1);
+ if (expnode== NULL)
+ fatal("aliases_virtual_get: calloc");
+ expnode->type = alias.type;
+ expnode->u = alias.u;
+ expandtree_insert(expandtree, expnode);
}
free(line);
@@ -395,7 +398,7 @@ alias_is_filter(struct alias *alias, char *line, size_t len)
if (strlcpy(alias->u.filter, line, sizeof(alias->u.filter)) >=
sizeof(alias->u.filter))
return 0;
- alias->type = ALIAS_FILTER;
+ alias->type = EXPAND_FILTER;
return 1;
}
return 0;
@@ -415,7 +418,7 @@ alias_is_username(struct alias *alias, char *line, size_t len)
++line;
}
- alias->type = ALIAS_USERNAME;
+ alias->type = EXPAND_USERNAME;
return 1;
}
@@ -437,8 +440,8 @@ alias_is_address(struct alias *alias, char *line, size_t len)
/* scan pre @ for disallowed chars */
*domain++ = '\0';
- strlcpy(alias->u.path.user, line, sizeof(alias->u.path.user));
- strlcpy(alias->u.path.domain, domain, sizeof(alias->u.path.domain));
+ strlcpy(alias->u.mailaddr.user, line, sizeof(alias->u.mailaddr.user));
+ strlcpy(alias->u.mailaddr.domain, domain, sizeof(alias->u.mailaddr.domain));
while (*line) {
char allowedset[] = "!#$%*/?|^{}`~&'+-=_.";
@@ -456,7 +459,7 @@ alias_is_address(struct alias *alias, char *line, size_t len)
++domain;
}
- alias->type = ALIAS_ADDRESS;
+ alias->type = EXPAND_ADDRESS;
return 1;
}
@@ -469,7 +472,7 @@ alias_is_filename(struct alias *alias, char *line, size_t len)
if (strlcpy(alias->u.filename, line,
sizeof(alias->u.filename)) >= sizeof(alias->u.filename))
return 0;
- alias->type = ALIAS_FILENAME;
+ alias->type = EXPAND_FILENAME;
return 1;
}
@@ -482,50 +485,47 @@ alias_is_include(struct alias *alias, char *line, size_t len)
if (! alias_is_filename(alias, line + 9, len - 9))
return 0;
- alias->type = ALIAS_INCLUDE;
+ alias->type = EXPAND_INCLUDE;
return 1;
}
-int
-alias_cmp(struct alias *a1, struct alias *a2)
+struct expand_node *
+expandtree_lookup(struct expandtree *expandtree, struct expand_node *node)
{
- /*
- * do not return u_int64_t's
- */
- if (a1->id < a2->id)
- return (-1);
-
- if (a1->id > a2->id)
- return (1);
+ struct expand_node key;
- return (0);
+ key = *node;
+ return RB_FIND(expandtree, expandtree, &key);
}
-struct alias *
-aliasestree_lookup(struct aliasestree *aliasestree, struct alias *alias)
+void
+expandtree_insert(struct expandtree *expandtree, struct expand_node *node)
{
- struct alias key;
-
- key = *alias;
- return RB_FIND(aliasestree, aliasestree, &key);
+ node->id = generate_uid();
+ RB_INSERT(expandtree, expandtree, node);
}
void
-aliasestree_insert(struct aliasestree *aliasestree, struct alias *alias)
+expandtree_remove(struct expandtree *expandtree, struct expand_node *node)
{
- alias->id = generate_uid();
- RB_INSERT(aliasestree, aliasestree, alias);
+ struct expand_node *p;
+
+ p = expandtree_lookup(expandtree, node);
+ if (p == NULL)
+ fatalx("expandtree_remove: node doesn't exist.");
+ RB_REMOVE(expandtree, expandtree, node);
}
-void
-aliasestree_remove(struct aliasestree *aliasestree, struct alias *alias)
+int
+expand_cmp(struct expand_node *e1, struct expand_node *e2)
{
- struct alias *node;
+ if (e1->id < e2->id)
+ return -1;
- node = aliasestree_lookup(aliasestree, alias);
- if (node == NULL)
- fatalx("aliasestree_remove: node doesn't exist.");
- RB_REMOVE(aliasestree, aliasestree, alias);
+ if (e1->id > e2->id)
+ return 1;
+
+ return 0;
}
-RB_GENERATE(aliasestree, alias, entry, alias_cmp);
+RB_GENERATE(expandtree, expand_node, entry, expand_cmp);
diff --git a/usr.sbin/smtpd/forward.c b/usr.sbin/smtpd/forward.c
index f2d70a9f608..e9a245433bd 100644
--- a/usr.sbin/smtpd/forward.c
+++ b/usr.sbin/smtpd/forward.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: forward.c,v 1.16 2009/11/08 21:40:05 gilles Exp $ */
+/* $OpenBSD: forward.c,v 1.17 2009/11/08 23:08:56 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -35,15 +35,15 @@
#include "smtpd.h"
int
-forwards_get(int fd, struct aliasestree *aliases)
+forwards_get(int fd, struct expandtree *expandtree)
{
FILE *fp;
struct alias alias;
- struct alias *aliasp;
char *buf, *lbuf, *p, *cp;
size_t len;
size_t nbaliases = 0;
int quoted;
+ struct expand_node *expnode;
fp = fdopen(fd, "r");
if (fp == NULL)
@@ -89,17 +89,18 @@ forwards_get(int fd, struct aliasestree *aliases)
continue;
}
- if (alias.type == ALIAS_INCLUDE) {
+ if (alias.type == EXPAND_INCLUDE) {
log_debug(
"includes are forbidden in ~/.forward");
continue;
}
- aliasp = calloc(1, sizeof(struct alias));
- if (aliasp == NULL)
+ expnode = calloc(sizeof(struct expand_node), 1);
+ if (expnode == NULL)
fatal("calloc");
- *aliasp = alias;
- aliasestree_insert(aliases, aliasp);
+ expnode->type = alias.type;
+ expnode->u = alias.u;
+ expandtree_insert(expandtree, expnode);
nbaliases++;
} while (*cp != '\0');
}
diff --git a/usr.sbin/smtpd/lka.c b/usr.sbin/smtpd/lka.c
index 741efc2923f..71849263256 100644
--- a/usr.sbin/smtpd/lka.c
+++ b/usr.sbin/smtpd/lka.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lka.c,v 1.82 2009/11/08 21:40:05 gilles Exp $ */
+/* $OpenBSD: lka.c,v 1.83 2009/11/08 23:08:56 gilles Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -53,13 +53,13 @@ void lka_setup_events(struct smtpd *);
void lka_disable_events(struct smtpd *);
void lka_expand_pickup(struct smtpd *, struct lkasession *);
int lka_expand_resume(struct smtpd *, struct lkasession *);
-int lka_resolve_alias(struct smtpd *, char *tag, struct path *, struct alias *);
+int lka_resolve_node(struct smtpd *, char *tag, struct path *, struct expand_node *);
int lka_verify_mail(struct smtpd *, struct path *);
struct rule *ruleset_match(struct smtpd *, char *, struct path *, struct sockaddr_storage *);
int lka_resolve_path(struct smtpd *, struct lkasession *, struct path *);
struct lkasession *lka_session_init(struct smtpd *, struct submit_status *);
void lka_request_forwardfile(struct smtpd *, struct lkasession *, char *);
-void lka_clear_aliasestree(struct aliasestree *);
+void lka_clear_expandtree(struct expandtree *);
void lka_clear_deliverylist(struct deliverylist *);
int lka_encode_credentials(char *, size_t, char *);
size_t lka_expand(char *, size_t, struct path *);
@@ -232,7 +232,7 @@ lka_dispatch_parent(int sig, short event, void *p)
/* received a descriptor, we have a forward file ... */
if (fd != -1) {
- if (! forwards_get(fd, &lkasession->aliasestree)) {
+ if (! forwards_get(fd, &lkasession->expandtree)) {
lkasession->ss.code = 530;
lkasession->flags |= F_ERROR;
}
@@ -370,7 +370,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->aliasestree, ss->u.path.user)) {
+ &lkasession->expandtree, ss->u.path.user)) {
ss->code = 530;
imsg_compose_event(iev, IMSG_LKA_RCPT, 0, 0, -1,
ss, sizeof(*ss));
@@ -381,7 +381,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->aliasestree, &ss->u.path)) {
+ &lkasession->expandtree, &ss->u.path)) {
ss->code = 530;
imsg_compose_event(iev, IMSG_LKA_RCPT, 0, 0, -1,
ss, sizeof(*ss));
@@ -833,21 +833,21 @@ lka_expand(char *buf, size_t len, struct path *path)
}
int
-lka_resolve_alias(struct smtpd *env, char *tag, struct path *path, struct alias *alias)
+lka_resolve_node(struct smtpd *env, char *tag, struct path *path, struct expand_node *expnode)
{
struct path psave = *path;
bzero(path, sizeof(struct path));
- switch (alias->type) {
- case ALIAS_USERNAME:
- log_debug("lka_resolve_alias: alias is local username: %s",
- alias->u.username);
- if (strlcpy(path->pw_name, alias->u.username,
+ switch (expnode->type) {
+ case EXPAND_USERNAME:
+ log_debug("lka_resolve_node: node is local username: %s",
+ expnode->u.username);
+ if (strlcpy(path->pw_name, expnode->u.username,
sizeof(path->pw_name)) >= sizeof(path->pw_name))
return 0;
- if (strlcpy(path->user, alias->u.username,
+ if (strlcpy(path->user, expnode->u.username,
sizeof(path->user)) >= sizeof(path->user))
return 0;
@@ -861,37 +861,44 @@ lka_resolve_alias(struct smtpd *env, char *tag, struct path *path, struct alias
sizeof(psave.domain));
}
- log_debug("lka_resolve_alias: resolved to address: %s@%s",
+ log_debug("lka_resolve_node: resolved to address: %s@%s",
path->user, path->domain);
lka_rcpt_action(env, tag, path);
break;
- case ALIAS_FILENAME:
- log_debug("lka_resolve_alias: alias is filename: %s",
- alias->u.filename);
+ case EXPAND_FILENAME:
+ log_debug("lka_resolve_node: node is filename: %s",
+ expnode->u.filename);
path->rule.r_action = A_FILENAME;
- strlcpy(path->u.filename, alias->u.filename,
+ strlcpy(path->u.filename, expnode->u.filename,
sizeof(path->u.filename));
break;
- case ALIAS_FILTER:
- log_debug("lka_resolve_alias: alias is filter: %s",
- alias->u.filter);
+ case EXPAND_FILTER:
+ log_debug("lka_resolve_node: node is filter: %s",
+ expnode->u.filter);
path->rule.r_action = A_EXT;
- strlcpy(path->rule.r_value.command, alias->u.filter + 2,
+ strlcpy(path->rule.r_value.command, expnode->u.filter + 2,
sizeof(path->rule.r_value.command));
path->rule.r_value.command[strlen(path->rule.r_value.command) - 1] = '\0';
break;
- case ALIAS_ADDRESS:
- log_debug("lka_resolve_alias: alias is address: %s@%s",
- alias->u.path.user, alias->u.path.domain);
+ case EXPAND_ADDRESS:
+ log_debug("lka_resolve_node: node is address: %s@%s",
+ expnode->u.mailaddr.user, expnode->u.mailaddr.domain);
+
+ if (strlcpy(path->user, expnode->u.mailaddr.user,
+ sizeof(path->user)) >= sizeof(path->user))
+ return 0;
+
+ if (strlcpy(path->domain, expnode->u.mailaddr.domain,
+ sizeof(path->domain)) >= sizeof(path->domain))
+ return 0;
- *path = alias->u.path;
lka_rcpt_action(env, tag, path);
break;
- case ALIAS_INCLUDE:
- fatalx("lka_resolve_alias: unexpected type");
+ case EXPAND_INCLUDE:
+ fatalx("lka_resolve_node: unexpected type");
break;
}
@@ -933,24 +940,24 @@ int
lka_expand_resume(struct smtpd *env, struct lkasession *lkasession)
{
u_int8_t done = 1;
- struct alias *rmalias = NULL;
- struct alias *alias;
+ struct expand_node *expnode, *rmnode = NULL;
struct path *lkasessionpath = NULL;
struct path *respath = NULL;
lkasessionpath = &lkasession->path;
- rmalias = NULL;
- RB_FOREACH(alias, aliasestree, &lkasession->aliasestree) {
+ rmnode = NULL;
+
+ RB_FOREACH(expnode, expandtree, &lkasession->expandtree) {
struct path path;
- if (rmalias) {
- aliasestree_remove(&lkasession->aliasestree, rmalias);
- free(rmalias);
- rmalias = NULL;
+ if (rmnode) {
+ expandtree_remove(&lkasession->expandtree, rmnode);
+ free(rmnode);
+ rmnode = NULL;
}
- rmalias = alias;
+ rmnode = expnode;
- if (! lka_resolve_alias(env, lkasession->message.tag, &path, alias))
+ if (! lka_resolve_node(env, lkasession->message.tag, &path, expnode))
return -1;
path.flags = lkasessionpath->flags;
@@ -967,28 +974,28 @@ lka_expand_resume(struct smtpd *env, struct lkasession *lkasession)
else if (respath->flags & F_PATH_ALIAS) {
if (aliases_get(env, lkasessionpath->rule.r_amap,
- &lkasession->aliasestree, respath->user))
+ &lkasession->expandtree, respath->user))
done = 0;
}
else if (respath->flags & F_PATH_VIRTUAL) {
if (aliases_virtual_get(env, lkasessionpath->cond->c_map,
- &lkasession->aliasestree, respath))
+ &lkasession->expandtree, respath))
done = 0;
}
}
- if (rmalias) {
- aliasestree_remove(&lkasession->aliasestree, rmalias);
- free(rmalias);
+ if (rmnode) {
+ expandtree_remove(&lkasession->expandtree, rmnode);
+ free(rmnode);
}
if (!done && lkasession->iterations == 5) {
return -1;
}
- if (RB_ROOT(&lkasession->aliasestree) == NULL)
+ if (RB_ROOT(&lkasession->expandtree) == NULL)
return 0;
return 1;
@@ -1078,13 +1085,13 @@ lkasession_cmp(struct lkasession *s1, struct lkasession *s2)
}
void
-lka_clear_aliasestree(struct aliasestree *aliasestree)
+lka_clear_expandtree(struct expandtree *expandtree)
{
- struct alias *alias;
+ struct expand_node *expnode;
- while ((alias = RB_ROOT(aliasestree)) != NULL) {
- aliasestree_remove(aliasestree, alias);
- free(alias);
+ while ((expnode = RB_ROOT(expandtree)) != NULL) {
+ expandtree_remove(expandtree, expnode);
+ free(expnode);
}
}
@@ -1135,7 +1142,7 @@ lka_session_init(struct smtpd *env, struct submit_status *ss)
lkasession->message = ss->msg;
lkasession->ss = *ss;
- RB_INIT(&lkasession->aliasestree);
+ RB_INIT(&lkasession->expandtree);
TAILQ_INIT(&lkasession->deliverylist);
SPLAY_INSERT(lkatree, &env->lka_sessions, lkasession);
@@ -1168,7 +1175,7 @@ lka_expansion_done(struct smtpd *env, struct lkasession *lkasession)
struct path *path;
if (lkasession->flags & F_ERROR) {
- lka_clear_aliasestree(&lkasession->aliasestree);
+ lka_clear_expandtree(&lkasession->expandtree);
lka_clear_deliverylist(&lkasession->deliverylist);
imsg_compose_event(env->sc_ievs[PROC_MFA], IMSG_LKA_RCPT, 0, 0,
-1, &lkasession->ss, sizeof(struct submit_status));
diff --git a/usr.sbin/smtpd/makemap.c b/usr.sbin/smtpd/makemap.c
index d5ee5c34be4..a707c6220c2 100644
--- a/usr.sbin/smtpd/makemap.c
+++ b/usr.sbin/smtpd/makemap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: makemap.c,v 1.23 2009/11/03 22:57:41 gilles Exp $ */
+/* $OpenBSD: makemap.c,v 1.24 2009/11/08 23:08:56 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -354,9 +354,9 @@ make_plain(DBT *val, char *text)
int
make_aliases(DBT *val, char *text)
{
- struct alias a;
- char *subrcpt;
- char *endp;
+ struct alias a;
+ char *subrcpt;
+ char *endp;
val->data = NULL;
val->size = 0;
diff --git a/usr.sbin/smtpd/runner.c b/usr.sbin/smtpd/runner.c
index 31b0017057d..594d7d458da 100644
--- a/usr.sbin/smtpd/runner.c
+++ b/usr.sbin/smtpd/runner.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: runner.c,v 1.71 2009/11/08 21:40:05 gilles Exp $ */
+/* $OpenBSD: runner.c,v 1.72 2009/11/08 23:08:56 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -800,6 +800,8 @@ runner_message_schedule(struct message *messagep, time_t tm)
delay = SMTPD_QUEUE_MAXINTERVAL;
+ // recompute path
+
if (messagep->type == T_MDA_MESSAGE ||
messagep->type == T_BOUNCE_MESSAGE) {
if (messagep->status & S_MESSAGE_LOCKFAILURE) {
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index 17028a8783d..05a45a8893e 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.155 2009/11/08 21:40:05 gilles Exp $ */
+/* $OpenBSD: smtpd.h,v 1.156 2009/11/08 23:08:56 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -349,6 +349,18 @@ enum path_flags {
F_PATH_RELAY = 0x80,
};
+struct mailaddr {
+ char user[MAX_LOCALPART_SIZE];
+ char domain[MAX_DOMAINPART_SIZE];
+};
+
+union path_data {
+ char username[MAXLOGNAME];
+ char filename[MAXPATHLEN];
+ char filter[MAXPATHLEN];
+ struct mailaddr mailaddr;
+};
+
struct path {
TAILQ_ENTRY(path) entry;
struct rule rule;
@@ -358,31 +370,28 @@ struct path {
char user[MAX_LOCALPART_SIZE];
char domain[MAX_DOMAINPART_SIZE];
char pw_name[MAXLOGNAME];
- union path_data {
- char filename[MAXPATHLEN];
- char filter[MAXPATHLEN];
- } u;
+ union path_data u;
};
TAILQ_HEAD(deliverylist, path);
-enum alias_type {
- ALIAS_USERNAME,
- ALIAS_FILENAME,
- ALIAS_FILTER,
- ALIAS_INCLUDE,
- ALIAS_ADDRESS
+enum expand_type {
+ EXPAND_USERNAME,
+ EXPAND_FILENAME,
+ EXPAND_FILTER,
+ EXPAND_INCLUDE,
+ EXPAND_ADDRESS
+};
+
+struct expand_node {
+ RB_ENTRY(expand_node) entry;
+ u_int64_t id;
+ enum expand_type type;
+ union path_data u;
};
struct alias {
- RB_ENTRY(alias) entry;
- u_int64_t id;
- enum alias_type type;
- union alias_data {
- char username[MAXLOGNAME];
- char filename[MAXPATHLEN];
- char filter[MAXPATHLEN];
- struct path path;
- } u;
+ enum expand_type type;
+ union path_data u;
};
enum message_type {
@@ -728,7 +737,7 @@ struct lkasession {
struct path path;
struct deliverylist deliverylist;
- RB_HEAD(aliasestree, alias) aliasestree;
+ RB_HEAD(expandtree, expand_node) expandtree;
u_int8_t iterations;
u_int32_t pending;
@@ -779,16 +788,16 @@ struct mta_session {
/* aliases.c */
int aliases_exist(struct smtpd *, objid_t, char *);
-int aliases_get(struct smtpd *, objid_t, struct aliasestree *, char *);
+int aliases_get(struct smtpd *, objid_t, struct expandtree *, char *);
int aliases_vdomain_exists(struct smtpd *, objid_t, char *);
int aliases_virtual_exist(struct smtpd *, objid_t, struct path *);
-int aliases_virtual_get(struct smtpd *, objid_t, struct aliasestree *, struct path *);
+int aliases_virtual_get(struct smtpd *, objid_t, struct expandtree *, struct path *);
int alias_parse(struct alias *, char *);
-int alias_cmp(struct alias *, struct alias *);
-void aliasestree_insert(struct aliasestree *, struct alias *);
-void aliasestree_remove(struct aliasestree *, struct alias *);
-struct alias *aliasestree_lookup(struct aliasestree *, struct alias *);
-RB_PROTOTYPE(aliasestree, alias, entry, alias_cmp);
+int expand_cmp(struct expand_node *, struct expand_node *);
+void expandtree_insert(struct expandtree *, struct expand_node *);
+void expandtree_remove(struct expandtree *, struct expand_node *);
+struct expand_node *expandtree_lookup(struct expandtree *, struct expand_node *);
+RB_PROTOTYPE(expandtree, expand_node, nodes, expand_cmp);
/* authenticate.c */
int authenticate_user(char *, char *);
@@ -823,7 +832,7 @@ void dns_async(struct smtpd *, struct imsgev *, int,
/* forward.c */
-int forwards_get(int, struct aliasestree *);
+int forwards_get(int, struct expandtree *);
/* smtpd.c */
int child_cmp(struct child *, struct child *);