diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2009-10-12 18:19:47 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2009-10-12 18:19:47 +0000 |
commit | 4c85db8b5736693bd819a09987f0dc89a9f1c24d (patch) | |
tree | 52720f2d03c22df54feaebfdb7a33f45399b9bf7 | |
parent | 8c6e2facbc71f7315f683084309517df13be135a (diff) |
to support virtual domains properly, smtpd needed to have the domain stored
as a key in the virtual map, which means that to support virtual domain for
openbsd.org I would do:
openbsd.org whatevervalue
gilles@openbsd.org gilles
this commit teaches makemap how to deduce the special domain keys based on
the entries for that domain, so that only the second line is needed now.
-rw-r--r-- | usr.sbin/smtpd/makemap.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/usr.sbin/smtpd/makemap.c b/usr.sbin/smtpd/makemap.c index bb940aff167..4291d5033f3 100644 --- a/usr.sbin/smtpd/makemap.c +++ b/usr.sbin/smtpd/makemap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: makemap.c,v 1.20 2009/08/08 00:02:22 gilles Exp $ */ +/* $OpenBSD: makemap.c,v 1.21 2009/10/12 18:19:46 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -221,8 +221,11 @@ parse_entry(char *line, size_t len, size_t lineno) { DBT key; DBT val; + DBT domkey; + DBT domval; char *keyp; char *valp; + char *domp; keyp = line; while (isspace((int)*keyp)) @@ -259,6 +262,22 @@ parse_entry(char *line, size_t len, size_t lineno) warn("dbput"); return 0; } + + /* add key for domain */ + if ((domp = strrchr(key.data, '@')) != NULL) { + domkey.data = domp + 1; + domkey.size = strlen(domkey.data) + 1; + + domval.data = "<empty>"; + domval.size = strlen(domval.data) + 1; + + if (db->put(db, &domkey, &domval, 0) == -1) { + warn("dbput"); + return 0; + } + } + + dbputs++; free(val.data); |