diff options
author | Sunil Nimmagadda <sunil@cvs.openbsd.org> | 2015-12-21 11:20:08 +0000 |
---|---|---|
committer | Sunil Nimmagadda <sunil@cvs.openbsd.org> | 2015-12-21 11:20:08 +0000 |
commit | 8eb6fc5559f2841ce559cf73695bf43de6e2c5e5 (patch) | |
tree | 74da557e9054e623098d63634e5fd3a57300a1dd /usr.sbin/smtpd/smtpctl.c | |
parent | 1d0db0019a4e006949722bfa546baa252bf847cc (diff) |
Start accepting some sendmail compatible commandline arguments.
This diff teaches smtpctl to understand '-bi -O AliasFile=<path_aliases>'
and generate aliases.db.
Ok gilles@ jung@ millert@
Diffstat (limited to 'usr.sbin/smtpd/smtpctl.c')
-rw-r--r-- | usr.sbin/smtpd/smtpctl.c | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/usr.sbin/smtpd/smtpctl.c b/usr.sbin/smtpd/smtpctl.c index 80c1b5e9f55..6db7f102b08 100644 --- a/usr.sbin/smtpd/smtpctl.c +++ b/usr.sbin/smtpd/smtpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpctl.c,v 1.140 2015/12/11 07:30:24 gilles Exp $ */ +/* $OpenBSD: smtpctl.c,v 1.141 2015/12/21 11:20:07 sunil Exp $ */ /* * Copyright (c) 2013 Eric Faurot <eric@openbsd.org> @@ -976,13 +976,52 @@ do_uncorrupt(int argc, struct parameter *argv) int main(int argc, char **argv) { + arglist args; gid_t gid; char *argv_mailq[] = { "show", "queue", NULL }; + char *aliases_path = NULL, *p; FILE *offlinefp = NULL; + int ch, i, sendmail_makemap = 0; gid = getgid(); if (strcmp(__progname, "sendmail") == 0 || strcmp(__progname, "send-mail") == 0) { + /* + * determine whether we are called with flags + * that should invoke makemap/newaliases. + */ + while ((ch = getopt(argc, argv, "b:C:O:")) != -1) { + switch (ch) { + case 'b': + if (strcmp(optarg, "i") == 0) + sendmail_makemap = 1; + break; + case 'C': + break; /* compatibility, not required */ + case 'O': + if (strncmp(optarg, "AliasFile=", 10) != 0) + break; + p = strchr(optarg, '='); + aliases_path = ++p; + break; + } + } + argc -= optind; + argv += optind; + optind = 0; + if (sendmail_makemap) { + memset(&args, 0, sizeof args); + addargs(&args, "%s", "makemap"); + for (i = 0; i < argc; i++) + addargs(&args, "%s", argv[i]); + + addargs(&args, "%s", "-taliases"); + if (aliases_path) + addargs(&args, "%s", aliases_path); + + return makemap(args.num, args.list); + } + if (!srv_connect()) offlinefp = offline_file(); |