summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunil Nimmagadda <sunil@cvs.openbsd.org>2015-12-07 12:29:20 +0000
committerSunil Nimmagadda <sunil@cvs.openbsd.org>2015-12-07 12:29:20 +0000
commit4a2b40e7dfab3646c05067881f04910e3607ba80 (patch)
treec953816d6ec99959d9de5371ea9f488edcba68f2
parent6881863d0638e2cd9f7c12d49f77c398683d5967 (diff)
Merge makemap(8) into smtpctl(8).
Ok gilles@, jung@
-rw-r--r--usr.sbin/smtpd/Makefile3
-rw-r--r--usr.sbin/smtpd/enqueue.c10
-rw-r--r--usr.sbin/smtpd/makemap.c39
-rw-r--r--usr.sbin/smtpd/makemap/Makefile41
-rw-r--r--usr.sbin/smtpd/smtpctl.c18
-rw-r--r--usr.sbin/smtpd/smtpctl/Makefile12
-rw-r--r--usr.sbin/smtpd/smtpd.h4
7 files changed, 48 insertions, 79 deletions
diff --git a/usr.sbin/smtpd/Makefile b/usr.sbin/smtpd/Makefile
index eb429a6bb1f..b0a347d8857 100644
--- a/usr.sbin/smtpd/Makefile
+++ b/usr.sbin/smtpd/Makefile
@@ -1,9 +1,8 @@
-# $OpenBSD: Makefile,v 1.14 2015/11/30 19:54:25 jung Exp $
+# $OpenBSD: Makefile,v 1.15 2015/12/07 12:29:19 sunil Exp $
.include <bsd.own.mk>
SUBDIR = smtpd
SUBDIR+= smtpctl
-SUBDIR+= makemap
.include <bsd.subdir.mk>
diff --git a/usr.sbin/smtpd/enqueue.c b/usr.sbin/smtpd/enqueue.c
index 16838aeb20c..1bc3752e338 100644
--- a/usr.sbin/smtpd/enqueue.c
+++ b/usr.sbin/smtpd/enqueue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: enqueue.c,v 1.106 2015/12/05 13:14:21 claudio Exp $ */
+/* $OpenBSD: enqueue.c,v 1.107 2015/12/07 12:29:19 sunil Exp $ */
/*
* Copyright (c) 2005 Henning Brauer <henning@bulabula.org>
@@ -99,10 +99,10 @@ struct {
#define WSP(c) (c == ' ' || c == '\t')
-int verbose = 0;
-char host[HOST_NAME_MAX+1];
-char *user = NULL;
-time_t timestamp;
+int verbose = 0;
+static char host[HOST_NAME_MAX+1];
+char *user = NULL;
+time_t timestamp;
struct {
int fd;
diff --git a/usr.sbin/smtpd/makemap.c b/usr.sbin/smtpd/makemap.c
index bd6e1acc8d1..f48891be924 100644
--- a/usr.sbin/smtpd/makemap.c
+++ b/usr.sbin/smtpd/makemap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: makemap.c,v 1.56 2015/10/26 16:38:06 sunil Exp $ */
+/* $OpenBSD: makemap.c,v 1.57 2015/12/07 12:29:19 sunil Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -42,16 +42,14 @@
#define PATH_ALIASES "/etc/mail/aliases"
-extern char *__progname;
-
-__dead void usage(void);
-static int parse_map(char *);
-static int parse_entry(char *, size_t, size_t);
-static int parse_mapentry(char *, size_t, size_t);
-static int parse_setentry(char *, size_t, size_t);
-static int make_plain(DBT *, char *);
-static int make_aliases(DBT *, char *);
-static char *conf_aliases(char *);
+static void usage(void);
+static int parse_map(char *);
+static int parse_entry(char *, size_t, size_t);
+static int parse_mapentry(char *, size_t, size_t);
+static int parse_setentry(char *, size_t, size_t);
+static int make_plain(DBT *, char *);
+static int make_aliases(DBT *, char *);
+static char *conf_aliases(char *);
DB *db;
char *source;
@@ -60,6 +58,7 @@ int dbputs;
struct smtpd smtpd;
struct smtpd *env = &smtpd;
+extern char *__progname;
enum program {
P_MAKEMAP,
@@ -88,7 +87,7 @@ fork_proc_backend(const char *backend, const char *conf, const char *procname)
}
int
-main(int argc, char *argv[])
+makemap(int argc, char *argv[])
{
struct stat sb;
char dbname[PATH_MAX];
@@ -225,7 +224,7 @@ bad:
return 1;
}
-int
+static int
parse_map(char *filename)
{
FILE *fp;
@@ -265,7 +264,7 @@ parse_map(char *filename)
return 1;
}
-int
+static int
parse_entry(char *line, size_t len, size_t lineno)
{
switch (type) {
@@ -278,7 +277,7 @@ parse_entry(char *line, size_t len, size_t lineno)
return 0;
}
-int
+static int
parse_mapentry(char *line, size_t len, size_t lineno)
{
DBT key;
@@ -336,7 +335,7 @@ bad:
return 0;
}
-int
+static int
parse_setentry(char *line, size_t len, size_t lineno)
{
DBT key;
@@ -371,7 +370,7 @@ parse_setentry(char *line, size_t len, size_t lineno)
return 1;
}
-int
+static int
make_plain(DBT *val, char *text)
{
val->data = xstrdup(text, "make_plain");
@@ -380,7 +379,7 @@ make_plain(DBT *val, char *text)
return (val->size);
}
-int
+static int
make_aliases(DBT *val, char *text)
{
struct expandnode xn;
@@ -412,7 +411,7 @@ error:
return 0;
}
-char *
+static char *
conf_aliases(char *cfgpath)
{
struct table *table;
@@ -435,7 +434,7 @@ conf_aliases(char *cfgpath)
return (path);
}
-void
+static void
usage(void)
{
if (mode == P_NEWALIASES)
diff --git a/usr.sbin/smtpd/makemap/Makefile b/usr.sbin/smtpd/makemap/Makefile
deleted file mode 100644
index dc7995cc1cd..00000000000
--- a/usr.sbin/smtpd/makemap/Makefile
+++ /dev/null
@@ -1,41 +0,0 @@
-# $OpenBSD: Makefile,v 1.27 2015/12/01 09:54:52 gilles Exp $
-
-.PATH: ${.CURDIR}/..
-
-PROG= makemap
-BINOWN= root
-
-BINMODE?=555
-
-BINDIR= /usr/libexec/smtpd
-MAN= aliases.5 forward.5 makemap.8 newaliases.8
-
-CFLAGS+= -fstack-protector-all
-CFLAGS+= -I${.CURDIR}/..
-CFLAGS+= -Wall -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS+= -Wmissing-declarations
-CFLAGS+= -Wshadow -Wpointer-arith -Wcast-qual
-CFLAGS+= -Wsign-compare
-CFLAGS+= -DNO_IO
-
-SRCS= aliases.c
-SRCS+= dict.c
-SRCS+= expand.c
-SRCS+= limit.c
-SRCS+= log.c
-SRCS+= makemap.c
-SRCS+= parse.y
-SRCS+= mailaddr.c
-SRCS+= table.c
-SRCS+= to.c
-SRCS+= tree.c
-SRCS+= util.c
-
-SRCS+= table_static.c
-SRCS+= table_db.c
-SRCS+= table_getpwnam.c
-SRCS+= table_proc.c
-
-DPADD+= ${LIBUTIL} ${LIBCRYPTO} ${LIBZ}
-LDADD+= -lutil -lcrypto -lz
-.include <bsd.prog.mk>
diff --git a/usr.sbin/smtpd/smtpctl.c b/usr.sbin/smtpd/smtpctl.c
index c3f1df5712b..e5414340bf5 100644
--- a/usr.sbin/smtpd/smtpctl.c
+++ b/usr.sbin/smtpd/smtpctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpctl.c,v 1.137 2015/12/05 13:14:21 claudio Exp $ */
+/* $OpenBSD: smtpctl.c,v 1.138 2015/12/07 12:29:19 sunil Exp $ */
/*
* Copyright (c) 2013 Eric Faurot <eric@openbsd.org>
@@ -84,8 +84,6 @@ struct queue_backend queue_backend_ram;
__dead void
usage(void)
{
- extern char *__progname;
-
if (sendmail)
fprintf(stderr, "usage: %s [-tv] [-f from] [-F name] to ...\n",
__progname);
@@ -937,7 +935,7 @@ do_discover(int argc, struct parameter *argv)
srv_read(&n_evp, sizeof n_evp);
srv_end();
}
-
+
printf("%zu envelope%s discovered\n", n_evp, (n_evp != 1) ? "s" : "");
return (0);
}
@@ -987,10 +985,12 @@ main(int argc, char **argv)
if (pledge("stdio rpath wpath cpath tmppath flock "
"dns getpw recvfd", NULL) == -1)
err(1, "pledge");
-
+
sendmail = 1;
return (enqueue(argc, argv, offlinefp));
- }
+ } else if (strcmp(__progname, "makemap") == 0 ||
+ strcmp(__progname, "newaliases") == 0)
+ return makemap(argc, argv);
if (geteuid())
errx(1, "need root privileges");
@@ -1075,8 +1075,8 @@ show_queue_envelope(struct envelope *e, int online)
(void)snprintf(runstate, sizeof runstate, "pending|%zd",
(ssize_t)(e->nexttry - now));
else if (e->flags & EF_INFLIGHT)
- (void)snprintf(runstate, sizeof runstate, "inflight|%zd",
- (ssize_t)(now - e->lasttry));
+ (void)snprintf(runstate, sizeof runstate,
+ "inflight|%zd", (ssize_t)(now - e->lasttry));
else
(void)snprintf(runstate, sizeof runstate, "invalid|");
e->flags &= ~(EF_PENDING|EF_INFLIGHT);
@@ -1330,7 +1330,7 @@ static int
is_encrypted_fp(FILE *fp)
{
uint8_t magic;
- int ret = 0;
+ int ret = 0;
if (fread(&magic, 1, sizeof magic, fp) != sizeof magic)
goto end;
diff --git a/usr.sbin/smtpd/smtpctl/Makefile b/usr.sbin/smtpd/smtpctl/Makefile
index 7f9f8a43dbf..bf65eb110a0 100644
--- a/usr.sbin/smtpd/smtpctl/Makefile
+++ b/usr.sbin/smtpd/smtpctl/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.40 2015/12/01 09:58:38 gilles Exp $
+# $OpenBSD: Makefile,v 1.41 2015/12/07 12:29:19 sunil Exp $
.PATH: ${.CURDIR}/..
@@ -35,6 +35,16 @@ SRCS+= to.c
SRCS+= expand.c
SRCS+= tree.c
SRCS+= dict.c
+SRCS+= aliases.c
+SRCS+= limit.c
+SRCS+= makemap.c
+SRCS+= parse.y
+SRCS+= mailaddr.c
+SRCS+= table.c
+SRCS+= table_static.c
+SRCS+= table_db.c
+SRCS+= table_getpwnam.c
+SRCS+= table_proc.c
LDADD+= -lutil -lz -lcrypto
DPADD+= ${LIBUTIL} ${LIBZ} ${LIBCRYPTO}
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index b37d44e623b..f215ec6a371 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.493 2015/12/03 21:11:33 jung Exp $ */
+/* $OpenBSD: smtpd.h,v 1.494 2015/12/07 12:29:19 sunil Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -1219,6 +1219,8 @@ void mda_postfork(void);
void mda_postprivdrop(void);
void mda_imsg(struct mproc *, struct imsg *);
+/* makemap.c */
+int makemap(int, char **);
/* mailaddr.c */
int mailaddr_line(struct maddrmap *, const char *);