aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGilles Chehade <gilles@dalenys.com>2016-02-12 08:23:40 +0100
committerGilles Chehade <gilles@dalenys.com>2016-02-12 08:23:40 +0100
commit6142b05d07eee9cd4e45259b68b8144783933886 (patch)
tree3bc828bd40fbcc76d6bce476102aa982eaba8e05
parentMerge pull request #655 from bsdsx/solaris_check_for_af_local (diff)
parentsync with CVS: (diff)
downloadOpenSMTPD-6142b05d07eee9cd4e45259b68b8144783933886.tar.xz
OpenSMTPD-6142b05d07eee9cd4e45259b68b8144783933886.zip
Merge branch 'master' into portableopensmtpd-201602120826p1
-rw-r--r--smtpd/CVS/Entries148
-rw-r--r--smtpd/makemap.c26
-rw-r--r--smtpd/mproc.c16
-rw-r--r--smtpd/smtpctl.c107
4 files changed, 145 insertions, 152 deletions
diff --git a/smtpd/CVS/Entries b/smtpd/CVS/Entries
index 5e9e3152..ceb232f9 100644
--- a/smtpd/CVS/Entries
+++ b/smtpd/CVS/Entries
@@ -14,77 +14,77 @@ D/smtpd////
/smtpd.8/1.28/Wed Feb 3 12:14:44 2016//
/ssl.h/1.19/Wed Feb 3 12:14:44 2016//
/table.5/1.5/Wed Feb 3 12:14:44 2016//
-/aliases.c/1.69/Wed Feb 10 07:34:32 2016//
-/bounce.c/1.72/Wed Feb 10 07:34:32 2016//
-/ca.c/1.21/Wed Feb 10 07:34:32 2016//
-/compress_backend.c/1.9/Wed Feb 10 07:34:32 2016//
-/compress_gzip.c/1.10/Wed Feb 10 07:34:32 2016//
-/config.c/1.33/Wed Feb 10 07:34:32 2016//
-/control.c/1.111/Wed Feb 10 07:34:32 2016//
-/crypto.c/1.5/Wed Feb 10 07:34:32 2016//
-/delivery.c/1.6/Wed Feb 10 07:34:32 2016//
-/delivery_filename.c/1.14/Wed Feb 10 07:34:32 2016//
-/delivery_lmtp.c/1.15/Wed Feb 10 07:34:32 2016//
-/delivery_maildir.c/1.17/Wed Feb 10 07:34:32 2016//
-/delivery_mbox.c/1.12/Wed Feb 10 07:34:32 2016//
-/delivery_mda.c/1.9/Wed Feb 10 07:34:32 2016//
-/dict.c/1.5/Wed Feb 10 07:34:32 2016//
-/dns.c/1.83/Wed Feb 10 07:34:32 2016//
-/enqueue.c/1.112/Wed Feb 10 07:34:32 2016//
-/envelope.c/1.36/Wed Feb 10 07:34:32 2016//
-/esc.c/1.4/Wed Feb 10 07:34:32 2016//
-/expand.c/1.29/Wed Feb 10 07:34:32 2016//
-/filter.c/1.16/Wed Feb 10 07:34:32 2016//
-/forward.c/1.39/Wed Feb 10 07:34:32 2016//
-/iobuf.c/1.9/Wed Feb 10 07:34:32 2016//
-/ioev.c/1.24/Wed Feb 10 07:34:32 2016//
-/limit.c/1.4/Wed Feb 10 07:34:32 2016//
-/lka.c/1.192/Wed Feb 10 07:34:32 2016//
-/lka_session.c/1.79/Wed Feb 10 07:34:32 2016//
-/log.c/1.17/Wed Feb 10 07:34:32 2016//
-/log.h/1.5/Wed Feb 10 07:34:32 2016//
-/mailaddr.c/1.2/Wed Feb 10 07:34:32 2016//
-/makemap.c/1.61/Wed Feb 10 07:34:32 2016//
-/mda.c/1.117/Wed Feb 10 07:34:32 2016//
-/mproc.c/1.17/Wed Feb 10 07:34:32 2016//
-/mta.c/1.200/Wed Feb 10 07:34:33 2016//
-/mta_session.c/1.82/Wed Feb 10 07:34:33 2016//
-/parse.y/1.181/Wed Feb 10 07:34:33 2016//
-/parser.c/1.40/Wed Feb 10 07:34:33 2016//
-/pony.c/1.12/Wed Feb 10 07:34:33 2016//
-/queue.c/1.176/Wed Feb 10 07:34:33 2016//
-/queue_backend.c/1.62/Wed Feb 10 07:34:33 2016//
-/queue_fs.c/1.14/Wed Feb 10 07:34:33 2016//
-/queue_null.c/1.6/Wed Feb 10 07:34:33 2016//
-/queue_proc.c/1.6/Wed Feb 10 07:34:33 2016//
-/queue_ram.c/1.7/Wed Feb 10 07:34:33 2016//
-/rfc2822.c/1.7/Wed Feb 10 07:34:33 2016//
-/ruleset.c/1.32/Wed Feb 10 07:34:33 2016//
-/runq.c/1.2/Wed Feb 10 07:34:33 2016//
-/scheduler.c/1.51/Wed Feb 10 07:34:33 2016//
-/scheduler_backend.c/1.15/Wed Feb 10 07:34:33 2016//
-/scheduler_null.c/1.9/Wed Feb 10 07:34:33 2016//
-/scheduler_proc.c/1.8/Wed Feb 10 07:34:33 2016//
-/scheduler_ramqueue.c/1.42/Wed Feb 10 07:34:33 2016//
-/smtp.c/1.152/Wed Feb 10 07:34:33 2016//
-/smtp_session.c/1.268/Wed Feb 10 07:34:33 2016//
-/smtpctl.c/1.146/Wed Feb 10 07:34:33 2016//
-/smtpd-api.h/1.29/Wed Feb 10 07:34:53 2016//
-/smtpd-defines.h/1.6/Wed Feb 10 07:34:33 2016//
-/smtpd.c/1.274/Wed Feb 10 07:34:33 2016//
-/smtpd.conf.5/1.153/Wed Feb 10 07:34:33 2016//
-/smtpd.h/1.511/Wed Feb 10 07:34:33 2016//
-/ssl.c/1.85/Wed Feb 10 07:34:33 2016//
-/ssl_smtpd.c/1.13/Wed Feb 10 07:34:33 2016//
-/stat_backend.c/1.10/Wed Feb 10 07:34:33 2016//
-/stat_ramstat.c/1.10/Wed Feb 10 07:34:33 2016//
-/table.c/1.23/Wed Feb 10 07:34:33 2016//
-/table_api.c/1.8/Wed Feb 10 07:34:33 2016//
-/table_db.c/1.9/Wed Feb 10 07:34:33 2016//
-/table_getpwnam.c/1.4/Wed Feb 10 07:34:33 2016//
-/table_proc.c/1.6/Wed Feb 10 07:34:33 2016//
-/table_static.c/1.15/Wed Feb 10 07:34:33 2016//
-/to.c/1.24/Wed Feb 10 07:34:33 2016//
-/tree.c/1.5/Wed Feb 10 07:34:33 2016//
-/util.c/1.125/Wed Feb 10 07:34:33 2016//
-/waitq.c/1.5/Wed Feb 10 07:34:33 2016//
+/aliases.c/1.69/Fri Feb 12 07:22:06 2016//
+/bounce.c/1.72/Fri Feb 12 07:22:06 2016//
+/ca.c/1.21/Fri Feb 12 07:22:06 2016//
+/compress_backend.c/1.9/Fri Feb 12 07:22:06 2016//
+/compress_gzip.c/1.10/Fri Feb 12 07:22:06 2016//
+/config.c/1.33/Fri Feb 12 07:22:06 2016//
+/control.c/1.111/Fri Feb 12 07:22:06 2016//
+/crypto.c/1.5/Fri Feb 12 07:22:06 2016//
+/delivery.c/1.6/Fri Feb 12 07:22:06 2016//
+/delivery_filename.c/1.14/Fri Feb 12 07:22:06 2016//
+/delivery_lmtp.c/1.15/Fri Feb 12 07:22:06 2016//
+/delivery_maildir.c/1.17/Fri Feb 12 07:22:06 2016//
+/delivery_mbox.c/1.12/Fri Feb 12 07:22:06 2016//
+/delivery_mda.c/1.9/Fri Feb 12 07:22:06 2016//
+/dict.c/1.5/Fri Feb 12 07:22:06 2016//
+/dns.c/1.83/Fri Feb 12 07:22:06 2016//
+/enqueue.c/1.112/Fri Feb 12 07:22:06 2016//
+/envelope.c/1.36/Fri Feb 12 07:22:06 2016//
+/esc.c/1.4/Fri Feb 12 07:22:06 2016//
+/expand.c/1.29/Fri Feb 12 07:22:06 2016//
+/filter.c/1.16/Fri Feb 12 07:22:06 2016//
+/forward.c/1.39/Fri Feb 12 07:22:06 2016//
+/iobuf.c/1.9/Fri Feb 12 07:22:06 2016//
+/ioev.c/1.24/Fri Feb 12 07:22:06 2016//
+/limit.c/1.4/Fri Feb 12 07:22:06 2016//
+/lka.c/1.192/Fri Feb 12 07:22:06 2016//
+/lka_session.c/1.79/Fri Feb 12 07:22:06 2016//
+/log.c/1.17/Fri Feb 12 07:22:06 2016//
+/log.h/1.5/Fri Feb 12 07:22:06 2016//
+/mailaddr.c/1.2/Fri Feb 12 07:22:06 2016//
+/makemap.c/1.63/Fri Feb 12 07:22:32 2016//
+/mda.c/1.117/Fri Feb 12 07:22:06 2016//
+/mproc.c/1.18/Fri Feb 12 07:22:32 2016//
+/mta.c/1.200/Fri Feb 12 07:22:06 2016//
+/mta_session.c/1.82/Fri Feb 12 07:22:06 2016//
+/parse.y/1.181/Fri Feb 12 07:22:06 2016//
+/parser.c/1.40/Fri Feb 12 07:22:07 2016//
+/pony.c/1.12/Fri Feb 12 07:22:07 2016//
+/queue.c/1.176/Fri Feb 12 07:22:07 2016//
+/queue_backend.c/1.62/Fri Feb 12 07:22:07 2016//
+/queue_fs.c/1.14/Fri Feb 12 07:22:07 2016//
+/queue_null.c/1.6/Fri Feb 12 07:22:07 2016//
+/queue_proc.c/1.6/Fri Feb 12 07:22:07 2016//
+/queue_ram.c/1.7/Fri Feb 12 07:22:07 2016//
+/rfc2822.c/1.7/Fri Feb 12 07:22:07 2016//
+/ruleset.c/1.32/Fri Feb 12 07:22:07 2016//
+/runq.c/1.2/Fri Feb 12 07:22:07 2016//
+/scheduler.c/1.51/Fri Feb 12 07:22:07 2016//
+/scheduler_backend.c/1.15/Fri Feb 12 07:22:07 2016//
+/scheduler_null.c/1.9/Fri Feb 12 07:22:07 2016//
+/scheduler_proc.c/1.8/Fri Feb 12 07:22:07 2016//
+/scheduler_ramqueue.c/1.42/Fri Feb 12 07:22:07 2016//
+/smtp.c/1.152/Fri Feb 12 07:22:07 2016//
+/smtp_session.c/1.268/Fri Feb 12 07:22:07 2016//
+/smtpctl.c/1.147/Fri Feb 12 07:22:32 2016//
+/smtpd-api.h/1.29/Wed Feb 10 07:35:31 2016//
+/smtpd-defines.h/1.6/Fri Feb 12 07:22:07 2016//
+/smtpd.c/1.274/Fri Feb 12 07:22:07 2016//
+/smtpd.conf.5/1.153/Fri Feb 12 07:22:07 2016//
+/smtpd.h/1.511/Fri Feb 12 07:22:07 2016//
+/ssl.c/1.85/Fri Feb 12 07:22:07 2016//
+/ssl_smtpd.c/1.13/Fri Feb 12 07:22:07 2016//
+/stat_backend.c/1.10/Fri Feb 12 07:22:07 2016//
+/stat_ramstat.c/1.10/Fri Feb 12 07:22:07 2016//
+/table.c/1.23/Fri Feb 12 07:22:07 2016//
+/table_api.c/1.8/Fri Feb 12 07:22:07 2016//
+/table_db.c/1.9/Fri Feb 12 07:22:07 2016//
+/table_getpwnam.c/1.4/Fri Feb 12 07:22:07 2016//
+/table_proc.c/1.6/Fri Feb 12 07:22:07 2016//
+/table_static.c/1.15/Fri Feb 12 07:22:07 2016//
+/to.c/1.24/Fri Feb 12 07:22:07 2016//
+/tree.c/1.5/Fri Feb 12 07:22:07 2016//
+/util.c/1.125/Fri Feb 12 07:22:07 2016//
+/waitq.c/1.5/Fri Feb 12 07:22:07 2016//
diff --git a/smtpd/makemap.c b/smtpd/makemap.c
index 99f6246c..c32c146d 100644
--- a/smtpd/makemap.c
+++ b/smtpd/makemap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: makemap.c,v 1.61 2015/12/28 22:08:30 jung Exp $ */
+/* $OpenBSD: makemap.c,v 1.63 2016/02/12 03:11:16 sunil Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -66,7 +66,7 @@ static int parse_setentry(DB *, int *, char *, size_t, size_t);
static int make_plain(DBT *, char *);
static int make_aliases(DBT *, char *);
static char *conf_aliases(char *);
-static int dump_db(const char *, DBTYPE);
+static int dump_db(const char *, DBTYPE);
struct smtpd smtpd;
struct smtpd *env = &smtpd;
@@ -110,19 +110,25 @@ makemap(int argc, char *argv[])
int ch, dbputs = 0, Uflag = 0;
DBTYPE dbtype = DB_HASH;
char *p;
- int fd = -1;
+ int fd = -1;
log_init(1);
mode = strcmp(__progname, "newaliases") ? P_MAKEMAP : P_NEWALIASES;
conf = CONF_FILE;
type = T_PLAIN;
- opts = "ho:t:d:U";
+ opts = "b:C:d:ho:O:t:U";
if (mode == P_NEWALIASES)
opts = "f:h";
while ((ch = getopt(argc, argv, opts)) != -1) {
switch (ch) {
+ case 'b':
+ if (optarg && strcmp(optarg, "i") == 0)
+ mode = P_NEWALIASES;
+ break;
+ case 'C':
+ break; /* for compatibility */
case 'd':
if (strcmp(optarg, "hash") == 0)
dbtype = DB_HASH;
@@ -139,6 +145,13 @@ makemap(int argc, char *argv[])
case 'o':
oflag = optarg;
break;
+ case 'O':
+ if (strncmp(optarg, "AliasFile=", 10) != 0)
+ break;
+ type = T_ALIASES;
+ p = strchr(optarg, '=');
+ source = ++p;
+ break;
case 't':
if (strcmp(optarg, "aliases") == 0)
type = T_ALIASES;
@@ -185,7 +198,8 @@ makemap(int argc, char *argv[])
if (argc != 0)
usage();
type = T_ALIASES;
- source = conf_aliases(conf);
+ if (source == NULL)
+ source = conf_aliases(conf);
} else {
if (argc != 1)
usage();
@@ -207,7 +221,7 @@ makemap(int argc, char *argv[])
if ((fd = mkstemp(dbname)) == -1)
err(1, "mkstemp");
- db = dbopen(dbname, O_RDWR, 0644, dbtype, NULL);
+ db = dbopen(dbname, O_TRUNC|O_RDWR, 0644, dbtype, NULL);
if (db == NULL) {
warn("dbopen: %s", dbname);
goto bad;
diff --git a/smtpd/mproc.c b/smtpd/mproc.c
index 14441d5f..8d1c710f 100644
--- a/smtpd/mproc.c
+++ b/smtpd/mproc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mproc.c,v 1.17 2016/02/09 11:50:49 sunil Exp $ */
+/* $OpenBSD: mproc.c,v 1.18 2016/02/10 15:03:37 millert Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@faurot.net>
@@ -158,13 +158,15 @@ mproc_dispatch(int fd, short event, void *arg)
else
n = imsg_read(&p->imsgbuf);
- if (n == -1 && errno == EAGAIN)
- return;
- else if (n == -1) {
+ switch (n) {
+ case -1:
+ if (errno == EAGAIN)
+ return;
log_warn("warn: %s -> %s: imsg_read",
proc_name(smtpd_process), p->name);
fatal("exiting");
- } else if (n == 0) {
+ /* NOTREACHED */
+ case 0:
/* this pipe is dead, so remove the event handler */
if (smtpd_process != PROC_CONTROL ||
p->proc != PROC_CLIENT)
@@ -172,8 +174,10 @@ mproc_dispatch(int fd, short event, void *arg)
proc_name(smtpd_process), p->name);
p->handler(p, NULL);
return;
- } else
+ default:
p->bytes_in += n;
+ break;
+ }
}
if (event & EV_WRITE) {
diff --git a/smtpd/smtpctl.c b/smtpd/smtpctl.c
index 995c92ff..afc1bcd6 100644
--- a/smtpd/smtpctl.c
+++ b/smtpd/smtpctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpctl.c,v 1.146 2016/02/09 10:38:02 gilles Exp $ */
+/* $OpenBSD: smtpctl.c,v 1.147 2016/02/12 03:11:16 sunil Exp $ */
/*
* Copyright (c) 2013 Eric Faurot <eric@openbsd.org>
@@ -84,6 +84,7 @@ static int is_encrypted_fp(FILE *);
static int is_encrypted_buffer(const char *);
static int is_gzip_buffer(const char *);
static FILE *offline_file(void);
+static void sendmail_compat(int, char **);
extern char *__progname;
int sendmail;
@@ -993,77 +994,14 @@ 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.
- */
- opterr = 0;
- 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;
- }
- }
- opterr = 1;
-
- if (sendmail_makemap) {
- argc -= optind;
- argv += optind;
- optind = 0;
-
- 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);
- }
- optind = 0;
-
- if (!srv_connect())
- offlinefp = offline_file();
-
- if (setresgid(gid, gid, gid) == -1)
- err(1, "setresgid");
-
- /* we'll reduce further down the road */
- 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);
+ sendmail_compat(argc, argv);
if (geteuid())
errx(1, "need root privileges");
+ gid = getgid();
if (setresgid(gid, gid, gid) == -1)
err(1, "setresgid");
@@ -1122,7 +1060,44 @@ main(int argc, char **argv)
errx(1, "unsupported mode");
return (0);
+}
+
+void
+sendmail_compat(int argc, char **argv)
+{
+ FILE *offlinefp = NULL;
+ gid_t gid;
+ int i;
+
+ if (strcmp(__progname, "sendmail") == 0 ||
+ strcmp(__progname, "send-mail") == 0) {
+ /*
+ * determine whether we are called with flags
+ * 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 (!srv_connect())
+ offlinefp = offline_file();
+
+ gid = getgid();
+ if (setresgid(gid, gid, gid) == -1)
+ err(1, "setresgid");
+
+ /* we'll reduce further down the road */
+ if (pledge("stdio rpath wpath cpath tmppath flock "
+ "dns getpw recvfd", NULL) == -1)
+ err(1, "pledge");
+
+ sendmail = 1;
+ exit(enqueue(argc, argv, offlinefp));
+ } else if (strcmp(__progname, "makemap") == 0 ||
+ strcmp(__progname, "newaliases") == 0)
+ exit(makemap(argc, argv));
}
static void