summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/aliases.c
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2009-10-11 17:40:50 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2009-10-11 17:40:50 +0000
commitac4fcac1a4ee0d67b58fae11859cb103d8785252 (patch)
tree3f489733493fd73de52728cd246b621dbbdb8242 /usr.sbin/smtpd/aliases.c
parent09b79addbc2f9597ca0b01c274381ccab6c9e35f (diff)
implement proper virtual domains instead of faking them on top of primary
domains. this means that: - virtual domains no longer deliver to a local user when not told to - they no longer attempt to resolve aliases when not told to - they no longer need an explicit rule in smtpd.conf for EACH domain - the "virtual" map is no longer hardcoded - smtpd no longer needs a restart to support a new domain instead we introduce the: accept for virtual map "mapname" [...] syntax which refers to a map that can be manipulated at runtime. idea discussed and okayd with jacekm@
Diffstat (limited to 'usr.sbin/smtpd/aliases.c')
-rw-r--r--usr.sbin/smtpd/aliases.c51
1 files changed, 37 insertions, 14 deletions
diff --git a/usr.sbin/smtpd/aliases.c b/usr.sbin/smtpd/aliases.c
index 3427ce4bb2e..99aa40b03af 100644
--- a/usr.sbin/smtpd/aliases.c
+++ b/usr.sbin/smtpd/aliases.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aliases.c,v 1.19 2009/08/08 00:02:22 gilles Exp $ */
+/* $OpenBSD: aliases.c,v 1.20 2009/10/11 17:40:49 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -136,19 +136,47 @@ aliases_get(struct smtpd *env, struct aliaseslist *aliases, char *username)
}
int
-aliases_virtual_exist(struct smtpd *env, struct path *path)
+aliases_vdomain_exists(struct smtpd *env, struct map *map, char *hostname)
+{
+ int ret;
+ DBT key;
+ DBT val;
+ DB *vtable;
+ char strkey[MAX_LINE_SIZE];
+
+ vtable = dbopen(map->m_config, O_RDONLY, 0600, DB_HASH, NULL);
+ if (vtable == NULL) {
+ log_warn("aliases_vdomain_exists: dbopen");
+ return 0;
+ }
+
+ if (! bsnprintf(strkey, sizeof(strkey), "%s", hostname)) {
+ vtable->close(vtable);
+ return 0;
+ }
+ lowercase(strkey, strkey, sizeof(strkey));
+
+ key.data = strkey;
+ key.size = strlen(key.data) + 1;
+
+ ret = vtable->get(vtable, &key, &val, 0);
+ if (ret == -1)
+ log_warn("aliases_vdomain_exists");
+
+ vtable->close(vtable);
+
+ return (ret == 0);
+}
+
+int
+aliases_virtual_exist(struct smtpd *env, struct map *map, struct path *path)
{
int ret;
DBT key;
DBT val;
DB *aliasesdb;
- struct map *map;
char strkey[MAX_LINE_SIZE];
- map = map_findbyname(env, "virtual");
- if (map == NULL)
- return 0;
-
aliasesdb = dbopen(map->m_config, O_RDONLY, 0600, DB_HASH, NULL);
if (aliasesdb == NULL) {
log_warn("aliases_virtual_exist: dbopen");
@@ -190,8 +218,8 @@ aliases_virtual_exist(struct smtpd *env, struct path *path)
}
int
-aliases_virtual_get(struct smtpd *env, struct aliaseslist *aliases,
- struct path *path)
+aliases_virtual_get(struct smtpd *env, struct map *map,
+ struct aliaseslist *aliases, struct path *path)
{
int ret;
DBT key;
@@ -201,13 +229,8 @@ aliases_virtual_get(struct smtpd *env, struct aliaseslist *aliases,
struct alias alias;
struct alias *aliasp;
struct alias *nextalias;
- struct map *map;
char strkey[MAX_LINE_SIZE];
- map = map_findbyname(env, "virtual");
- if (map == NULL)
- return 0;
-
aliasesdb = dbopen(map->m_config, O_RDONLY, 0600, DB_HASH, NULL);
if (aliasesdb == NULL) {
log_warn("aliases_virtual_get: dbopen");