summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunil Nimmagadda <sunil@cvs.openbsd.org>2017-07-27 18:48:31 +0000
committerSunil Nimmagadda <sunil@cvs.openbsd.org>2017-07-27 18:48:31 +0000
commit50683ab5860858cee8f0fb938a9b5bf01f2a4d93 (patch)
tree2afbb33d33caec160ab452194e22f5603d13dd22
parent6ef77a9f70fa12d91578727533caa7172e17461d (diff)
smtpctl(8): Use an int to determine mode instead of __progname.
Ok millert@ gilles@
-rw-r--r--usr.sbin/smtpd/makemap.c19
-rw-r--r--usr.sbin/smtpd/smtpctl.c15
-rw-r--r--usr.sbin/smtpd/smtpd.h7
3 files changed, 19 insertions, 22 deletions
diff --git a/usr.sbin/smtpd/makemap.c b/usr.sbin/smtpd/makemap.c
index af24a8c0ade..8f32e766fd2 100644
--- a/usr.sbin/smtpd/makemap.c
+++ b/usr.sbin/smtpd/makemap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: makemap.c,v 1.66 2017/01/09 09:53:23 reyk Exp $ */
+/* $OpenBSD: makemap.c,v 1.67 2017/07/27 18:48:30 sunil Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -55,12 +55,7 @@ static int dump_db(const char *, DBTYPE);
struct smtpd smtpd;
struct smtpd *env = &smtpd;
char *source;
-extern char *__progname;
-
-enum program {
- P_MAKEMAP,
- P_NEWALIASES
-} mode;
+static int mode;
enum output_type {
T_PLAIN,
@@ -84,7 +79,7 @@ fork_proc_backend(const char *backend, const char *conf, const char *procname)
}
int
-makemap(int argc, char *argv[])
+makemap(int prog_mode, int argc, char *argv[])
{
struct stat sb;
char dbname[PATH_MAX];
@@ -98,7 +93,7 @@ makemap(int argc, char *argv[])
log_init(1, LOG_MAIL);
- mode = strcmp(__progname, "newaliases") ? P_MAKEMAP : P_NEWALIASES;
+ mode = prog_mode;
conf = CONF_FILE;
type = T_PLAIN;
opts = "b:C:d:ho:O:t:U";
@@ -501,9 +496,9 @@ static void
usage(void)
{
if (mode == P_NEWALIASES)
- fprintf(stderr, "usage: %s [-f file]\n", __progname);
+ fprintf(stderr, "usage: newaliases [-f file]\n");
else
- fprintf(stderr, "usage: %s [-U] [-d dbtype] [-o dbfile] "
- "[-t type] file\n", __progname);
+ fprintf(stderr, "usage: makemap [-U] [-d dbtype] [-o dbfile] "
+ "[-t type] file\n");
exit(1);
}
diff --git a/usr.sbin/smtpd/smtpctl.c b/usr.sbin/smtpd/smtpctl.c
index 63dace2305a..bd85863267c 100644
--- a/usr.sbin/smtpd/smtpctl.c
+++ b/usr.sbin/smtpd/smtpctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpctl.c,v 1.153 2017/05/19 19:56:42 eric Exp $ */
+/* $OpenBSD: smtpctl.c,v 1.154 2017/07/27 18:48:30 sunil Exp $ */
/*
* Copyright (c) 2013 Eric Faurot <eric@openbsd.org>
@@ -1096,10 +1096,8 @@ sendmail_compat(int argc, char **argv)
* that should invoke makemap/newaliases.
*/
for (i = 1; i < argc; i++)
- if (strncmp(argv[i], "-bi", 3) == 0) {
- __progname = "newaliases";
- exit(makemap(argc, argv));
- }
+ if (strncmp(argv[i], "-bi", 3) == 0)
+ exit(makemap(P_NEWALIASES, argc, argv));
if (!srv_connect())
offlinefp = offline_file();
@@ -1115,9 +1113,10 @@ sendmail_compat(int argc, char **argv)
sendmail = 1;
exit(enqueue(argc, argv, offlinefp));
- } else if (strcmp(__progname, "makemap") == 0 ||
- strcmp(__progname, "newaliases") == 0)
- exit(makemap(argc, argv));
+ } else if (strcmp(__progname, "makemap") == 0)
+ exit(makemap(P_MAKEMAP, argc, argv));
+ else if (strcmp(__progname, "newaliases") == 0)
+ exit(makemap(P_NEWALIASES, argc, argv));
}
static void
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index f158efa73d5..4474f44727a 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.532 2017/05/26 21:30:00 gilles Exp $ */
+/* $OpenBSD: smtpd.h,v 1.533 2017/07/27 18:48:30 sunil Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -104,6 +104,9 @@
#define MTA_EXT_DSN 0x400
+#define P_NEWALIASES 0
+#define P_MAKEMAP 1
+
struct userinfo {
char username[SMTPD_VUSERNAME_SIZE];
char directory[PATH_MAX];
@@ -1254,7 +1257,7 @@ size_t mda_expand_format(char *, size_t, const struct envelope *,
/* makemap.c */
-int makemap(int, char **);
+int makemap(int, int, char **);
/* mailaddr.c */