diff options
author | Eric Faurot <eric@cvs.openbsd.org> | 2012-09-19 10:10:31 +0000 |
---|---|---|
committer | Eric Faurot <eric@cvs.openbsd.org> | 2012-09-19 10:10:31 +0000 |
commit | 77a2f7f5fbb26fa4ac3c62390285c1436233c0e0 (patch) | |
tree | 4649158541a30ca90e26dd37637524d8789f6f95 /usr.sbin/smtpd | |
parent | 1fd0ba209b3f1be04b54e9a857ba3158549a66cc (diff) |
Remove aliases_exists() and aliases_virtual_exists(). The corresponding
*_get() functions can be called directly.
ok gilles@
Diffstat (limited to 'usr.sbin/smtpd')
-rw-r--r-- | usr.sbin/smtpd/aliases.c | 88 | ||||
-rw-r--r-- | usr.sbin/smtpd/lka_session.c | 17 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.h | 6 |
3 files changed, 27 insertions, 84 deletions
diff --git a/usr.sbin/smtpd/aliases.c b/usr.sbin/smtpd/aliases.c index 2d358e59947..87d1a0fadef 100644 --- a/usr.sbin/smtpd/aliases.c +++ b/usr.sbin/smtpd/aliases.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aliases.c,v 1.50 2012/09/19 09:06:35 eric Exp $ */ +/* $OpenBSD: aliases.c,v 1.51 2012/09/19 10:10:30 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -41,27 +41,6 @@ static int alias_is_filename(struct expandnode *, const char *, size_t); static int alias_is_include(struct expandnode *, const char *, size_t); int -aliases_exist(objid_t mapid, char *username) -{ - struct map_alias *map_alias; - char buf[MAX_LOCALPART_SIZE]; - - xlowercase(buf, username, sizeof(buf)); - map_alias = map_lookup(mapid, buf, K_ALIAS); - if (map_alias == NULL) - return 0; - - /* XXX - for now the map API always allocate */ - log_debug("aliases_exist: '%s' exists with %zd expansion nodes", - username, map_alias->nbnodes); - - expand_free(&map_alias->expandtree); - free(map_alias); - - return 1; -} - -int aliases_get(objid_t mapid, struct expandtree *expandtree, char *username) { struct map_alias *map_alias; @@ -94,52 +73,6 @@ aliases_get(objid_t mapid, struct expandtree *expandtree, char *username) } int -aliases_vdomain_exists(objid_t mapid, char *hostname) -{ - struct map_virtual *map_virtual; - char buf[MAXHOSTNAMELEN]; - - xlowercase(buf, hostname, sizeof(buf)); - map_virtual = map_lookup(mapid, buf, K_VIRTUAL); - if (map_virtual == NULL) - return 0; - - /* XXX - for now the map API always allocate */ - log_debug("aliases_vdomain_exist: '%s' exists", hostname); - expand_free(&map_virtual->expandtree); - free(map_virtual); - - return 1; -} - -int -aliases_virtual_exist(objid_t mapid, struct mailaddr *maddr) -{ - struct map_virtual *map_virtual; - char buf[MAX_LINE_SIZE]; - char *pbuf = buf; - - if (! bsnprintf(buf, sizeof(buf), "%s@%s", maddr->user, - maddr->domain)) - return 0; - xlowercase(buf, buf, sizeof(buf)); - - map_virtual = map_lookup(mapid, buf, K_VIRTUAL); - if (map_virtual == NULL) { - pbuf = strchr(buf, '@'); - map_virtual = map_lookup(mapid, pbuf, K_VIRTUAL); - } - if (map_virtual == NULL) - return 0; - - log_debug("aliases_virtual_exist: '%s' exists", pbuf); - expand_free(&map_virtual->expandtree); - free(map_virtual); - - return 1; -} - -int aliases_virtual_get(objid_t mapid, struct expandtree *expandtree, struct mailaddr *maddr) { @@ -181,6 +114,25 @@ aliases_virtual_get(objid_t mapid, struct expandtree *expandtree, return nbaliases; } +int +aliases_vdomain_exists(objid_t mapid, char *hostname) +{ + struct map_virtual *map_virtual; + char buf[MAXHOSTNAMELEN]; + + xlowercase(buf, hostname, sizeof(buf)); + map_virtual = map_lookup(mapid, buf, K_VIRTUAL); + if (map_virtual == NULL) + return 0; + + /* XXX - for now the map API always allocate */ + log_debug("aliases_vdomain_exist: '%s' exists", hostname); + expand_free(&map_virtual->expandtree); + free(map_virtual); + + return 1; +} + static int aliases_expand_include(struct expandtree *expandtree, const char *filename) { diff --git a/usr.sbin/smtpd/lka_session.c b/usr.sbin/smtpd/lka_session.c index 4c31b28a0e9..b26fbfdf987 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.28 2012/09/19 09:06:35 eric Exp $ */ +/* $OpenBSD: lka_session.c,v 1.29 2012/09/19 10:10:30 eric Exp $ */ /* * Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org> @@ -107,13 +107,8 @@ lka_session_envelope_expand(struct lka_session *lks, struct envelope *ep) tag++; } - if (aliases_exist(ep->rule.r_amap, username)) { - if (! aliases_get(ep->rule.r_amap, - &lks->expandtree, username)) { - return 0; - } + if (aliases_get(ep->rule.r_amap, &lks->expandtree, username)) return 1; - } bzero(&u, sizeof (u)); ub = user_backend_lookup(USER_PWD); @@ -155,12 +150,10 @@ lka_session_envelope_expand(struct lka_session *lks, struct envelope *ep) return 1; case C_VDOM: - if (aliases_virtual_exist(ep->rule.r_condition.c_map, &ep->dest)) { - if (! aliases_virtual_get(ep->rule.r_condition.c_map, - &lks->expandtree, &ep->dest)) - return 0; + if (aliases_virtual_get(ep->rule.r_condition.c_map, + &lks->expandtree, &ep->dest)) return 1; - } + return 0; default: diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h index a19ea91328c..c6657d5e5b7 100644 --- a/usr.sbin/smtpd/smtpd.h +++ b/usr.sbin/smtpd/smtpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.h,v 1.357 2012/09/19 09:06:35 eric Exp $ */ +/* $OpenBSD: smtpd.h,v 1.358 2012/09/19 10:10:30 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -931,11 +931,9 @@ extern void (*imsg_callback)(struct imsgev *, struct imsg *); /* aliases.c */ -int aliases_exist(objid_t, char *); int aliases_get(objid_t, struct expandtree *, char *); -int aliases_vdomain_exists(objid_t, char *); -int aliases_virtual_exist(objid_t, struct mailaddr *); int aliases_virtual_get(objid_t, struct expandtree *, struct mailaddr *); +int aliases_vdomain_exists(objid_t, char *); int alias_parse(struct expandnode *, char *); |