summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2012-10-13 09:44:26 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2012-10-13 09:44:26 +0000
commit636bef3bc0e8f59d2441b731e132a5fdcbc9b2be (patch)
tree86ab6e1ddf056eee7e8f036ef0ef2734cbf8ac0c /usr.sbin/smtpd
parent2a3cfe2b5dd297f5d3114dae73ae8d06c9399dda (diff)
when makemap is executed in sendmail mode, check if ".db" is part of the
filename and imply it otherwise so that the following works: makemap hash /etc/mail/aliases < aliases
Diffstat (limited to 'usr.sbin/smtpd')
-rw-r--r--usr.sbin/smtpd/makemap.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/usr.sbin/smtpd/makemap.c b/usr.sbin/smtpd/makemap.c
index 3651875be93..746c9216e4b 100644
--- a/usr.sbin/smtpd/makemap.c
+++ b/usr.sbin/smtpd/makemap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: makemap.c,v 1.39 2012/10/08 19:45:11 gilles Exp $ */
+/* $OpenBSD: makemap.c,v 1.40 2012/10/13 09:44:25 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -97,6 +97,7 @@ main(int argc, char *argv[])
DBTYPE dbtype = DB_HASH;
struct smtpd smtpd;
char *execname;
+ char *p;
env = &smtpd;
@@ -147,7 +148,18 @@ main(int argc, char *argv[])
if (argc == 2) {
if (oflag)
usage();
- execlp(execname, execname, "-d", argv[0], "-o", argv[1], "-", NULL);
+
+ p = strstr(argv[1], ".db");
+ if (p == NULL || strcmp(p, ".db") != 0) {
+ if (! bsnprintf(dbname, sizeof dbname, "%s.db", argv[1]))
+ errx(1, "database name too long");
+ }
+ else {
+ if (strlcpy(dbname, argv[1], sizeof dbname) >= sizeof dbname)
+ errx(1, "database name too long");
+ }
+
+ execlp(execname, execname, "-d", argv[0], "-o", dbname, "-", NULL);
err(1, "execlp");
}