summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorEric Faurot <eric@cvs.openbsd.org>2021-05-26 18:08:56 +0000
committerEric Faurot <eric@cvs.openbsd.org>2021-05-26 18:08:56 +0000
commitf0f3f7a34d266055284ff12f8a5984f03d28ba35 (patch)
treee420a2702474b93d0480682d57a0994c61017e96 /usr.sbin
parent49a33c1ca9073f58372b039022da15ac4b1f34df (diff)
replaces calls to err(3)/errx(3) with fatal()/fatalx() from log.c
for code that runs in the daemon. ok florian@ millert@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/smtpd/bounce.c5
-rw-r--r--usr.sbin/smtpd/ca.c7
-rw-r--r--usr.sbin/smtpd/compress_gzip.c3
-rw-r--r--usr.sbin/smtpd/control.c7
-rw-r--r--usr.sbin/smtpd/dict.c16
-rw-r--r--usr.sbin/smtpd/dispatcher.c7
-rw-r--r--usr.sbin/smtpd/envelope.c5
-rw-r--r--usr.sbin/smtpd/ioev.c34
-rw-r--r--usr.sbin/smtpd/limit.c3
-rw-r--r--usr.sbin/smtpd/lka.c9
-rw-r--r--usr.sbin/smtpd/mda.c5
-rw-r--r--usr.sbin/smtpd/mproc.c5
-rw-r--r--usr.sbin/smtpd/mta.c15
-rw-r--r--usr.sbin/smtpd/mta_session.c5
-rw-r--r--usr.sbin/smtpd/parse.y31
-rw-r--r--usr.sbin/smtpd/proxy.c1
-rw-r--r--usr.sbin/smtpd/queue.c7
-rw-r--r--usr.sbin/smtpd/queue_backend.c15
-rw-r--r--usr.sbin/smtpd/queue_fs.c9
-rw-r--r--usr.sbin/smtpd/queue_null.c3
-rw-r--r--usr.sbin/smtpd/queue_ram.c3
-rw-r--r--usr.sbin/smtpd/scheduler.c9
-rw-r--r--usr.sbin/smtpd/scheduler_backend.c3
-rw-r--r--usr.sbin/smtpd/scheduler_null.c3
-rw-r--r--usr.sbin/smtpd/scheduler_ramqueue.c17
-rw-r--r--usr.sbin/smtpd/smtp.c11
-rw-r--r--usr.sbin/smtpd/smtpctl.c5
-rw-r--r--usr.sbin/smtpd/smtpd.c76
-rw-r--r--usr.sbin/smtpd/srs.c3
-rw-r--r--usr.sbin/smtpd/table_db.c5
-rw-r--r--usr.sbin/smtpd/table_getpwnam.c3
-rw-r--r--usr.sbin/smtpd/to.c3
-rw-r--r--usr.sbin/smtpd/tree.c16
33 files changed, 160 insertions, 189 deletions
diff --git a/usr.sbin/smtpd/bounce.c b/usr.sbin/smtpd/bounce.c
index af9c7d0bde0..a69d2fd9178 100644
--- a/usr.sbin/smtpd/bounce.c
+++ b/usr.sbin/smtpd/bounce.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bounce.c,v 1.83 2020/12/31 08:27:15 martijn Exp $ */
+/* $OpenBSD: bounce.c,v 1.84 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2009 Gilles Chehade <gilles@poolp.org>
@@ -23,7 +23,6 @@
#include <sys/tree.h>
#include <sys/socket.h>
-#include <err.h>
#include <errno.h>
#include <event.h>
#include <imsg.h>
@@ -141,7 +140,7 @@ bounce_add(uint64_t evpid)
}
if (evp.type != D_BOUNCE)
- errx(1, "bounce: evp:%016" PRIx64 " is not of type D_BOUNCE!",
+ fatalx("bounce: evp:%016" PRIx64 " is not of type D_BOUNCE!",
evp.id);
key.msgid = evpid_to_msgid(evpid);
diff --git a/usr.sbin/smtpd/ca.c b/usr.sbin/smtpd/ca.c
index 06499d5ebae..769173ed49f 100644
--- a/usr.sbin/smtpd/ca.c
+++ b/usr.sbin/smtpd/ca.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ca.c,v 1.38 2021/03/05 12:37:32 eric Exp $ */
+/* $OpenBSD: ca.c,v 1.39 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org>
@@ -22,7 +22,6 @@
#include <sys/socket.h>
#include <sys/tree.h>
-#include <err.h>
#include <imsg.h>
#include <limits.h>
#include <pwd.h>
@@ -117,7 +116,7 @@ ca(void)
mproc_disable(p_dispatcher);
if (pledge("stdio", NULL) == -1)
- err(1, "pledge");
+ fatal("pledge");
event_dispatch();
fatalx("exited event loop");
@@ -333,7 +332,7 @@ ca_imsg(struct mproc *p, struct imsg *imsg)
return;
}
- errx(1, "ca_imsg: unexpected %s imsg", imsg_to_str(imsg->hdr.type));
+ fatalx("ca_imsg: unexpected %s imsg", imsg_to_str(imsg->hdr.type));
}
/*
diff --git a/usr.sbin/smtpd/compress_gzip.c b/usr.sbin/smtpd/compress_gzip.c
index 76f0926196b..d71a827aa01 100644
--- a/usr.sbin/smtpd/compress_gzip.c
+++ b/usr.sbin/smtpd/compress_gzip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: compress_gzip.c,v 1.11 2021/01/23 16:11:11 rob Exp $ */
+/* $OpenBSD: compress_gzip.c,v 1.12 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2012 Gilles Chehade <gilles@poolp.org>
@@ -24,7 +24,6 @@
#include <sys/stat.h>
#include <ctype.h>
-#include <err.h>
#include <fcntl.h>
#include <imsg.h>
#include <pwd.h>
diff --git a/usr.sbin/smtpd/control.c b/usr.sbin/smtpd/control.c
index 964a7cb43f7..caada2716ef 100644
--- a/usr.sbin/smtpd/control.c
+++ b/usr.sbin/smtpd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.126 2020/12/31 08:27:15 martijn Exp $ */
+/* $OpenBSD: control.c,v 1.127 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2012 Gilles Chehade <gilles@poolp.org>
@@ -25,7 +25,6 @@
#include <sys/socket.h>
#include <sys/un.h>
-#include <err.h>
#include <errno.h>
#include <event.h>
#include <fcntl.h>
@@ -159,7 +158,7 @@ control_imsg(struct mproc *p, struct imsg *imsg)
return;
}
- errx(1, "control_imsg: unexpected %s imsg",
+ fatalx("control_imsg: unexpected %s imsg",
imsg_to_str(imsg->hdr.type));
}
@@ -254,7 +253,7 @@ control(void)
control_listen();
if (pledge("stdio unix recvfd sendfd", NULL) == -1)
- err(1, "pledge");
+ fatal("pledge");
event_dispatch();
fatalx("exited event loop");
diff --git a/usr.sbin/smtpd/dict.c b/usr.sbin/smtpd/dict.c
index 91156d5a245..d99d9b301dc 100644
--- a/usr.sbin/smtpd/dict.c
+++ b/usr.sbin/smtpd/dict.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dict.c,v 1.6 2018/12/23 16:06:24 gilles Exp $ */
+/* $OpenBSD: dict.c,v 1.7 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2012 Gilles Chehade <gilles@poolp.org>
@@ -20,12 +20,12 @@
#include <sys/types.h>
#include <sys/tree.h>
-#include <err.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include "dict.h"
+#include "log.h"
struct dictentry {
SPLAY_ENTRY(dictentry) entry;
@@ -72,7 +72,7 @@ dict_set(struct dict *d, const char *k, void *data)
key.key = k;
if ((entry = SPLAY_FIND(_dict, &d->dict, &key)) == NULL) {
if ((entry = dict_alloc(k, data)) == NULL)
- err(1, "dict_set: malloc");
+ fatal("dict_set: malloc");
SPLAY_INSERT(_dict, &d->dict, entry);
old = NULL;
d->count += 1;
@@ -90,9 +90,9 @@ dict_xset(struct dict *d, const char * k, void *data)
struct dictentry *entry;
if ((entry = dict_alloc(k, data)) == NULL)
- err(1, "dict_xset: malloc");
+ fatal("dict_xset: malloc");
if (SPLAY_INSERT(_dict, &d->dict, entry))
- errx(1, "dict_xset(%p, %s)", d, k);
+ fatalx("dict_xset(%p, %s)", d, k);
d->count += 1;
}
@@ -115,7 +115,7 @@ dict_xget(struct dict *d, const char *k)
key.key = k;
if ((entry = SPLAY_FIND(_dict, &d->dict, &key)) == NULL)
- errx(1, "dict_xget(%p, %s)", d, k);
+ fatalx("dict_xget(%p, %s)", d, k);
return (entry->data);
}
@@ -146,7 +146,7 @@ dict_xpop(struct dict *d, const char *k)
key.key = k;
if ((entry = SPLAY_FIND(_dict, &d->dict, &key)) == NULL)
- errx(1, "dict_xpop(%p, %s)", d, k);
+ fatalx("dict_xpop(%p, %s)", d, k);
data = entry->data;
SPLAY_REMOVE(_dict, &d->dict, entry);
@@ -252,7 +252,7 @@ dict_merge(struct dict *dst, struct dict *src)
entry = SPLAY_ROOT(&src->dict);
SPLAY_REMOVE(_dict, &src->dict, entry);
if (SPLAY_INSERT(_dict, &dst->dict, entry))
- errx(1, "dict_merge: duplicate");
+ fatalx("dict_merge: duplicate");
}
dst->count += src->count;
src->count = 0;
diff --git a/usr.sbin/smtpd/dispatcher.c b/usr.sbin/smtpd/dispatcher.c
index 758de39f49c..f8fbe0066e8 100644
--- a/usr.sbin/smtpd/dispatcher.c
+++ b/usr.sbin/smtpd/dispatcher.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dispatcher.c,v 1.3 2021/04/21 07:54:10 eric Exp $ */
+/* $OpenBSD: dispatcher.c,v 1.4 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2014 Gilles Chehade <gilles@poolp.org>
@@ -22,7 +22,6 @@
#include <sys/socket.h>
#include <ctype.h>
-#include <err.h>
#include <errno.h>
#include <event.h>
#include <imsg.h>
@@ -134,7 +133,7 @@ dispatcher_imsg(struct mproc *p, struct imsg *imsg)
break;
}
- errx(1, "session_imsg: unexpected %s imsg", imsg_to_str(imsg->hdr.type));
+ fatalx("session_imsg: unexpected %s imsg", imsg_to_str(imsg->hdr.type));
}
static void
@@ -194,7 +193,7 @@ dispatcher(void)
config_peer(PROC_CA);
if (pledge("stdio inet unix recvfd sendfd", NULL) == -1)
- err(1, "pledge");
+ fatal("pledge");
event_dispatch();
fatalx("exited event loop");
diff --git a/usr.sbin/smtpd/envelope.c b/usr.sbin/smtpd/envelope.c
index 05a239e1814..13a351aea9b 100644
--- a/usr.sbin/smtpd/envelope.c
+++ b/usr.sbin/smtpd/envelope.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: envelope.c,v 1.47 2019/11/25 14:18:32 gilles Exp $ */
+/* $OpenBSD: envelope.c,v 1.48 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2013 Eric Faurot <eric@openbsd.org>
@@ -27,7 +27,6 @@
#include <arpa/inet.h>
#include <ctype.h>
-#include <err.h>
#include <errno.h>
#include <event.h>
#include <fcntl.h>
@@ -60,7 +59,7 @@ envelope_set_errormsg(struct envelope *e, char *fmt, ...)
/* this should not happen */
if (ret < 0)
- err(1, "vsnprintf");
+ fatal("vsnprintf");
if ((size_t)ret >= sizeof(e->errorline))
(void)strlcpy(e->errorline + (sizeof(e->errorline) - 4),
diff --git a/usr.sbin/smtpd/ioev.c b/usr.sbin/smtpd/ioev.c
index cdbfcbf5e3f..8d6d13c2635 100644
--- a/usr.sbin/smtpd/ioev.c
+++ b/usr.sbin/smtpd/ioev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ioev.c,v 1.46 2021/05/20 07:33:32 eric Exp $ */
+/* $OpenBSD: ioev.c,v 1.47 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -19,7 +19,6 @@
#include <sys/queue.h>
#include <sys/socket.h>
-#include <err.h>
#include <errno.h>
#include <event.h>
#include <fcntl.h>
@@ -34,6 +33,7 @@
#include "ioev.h"
#include "iobuf.h"
+#include "log.h"
enum {
IO_STATE_NONE,
@@ -149,12 +149,12 @@ io_set_nonblocking(int fd)
int flags;
if ((flags = fcntl(fd, F_GETFL)) == -1)
- err(1, "io_set_blocking:fcntl(F_GETFL)");
+ fatal("io_set_blocking:fcntl(F_GETFL)");
flags |= O_NONBLOCK;
if (fcntl(fd, F_SETFL, flags) == -1)
- err(1, "io_set_blocking:fcntl(F_SETFL)");
+ fatal("io_set_blocking:fcntl(F_SETFL)");
}
void
@@ -164,7 +164,7 @@ io_set_nolinger(int fd)
memset(&l, 0, sizeof(l));
if (setsockopt(fd, SOL_SOCKET, SO_LINGER, &l, sizeof(l)) == -1)
- err(1, "io_set_linger:setsockopt");
+ fatal("io_set_linger:setsockopt");
}
/*
@@ -186,7 +186,7 @@ io_frame_enter(const char *where, struct io *io, int ev)
frame, where, io_evstr(ev), io_strio(io));
if (current)
- errx(1, "io_frame_enter: interleaved frames");
+ fatalx("io_frame_enter: interleaved frames");
current = io;
@@ -199,7 +199,7 @@ io_frame_leave(struct io *io)
io_debug("io_frame_leave(%" PRIu64 ")\n", frame);
if (current && current != io)
- errx(1, "io_frame_leave: io mismatch");
+ fatalx("io_frame_leave: io mismatch");
/* io has been cleared */
if (current == NULL)
@@ -289,7 +289,7 @@ io_hold(struct io *io)
io_debug("io_enter(%p)\n", io);
if (io->flags & IO_HELD)
- errx(1, "io_hold: io is already held");
+ fatalx("io_hold: io is already held");
io->flags &= ~IO_RESET;
io->flags |= IO_HELD;
@@ -299,7 +299,7 @@ void
io_release(struct io *io)
{
if (!(io->flags & IO_HELD))
- errx(1, "io_release: io is not held");
+ fatalx("io_release: io is not held");
io->flags &= ~IO_HELD;
if (!(io->flags & IO_RESET))
@@ -364,7 +364,7 @@ io_set_read(struct io *io)
mode = io->flags & IO_RW;
if (!(mode == 0 || mode == IO_WRITE))
- errx(1, "io_set_read: full-duplex or reading");
+ fatalx("io_set_read: full-duplex or reading");
io->flags &= ~IO_RW;
io->flags |= IO_READ;
@@ -380,7 +380,7 @@ io_set_write(struct io *io)
mode = io->flags & IO_RW;
if (!(mode == 0 || mode == IO_READ))
- errx(1, "io_set_write: full-duplex or writing");
+ fatalx("io_set_write: full-duplex or writing");
io->flags &= ~IO_RW;
io->flags |= IO_WRITE;
@@ -784,7 +784,7 @@ io_dispatch_connect(int fd, short ev, void *humppa)
sl = sizeof(e);
r = getsockopt(fd, SOL_SOCKET, SO_ERROR, &e, &sl);
if (r == -1) {
- warn("io_dispatch_connect: getsockopt");
+ log_warn("io_dispatch_connect: getsockopt");
e = errno;
}
if (e) {
@@ -810,10 +810,10 @@ io_connect_tls(struct io *io, struct tls *tls, const char *hostname)
mode = io->flags & IO_RW;
if (mode != IO_WRITE)
- errx(1, "io_connect_tls: expect IO_WRITE mode");
+ fatalx("io_connect_tls: expect IO_WRITE mode");
if (io->tls)
- errx(1, "io_connect_tls: TLS already started");
+ fatalx("io_connect_tls: TLS already started");
if (tls_connect_socket(tls, io->sock, hostname) == -1) {
io->error = tls_error(tls);
@@ -834,10 +834,10 @@ io_accept_tls(struct io *io, struct tls *tls)
mode = io->flags & IO_RW;
if (mode != IO_READ)
- errx(1, "io_accept_tls: expect IO_READ mode");
+ fatalx("io_accept_tls: expect IO_READ mode");
if (io->tls)
- errx(1, "io_accept_tls: TLS already started");
+ fatalx("io_accept_tls: TLS already started");
if (tls_accept_socket(tls, &io->tls, io->sock) == -1) {
io->error = tls_error(tls);
@@ -967,7 +967,7 @@ void
io_reload_tls(struct io *io)
{
if (io->state != IO_STATE_UP)
- errx(1, "io_reload_tls: bad state");
+ fatalx("io_reload_tls: bad state");
if (IO_READING(io) && !(io->flags & IO_PAUSE_IN)) {
io_reset(io, EV_READ, io_dispatch_read_tls);
diff --git a/usr.sbin/smtpd/limit.c b/usr.sbin/smtpd/limit.c
index e7d0cb1705d..3b0e8f4a28f 100644
--- a/usr.sbin/smtpd/limit.c
+++ b/usr.sbin/smtpd/limit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: limit.c,v 1.5 2016/06/15 19:59:03 gilles Exp $ */
+/* $OpenBSD: limit.c,v 1.6 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2013 Eric Faurot <eric@openbsd.org>
@@ -22,7 +22,6 @@
#include <sys/socket.h>
#include <ctype.h>
-#include <err.h>
#include <event.h>
#include <fcntl.h>
#include <imsg.h>
diff --git a/usr.sbin/smtpd/lka.c b/usr.sbin/smtpd/lka.c
index ec0264a572f..58835b16ee2 100644
--- a/usr.sbin/smtpd/lka.c
+++ b/usr.sbin/smtpd/lka.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lka.c,v 1.245 2021/04/21 07:54:10 eric Exp $ */
+/* $OpenBSD: lka.c,v 1.246 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -28,7 +28,6 @@
#include <netinet/in.h>
#include <ctype.h>
-#include <err.h>
#include <errno.h>
#include <event.h>
#include <imsg.h>
@@ -313,7 +312,7 @@ lka_imsg(struct mproc *p, struct imsg *imsg)
/* revoke proc & exec */
if (pledge("stdio rpath inet dns getpw recvfd sendfd",
NULL) == -1)
- err(1, "pledge");
+ fatal("pledge");
/* setup proc registering task */
evtimer_set(&ev_proc_ready, proc_timeout, &ev_proc_ready);
@@ -637,7 +636,7 @@ lka_imsg(struct mproc *p, struct imsg *imsg)
}
- errx(1, "lka_imsg: unexpected %s imsg", imsg_to_str(imsg->hdr.type));
+ fatalx("lka_imsg: unexpected %s imsg", imsg_to_str(imsg->hdr.type));
}
static void
@@ -705,7 +704,7 @@ lka(void)
/* proc & exec will be revoked before serving requests */
if (pledge("stdio rpath inet dns getpw recvfd sendfd proc exec", NULL) == -1)
- err(1, "pledge");
+ fatal("pledge");
event_dispatch();
fatalx("exited event loop");
diff --git a/usr.sbin/smtpd/mda.c b/usr.sbin/smtpd/mda.c
index 765acda9be7..28ab377c031 100644
--- a/usr.sbin/smtpd/mda.c
+++ b/usr.sbin/smtpd/mda.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mda.c,v 1.141 2019/10/03 08:50:08 gilles Exp $ */
+/* $OpenBSD: mda.c,v 1.142 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -25,7 +25,6 @@
#include <sys/socket.h>
#include <ctype.h>
-#include <err.h>
#include <errno.h>
#include <event.h>
#include <imsg.h>
@@ -380,7 +379,7 @@ mda_imsg(struct mproc *p, struct imsg *imsg)
return;
}
- errx(1, "mda_imsg: unexpected %s imsg", imsg_to_str(imsg->hdr.type));
+ fatalx("mda_imsg: unexpected %s imsg", imsg_to_str(imsg->hdr.type));
}
void
diff --git a/usr.sbin/smtpd/mproc.c b/usr.sbin/smtpd/mproc.c
index 79e39a99e52..1e5f73d156b 100644
--- a/usr.sbin/smtpd/mproc.c
+++ b/usr.sbin/smtpd/mproc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mproc.c,v 1.37 2020/12/20 14:06:12 martijn Exp $ */
+/* $OpenBSD: mproc.c,v 1.38 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@faurot.net>
@@ -26,7 +26,6 @@
#include <arpa/inet.h>
#include <arpa/nameser.h>
-#include <err.h>
#include <errno.h>
#include <event.h>
#include <imsg.h>
@@ -64,7 +63,7 @@ mproc_fork(struct mproc *p, const char *path, char *argv[])
exit(1);
execv(path, argv);
- err(1, "execv: %s", path);
+ fatal("execv: %s", path);
}
/* parent process */
diff --git a/usr.sbin/smtpd/mta.c b/usr.sbin/smtpd/mta.c
index bd5585bacf8..e9dfc7958bf 100644
--- a/usr.sbin/smtpd/mta.c
+++ b/usr.sbin/smtpd/mta.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mta.c,v 1.238 2021/04/09 16:43:43 eric Exp $ */
+/* $OpenBSD: mta.c,v 1.239 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -25,7 +25,6 @@
#include <sys/socket.h>
#include <ctype.h>
-#include <err.h>
#include <errno.h>
#include <event.h>
#include <imsg.h>
@@ -466,7 +465,7 @@ mta_imsg(struct mproc *p, struct imsg *imsg)
return;
}
- errx(1, "mta_imsg: unexpected %s imsg", imsg_to_str(imsg->hdr.type));
+ fatalx("mta_imsg: unexpected %s imsg", imsg_to_str(imsg->hdr.type));
}
void
@@ -506,21 +505,21 @@ mta_setup_dispatcher(struct dispatcher *dispatcher)
if (remote->tls_ciphers)
ciphers = remote->tls_ciphers;
if (ciphers && tls_config_set_ciphers(config, ciphers) == -1)
- err(1, "%s", tls_config_error(config));
+ fatal("%s", tls_config_error(config));
if (remote->tls_protocols) {
if (tls_config_parse_protocols(&protos,
remote->tls_protocols) == -1)
- err(1, "failed to parse protocols \"%s\"",
+ fatal("failed to parse protocols \"%s\"",
remote->tls_protocols);
if (tls_config_set_protocols(config, protos) == -1)
- err(1, "%s", tls_config_error(config));
+ fatal("%s", tls_config_error(config));
}
if (remote->pki) {
pki = dict_get(env->sc_pki_dict, remote->pki);
if (pki == NULL)
- err(1, "client pki \"%s\" not found ", remote->pki);
+ fatal("client pki \"%s\" not found ", remote->pki);
tls_config_set_dheparams(config, dheparams[pki->pki_dhe]);
tls_config_use_fake_private_key(config);
@@ -1549,7 +1548,7 @@ mta_flush(struct mta_relay *relay, int fail, const char *error)
mta_relay_to_text(relay), fail, error);
if (fail != IMSG_MTA_DELIVERY_TEMPFAIL && fail != IMSG_MTA_DELIVERY_PERMFAIL)
- errx(1, "unexpected delivery status %d", fail);
+ fatalx("unexpected delivery status %d", fail);
n = 0;
while ((task = TAILQ_FIRST(&relay->tasks))) {
diff --git a/usr.sbin/smtpd/mta_session.c b/usr.sbin/smtpd/mta_session.c
index fd7361d0886..36e49681090 100644
--- a/usr.sbin/smtpd/mta_session.c
+++ b/usr.sbin/smtpd/mta_session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mta_session.c,v 1.141 2021/05/20 07:33:32 eric Exp $ */
+/* $OpenBSD: mta_session.c,v 1.142 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -28,7 +28,6 @@
#include <arpa/inet.h>
#include <ctype.h>
-#include <err.h>
#include <errno.h>
#include <event.h>
#include <imsg.h>
@@ -358,7 +357,7 @@ mta_session_imsg(struct mproc *p, struct imsg *imsg)
return;
default:
- errx(1, "mta_session_imsg: unexpected %s imsg",
+ fatalx("mta_session_imsg: unexpected %s imsg",
imsg_to_str(imsg->hdr.type));
}
}
diff --git a/usr.sbin/smtpd/parse.y b/usr.sbin/smtpd/parse.y
index f654d76922f..011e306ac61 100644
--- a/usr.sbin/smtpd/parse.y
+++ b/usr.sbin/smtpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.287 2021/04/09 16:43:43 eric Exp $ */
+/* $OpenBSD: parse.y,v 1.288 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -34,7 +34,6 @@
#include <arpa/inet.h>
#include <ctype.h>
-#include <err.h>
#include <errno.h>
#include <event.h>
#include <ifaddrs.h>
@@ -1894,7 +1893,7 @@ STRING {
filter_config->chain_size += 1;
filter_config->chain = reallocarray(filter_config->chain, filter_config->chain_size, sizeof(char *));
if (filter_config->chain == NULL)
- err(1, NULL);
+ fatal("reallocarray");
filter_config->chain[filter_config->chain_size - 1] = $1;
}
;
@@ -2846,7 +2845,7 @@ lungetc(int c)
if (file->ungetpos >= file->ungetsize) {
void *p = reallocarray(file->ungetbuf, file->ungetsize, 2);
if (p == NULL)
- err(1, "%s", __func__);
+ fatal("%s", __func__);
file->ungetbuf = p;
file->ungetsize *= 2;
}
@@ -2956,7 +2955,7 @@ top:
}
yylval.v.string = strdup(buf);
if (yylval.v.string == NULL)
- err(1, "%s", __func__);
+ fatal("%s", __func__);
return (STRING);
}
@@ -3021,7 +3020,7 @@ nodigits:
*p = '\0';
if ((token = lookup(buf)) == STRING)
if ((yylval.v.string = strdup(buf)) == NULL)
- err(1, "%s", __func__);
+ fatal("%s", __func__);
return (token);
}
if (c == '\n') {
@@ -3215,7 +3214,7 @@ cmdline_symset(char *s)
return (-1);
sym = strndup(s, val - s);
if (sym == NULL)
- errx(1, "%s: strndup", __func__);
+ fatalx("%s: strndup", __func__);
ret = symset(sym, val + 1, 1);
free(sym);
@@ -3254,15 +3253,15 @@ create_if_listener(struct listen_opts *lo)
uint16_t flags;
if (lo->port != 0 && lo->ssl == F_SSL)
- errx(1, "invalid listen option: tls/smtps on same port");
+ fatalx("invalid listen option: tls/smtps on same port");
if (lo->auth != 0 && !lo->ssl)
- errx(1, "invalid listen option: auth requires tls/smtps");
+ fatalx("invalid listen option: auth requires tls/smtps");
if (lo->pkicount && !lo->ssl)
- errx(1, "invalid listen option: pki requires tls/smtps");
+ fatalx("invalid listen option: pki requires tls/smtps");
if (lo->pkicount == 0 && lo->ssl)
- errx(1, "invalid listen option: pki required for tls/smtps");
+ fatalx("invalid listen option: pki required for tls/smtps");
flags = lo->flags;
@@ -3293,7 +3292,7 @@ create_if_listener(struct listen_opts *lo)
if (host_dns(lo))
return;
- errx(1, "invalid virtual ip or interface: %s", lo->ifx);
+ fatalx("invalid virtual ip or interface: %s", lo->ifx);
}
static void
@@ -3609,23 +3608,23 @@ is_if_in_group(const char *ifname, const char *groupname)
int ret = 0;
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
- err(1, "socket");
+ fatal("socket");
memset(&ifgr, 0, sizeof(ifgr));
if (strlcpy(ifgr.ifgr_name, ifname, IFNAMSIZ) >= IFNAMSIZ)
- errx(1, "interface name too large");
+ fatalx("interface name too large");
if (ioctl(s, SIOCGIFGROUP, (caddr_t)&ifgr) == -1) {
if (errno == EINVAL || errno == ENOTTY)
goto end;
- err(1, "SIOCGIFGROUP");
+ fatal("SIOCGIFGROUP");
}
len = ifgr.ifgr_len;
ifgr.ifgr_groups = xcalloc(len/sizeof(struct ifg_req),
sizeof(struct ifg_req));
if (ioctl(s, SIOCGIFGROUP, (caddr_t)&ifgr) == -1)
- err(1, "SIOCGIFGROUP");
+ fatal("SIOCGIFGROUP");
ifg = ifgr.ifgr_groups;
for (; ifg && len >= sizeof(struct ifg_req); ifg++) {
diff --git a/usr.sbin/smtpd/proxy.c b/usr.sbin/smtpd/proxy.c
index 7bf976d8939..f82dff34ba2 100644
--- a/usr.sbin/smtpd/proxy.c
+++ b/usr.sbin/smtpd/proxy.c
@@ -19,7 +19,6 @@
#include <sys/tree.h>
#include <sys/un.h>
-#include <err.h>
#include <errno.h>
#include <event.h>
#include <imsg.h>
diff --git a/usr.sbin/smtpd/queue.c b/usr.sbin/smtpd/queue.c
index 2b56a6deeca..86e6dfdffdf 100644
--- a/usr.sbin/smtpd/queue.c
+++ b/usr.sbin/smtpd/queue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: queue.c,v 1.191 2020/12/31 08:27:15 martijn Exp $ */
+/* $OpenBSD: queue.c,v 1.192 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -24,7 +24,6 @@
#include <sys/socket.h>
#include <sys/stat.h>
-#include <err.h>
#include <event.h>
#include <imsg.h>
#include <inttypes.h>
@@ -525,7 +524,7 @@ queue_imsg(struct mproc *p, struct imsg *imsg)
return;
}
- errx(1, "queue_imsg: unexpected %s imsg", imsg_to_str(imsg->hdr.type));
+ fatalx("queue_imsg: unexpected %s imsg", imsg_to_str(imsg->hdr.type));
}
static void
@@ -674,7 +673,7 @@ queue(void)
evtimer_add(&ev_qload, &tv);
if (pledge("stdio rpath wpath cpath flock recvfd sendfd", NULL) == -1)
- err(1, "pledge");
+ fatal("pledge");
event_dispatch();
fatalx("exited event loop");
diff --git a/usr.sbin/smtpd/queue_backend.c b/usr.sbin/smtpd/queue_backend.c
index a33f91f45f4..0be658b2149 100644
--- a/usr.sbin/smtpd/queue_backend.c
+++ b/usr.sbin/smtpd/queue_backend.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: queue_backend.c,v 1.66 2020/04/22 11:35:34 eric Exp $ */
+/* $OpenBSD: queue_backend.c,v 1.67 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@poolp.org>
@@ -23,7 +23,6 @@
#include <sys/stat.h>
#include <ctype.h>
-#include <err.h>
#include <errno.h>
#include <event.h>
#include <fcntl.h>
@@ -119,11 +118,11 @@ queue_init(const char *name, int server)
pwq = getpwnam(SMTPD_QUEUE_USER);
if (pwq == NULL)
- errx(1, "unknown user %s", SMTPD_QUEUE_USER);
+ fatalx("unknown user %s", SMTPD_QUEUE_USER);
gr = getgrnam(SMTPD_QUEUE_GROUP);
if (gr == NULL)
- errx(1, "unknown group %s", SMTPD_QUEUE_GROUP);
+ fatalx("unknown group %s", SMTPD_QUEUE_GROUP);
tree_init(&evpcache_tree);
TAILQ_INIT(&evpcache_list);
@@ -139,16 +138,16 @@ queue_init(const char *name, int server)
if (server) {
if (ckdir(PATH_SPOOL, 0711, 0, 0, 1) == 0)
- errx(1, "error in spool directory setup");
+ fatalx("error in spool directory setup");
if (ckdir(PATH_SPOOL PATH_OFFLINE, 0770, 0, gr->gr_gid, 1) == 0)
- errx(1, "error in offline directory setup");
+ fatalx("error in offline directory setup");
if (ckdir(PATH_SPOOL PATH_PURGE, 0700, pwq->pw_uid, 0, 1) == 0)
- errx(1, "error in purge directory setup");
+ fatalx("error in purge directory setup");
mvpurge(PATH_SPOOL PATH_TEMPORARY, PATH_SPOOL PATH_PURGE);
if (ckdir(PATH_SPOOL PATH_TEMPORARY, 0700, pwq->pw_uid, 0, 1) == 0)
- errx(1, "error in purge directory setup");
+ fatalx("error in purge directory setup");
}
r = backend->init(pwq, server, name);
diff --git a/usr.sbin/smtpd/queue_fs.c b/usr.sbin/smtpd/queue_fs.c
index 924bd2617c2..df2c78fbee3 100644
--- a/usr.sbin/smtpd/queue_fs.c
+++ b/usr.sbin/smtpd/queue_fs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: queue_fs.c,v 1.20 2020/02/25 17:03:13 millert Exp $ */
+/* $OpenBSD: queue_fs.c,v 1.21 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@poolp.org>
@@ -25,7 +25,6 @@
#include <ctype.h>
#include <dirent.h>
-#include <err.h>
#include <errno.h>
#include <event.h>
#include <fcntl.h>
@@ -565,7 +564,7 @@ fsqueue_qwalk_new(void)
FTS_PHYSICAL | FTS_NOCHDIR, NULL);
if (q->fts == NULL)
- err(1, "fsqueue_qwalk_new: fts_open: %s", path);
+ fatal("fsqueue_qwalk_new: fts_open: %s", path);
return (q);
}
@@ -651,13 +650,13 @@ queue_fs_init(struct passwd *pw, int server, const char *conf)
for (n = 0; n < nitems(paths); n++) {
(void)strlcpy(path, PATH_SPOOL, sizeof(path));
if (strlcat(path, paths[n], sizeof(path)) >= sizeof(path))
- errx(1, "path too long %s%s", PATH_SPOOL, paths[n]);
+ fatalx("path too long %s%s", PATH_SPOOL, paths[n]);
if (ckdir(path, 0700, pw->pw_uid, 0, server) == 0)
ret = 0;
}
if (clock_gettime(CLOCK_REALTIME, &startup))
- err(1, "clock_gettime");
+ fatal("clock_gettime");
tree_init(&evpcount);
diff --git a/usr.sbin/smtpd/queue_null.c b/usr.sbin/smtpd/queue_null.c
index d92f98a74e0..823d9cc4daf 100644
--- a/usr.sbin/smtpd/queue_null.c
+++ b/usr.sbin/smtpd/queue_null.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: queue_null.c,v 1.8 2018/12/30 23:09:58 guenther Exp $ */
+/* $OpenBSD: queue_null.c,v 1.9 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
@@ -23,7 +23,6 @@
#include <sys/stat.h>
#include <ctype.h>
-#include <err.h>
#include <errno.h>
#include <event.h>
#include <fcntl.h>
diff --git a/usr.sbin/smtpd/queue_ram.c b/usr.sbin/smtpd/queue_ram.c
index 56b9fa5b30f..bc0a72a5fdb 100644
--- a/usr.sbin/smtpd/queue_ram.c
+++ b/usr.sbin/smtpd/queue_ram.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: queue_ram.c,v 1.9 2018/12/30 23:09:58 guenther Exp $ */
+/* $OpenBSD: queue_ram.c,v 1.10 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
@@ -23,7 +23,6 @@
#include <sys/stat.h>
#include <ctype.h>
-#include <err.h>
#include <errno.h>
#include <event.h>
#include <fcntl.h>
diff --git a/usr.sbin/smtpd/scheduler.c b/usr.sbin/smtpd/scheduler.c
index b3bda1754b5..80edf9c758c 100644
--- a/usr.sbin/smtpd/scheduler.c
+++ b/usr.sbin/smtpd/scheduler.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scheduler.c,v 1.60 2018/12/30 23:09:58 guenther Exp $ */
+/* $OpenBSD: scheduler.c,v 1.61 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -27,7 +27,6 @@
#include <ctype.h>
#include <dirent.h>
-#include <err.h>
#include <errno.h>
#include <event.h>
#include <imsg.h>
@@ -400,7 +399,7 @@ scheduler_imsg(struct mproc *p, struct imsg *imsg)
return;
}
- errx(1, "scheduler_imsg: unexpected %s imsg",
+ fatalx("scheduler_imsg: unexpected %s imsg",
imsg_to_str(imsg->hdr.type));
}
@@ -429,7 +428,7 @@ scheduler(void)
backend = scheduler_backend_lookup(backend_scheduler);
if (backend == NULL)
- errx(1, "cannot find scheduler backend \"%s\"",
+ fatalx("cannot find scheduler backend \"%s\"",
backend_scheduler);
purge_config(PURGE_EVERYTHING & ~PURGE_DISPATCHERS);
@@ -471,7 +470,7 @@ scheduler(void)
scheduler_reset_events();
if (pledge("stdio", NULL) == -1)
- err(1, "pledge");
+ fatal("pledge");
event_dispatch();
fatalx("exited event loop");
diff --git a/usr.sbin/smtpd/scheduler_backend.c b/usr.sbin/smtpd/scheduler_backend.c
index 061f1129595..90c106fb826 100644
--- a/usr.sbin/smtpd/scheduler_backend.c
+++ b/usr.sbin/smtpd/scheduler_backend.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scheduler_backend.c,v 1.16 2018/05/24 11:38:24 gilles Exp $ */
+/* $OpenBSD: scheduler_backend.c,v 1.17 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2012 Gilles Chehade <gilles@poolp.org>
@@ -22,7 +22,6 @@
#include <sys/socket.h>
#include <ctype.h>
-#include <err.h>
#include <event.h>
#include <fcntl.h>
#include <imsg.h>
diff --git a/usr.sbin/smtpd/scheduler_null.c b/usr.sbin/smtpd/scheduler_null.c
index a8c43331eb4..b8db4a92d51 100644
--- a/usr.sbin/smtpd/scheduler_null.c
+++ b/usr.sbin/smtpd/scheduler_null.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scheduler_null.c,v 1.9 2015/01/20 17:37:54 deraadt Exp $ */
+/* $OpenBSD: scheduler_null.c,v 1.10 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
@@ -22,7 +22,6 @@
#include <sys/socket.h>
#include <ctype.h>
-#include <err.h>
#include <event.h>
#include <fcntl.h>
#include <imsg.h>
diff --git a/usr.sbin/smtpd/scheduler_ramqueue.c b/usr.sbin/smtpd/scheduler_ramqueue.c
index 8d5efc1009c..2c6ed66d56b 100644
--- a/usr.sbin/smtpd/scheduler_ramqueue.c
+++ b/usr.sbin/smtpd/scheduler_ramqueue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scheduler_ramqueue.c,v 1.45 2018/05/31 21:06:12 gilles Exp $ */
+/* $OpenBSD: scheduler_ramqueue.c,v 1.46 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2012 Gilles Chehade <gilles@poolp.org>
@@ -23,7 +23,6 @@
#include <sys/socket.h>
#include <ctype.h>
-#include <err.h>
#include <event.h>
#include <fcntl.h>
#include <imsg.h>
@@ -310,7 +309,7 @@ scheduler_ram_update(struct scheduler_info *si)
/* it *must* be in-flight */
if (evp->state != RQ_EVPSTATE_INFLIGHT)
- errx(1, "evp:%016" PRIx64 " not in-flight", si->evpid);
+ fatalx("evp:%016" PRIx64 " not in-flight", si->evpid);
TAILQ_REMOVE(&ramqueue.q_inflight, evp, entry);
@@ -352,7 +351,7 @@ scheduler_ram_delete(uint64_t evpid)
/* it *must* be in-flight */
if (evp->state != RQ_EVPSTATE_INFLIGHT)
- errx(1, "evp:%016" PRIx64 " not in-flight", evpid);
+ fatalx("evp:%016" PRIx64 " not in-flight", evpid);
TAILQ_REMOVE(&ramqueue.q_inflight, evp, entry);
@@ -379,7 +378,7 @@ scheduler_ram_hold(uint64_t evpid, uint64_t holdq)
/* it *must* be in-flight */
if (evp->state != RQ_EVPSTATE_INFLIGHT)
- errx(1, "evp:%016" PRIx64 " not in-flight", evpid);
+ fatalx("evp:%016" PRIx64 " not in-flight", evpid);
TAILQ_REMOVE(&ramqueue.q_inflight, evp, entry);
@@ -898,7 +897,7 @@ rq_queue_schedule(struct rq_queue *rq)
break;
if (evp->state != RQ_EVPSTATE_PENDING)
- errx(1, "evp:%016" PRIx64 " flags=0x%x", evp->evpid,
+ fatalx("evp:%016" PRIx64 " flags=0x%x", evp->evpid,
evp->flags);
if (evp->expire <= currtime) {
@@ -935,7 +934,7 @@ rq_envelope_list(struct rq_queue *rq, struct rq_envelope *evp)
return &rq->q_mda;
if (evp->type == D_BOUNCE)
return &rq->q_bounce;
- errx(1, "%016" PRIx64 " bad evp type %d", evp->evpid, evp->type);
+ fatalx("%016" PRIx64 " bad evp type %d", evp->evpid, evp->type);
case RQ_EVPSTATE_INFLIGHT:
return &rq->q_inflight;
@@ -944,7 +943,7 @@ rq_envelope_list(struct rq_queue *rq, struct rq_envelope *evp)
return (NULL);
}
- errx(1, "%016" PRIx64 " bad state %d", evp->evpid, evp->state);
+ fatalx("%016" PRIx64 " bad state %d", evp->evpid, evp->state);
return (NULL);
}
@@ -1146,7 +1145,7 @@ rq_envelope_to_text(struct rq_envelope *e)
(void)strlcat(buf, t, sizeof buf);
break;
default:
- errx(1, "%016" PRIx64 " bad state %d", e->evpid, e->state);
+ fatalx("%016" PRIx64 " bad state %d", e->evpid, e->state);
}
if (e->flags & RQ_ENVELOPE_REMOVED)
diff --git a/usr.sbin/smtpd/smtp.c b/usr.sbin/smtpd/smtp.c
index a2371f75611..7c7ab53645c 100644
--- a/usr.sbin/smtpd/smtp.c
+++ b/usr.sbin/smtpd/smtp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtp.c,v 1.169 2021/04/09 16:43:43 eric Exp $ */
+/* $OpenBSD: smtp.c,v 1.170 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -23,7 +23,6 @@
#include <sys/tree.h>
#include <sys/socket.h>
-#include <err.h>
#include <errno.h>
#include <event.h>
#include <imsg.h>
@@ -117,7 +116,7 @@ smtp_imsg(struct mproc *p, struct imsg *imsg)
return;
}
- errx(1, "smtp_imsg: unexpected %s imsg", imsg_to_str(imsg->hdr.type));
+ fatalx("smtp_imsg: unexpected %s imsg", imsg_to_str(imsg->hdr.type));
}
void
@@ -182,14 +181,14 @@ smtp_setup_listener_tls(struct listener *l)
if (l->tls_ciphers)
ciphers = l->tls_ciphers;
if (ciphers && tls_config_set_ciphers(config, ciphers) == -1)
- err(1, "%s", tls_config_error(config));
+ fatal("%s", tls_config_error(config));
if (l->tls_protocols) {
if (tls_config_parse_protocols(&protos, l->tls_protocols) == -1)
- err(1, "failed to parse protocols \"%s\"",
+ fatal("failed to parse protocols \"%s\"",
l->tls_protocols);
if (tls_config_set_protocols(config, protos) == -1)
- err(1, "%s", tls_config_error(config));
+ fatal("%s", tls_config_error(config));
}
pki = l->pki[0];
diff --git a/usr.sbin/smtpd/smtpctl.c b/usr.sbin/smtpd/smtpctl.c
index bd54cc3a914..5f4ded4858b 100644
--- a/usr.sbin/smtpd/smtpctl.c
+++ b/usr.sbin/smtpd/smtpctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpctl.c,v 1.167 2020/02/24 16:16:07 millert Exp $ */
+/* $OpenBSD: smtpctl.c,v 1.168 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2013 Eric Faurot <eric@openbsd.org>
@@ -761,7 +761,6 @@ do_show_queue(int argc, struct parameter *argv)
now = time(NULL);
if (!srv_connect()) {
- log_init(1, LOG_MAIL);
queue_init("fs", 0);
if (chroot(PATH_SPOOL) == -1 || chdir("/") == -1)
err(1, "%s", PATH_SPOOL);
@@ -1044,6 +1043,8 @@ main(int argc, char **argv)
int privileged;
char *argv_mailq[] = { "show", "queue", NULL };
+ log_init(1, LOG_MAIL);
+
sendmail_compat(argc, argv);
privileged = geteuid() == 0;
diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c
index 76bf1561e1f..8860da0876a 100644
--- a/usr.sbin/smtpd/smtpd.c
+++ b/usr.sbin/smtpd/smtpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.c,v 1.338 2021/04/21 07:54:10 eric Exp $ */
+/* $OpenBSD: smtpd.c,v 1.339 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -29,7 +29,6 @@
#include <bsd_auth.h>
#include <dirent.h>
-#include <err.h>
#include <errno.h>
#include <event.h>
#include <fcntl.h>
@@ -270,7 +269,7 @@ parent_imsg(struct mproc *p, struct imsg *imsg)
return;
}
- errx(1, "parent_imsg: unexpected %s imsg from %s",
+ fatalx("parent_imsg: unexpected %s imsg from %s",
imsg_to_str(imsg->hdr.type), proc_title(p->proc));
}
@@ -485,11 +484,6 @@ main(int argc, char *argv[])
char *rexec = NULL;
struct smtpd *conf;
- if ((conf = config_default()) == NULL)
- err(1, NULL);
-
- env = conf;
-
flags = 0;
opts = 0;
debug = 0;
@@ -497,6 +491,10 @@ main(int argc, char *argv[])
log_init(1, LOG_MAIL);
+ if ((conf = config_default()) == NULL)
+ fatal("config_default");
+ env = conf;
+
TAILQ_INIT(&offline_q);
while ((c = getopt(argc, argv, "B:dD:hnP:f:FT:vx:")) != -1) {
@@ -617,7 +615,7 @@ main(int argc, char *argv[])
if (strlcpy(env->sc_conffile, conffile, PATH_MAX)
>= PATH_MAX)
- errx(1, "config file exceeds PATH_MAX");
+ fatalx("config file exceeds PATH_MAX");
if (env->sc_opts & SMTPD_OPT_NOACTION) {
if (env->sc_queue_key &&
@@ -636,7 +634,7 @@ main(int argc, char *argv[])
/* check for root privileges */
if (geteuid())
- errx(1, "need root privileges");
+ fatalx("need root privileges");
log_init(foreground_log, LOG_MAIL);
log_trace_verbose(tracing);
@@ -648,7 +646,7 @@ main(int argc, char *argv[])
log_debug("debug: using \"%s\" stat backend", backend_stat);
if (env->sc_hostname[0] == '\0')
- errx(1, "machine does not have a hostname set");
+ fatalx("machine does not have a hostname set");
env->sc_uptime = time(NULL);
if (rexec == NULL) {
@@ -660,12 +658,12 @@ main(int argc, char *argv[])
password = getpass("queue key: ");
if (password == NULL)
- err(1, "getpass");
+ fatal("getpass");
env->sc_queue_key = strdup(password);
explicit_bzero(password, strlen(password));
if (env->sc_queue_key == NULL)
- err(1, "strdup");
+ fatal("strdup");
}
else {
char *buf = NULL;
@@ -674,7 +672,7 @@ main(int argc, char *argv[])
if (strcasecmp(env->sc_queue_key, "stdin") == 0) {
if ((len = getline(&buf, &sz, stdin)) == -1)
- err(1, "getline");
+ fatal("getline");
if (buf[len - 1] == '\n')
buf[len - 1] = '\0';
env->sc_queue_key = buf;
@@ -686,7 +684,7 @@ main(int argc, char *argv[])
if (!foreground)
if (daemon(0, 0) == -1)
- err(1, "failed to daemonize");
+ fatal("failed to daemonize");
/* setup all processes */
@@ -756,7 +754,7 @@ main(int argc, char *argv[])
env->sc_stat = stat_backend_lookup(backend_stat);
if (env->sc_stat == NULL)
- errx(1, "could not find stat backend \"%s\"", backend_stat);
+ fatalx("could not find stat backend \"%s\"", backend_stat);
return control();
}
@@ -783,7 +781,7 @@ main(int argc, char *argv[])
env->sc_comp = compress_backend_lookup("gzip");
if (!queue_init(backend_queue, 1))
- errx(1, "could not initialize queue backend");
+ fatalx("could not initialize queue backend");
return queue();
}
@@ -1088,7 +1086,7 @@ smtpd(void) {
if (pledge("stdio rpath wpath cpath fattr tmppath "
"getpw sendfd proc exec id inet chown unix", NULL) == -1)
- err(1, "pledge");
+ fatal("pledge");
event_dispatch();
fatalx("exited event loop");
@@ -1189,7 +1187,7 @@ fork_proc_backend(const char *key, const char *conf, const char *procname)
procname = name;
execl(path, procname, arg, (char *)NULL);
- err(1, "execl: %s", path);
+ fatal("execl: %s", path);
}
/* parent process */
@@ -1310,24 +1308,24 @@ fork_filter_process(const char *name, const char *command, const char *user, con
if (user == NULL)
user = SMTPD_USER;
if ((pw = getpwnam(user)) == NULL)
- err(1, "getpwnam");
+ fatal("getpwnam");
if (group) {
if ((gr = getgrnam(group)) == NULL)
- err(1, "getgrnam");
+ fatal("getgrnam");
}
else {
if ((gr = getgrgid(pw->pw_gid)) == NULL)
- err(1, "getgrgid");
+ fatal("getgrgid");
}
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, sp) == -1)
- err(1, "socketpair");
+ fatal("socketpair");
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, errfd) == -1)
- err(1, "socketpair");
+ fatal("socketpair");
if ((pid = fork()) == -1)
- err(1, "fork");
+ fatal("fork");
/* parent passes the child fd over to lka */
if (pid > 0) {
@@ -1351,24 +1349,24 @@ fork_filter_process(const char *name, const char *command, const char *user, con
if (chroot_path) {
if (chroot(chroot_path) != 0 || chdir("/") != 0)
- err(1, "chroot: %s", chroot_path);
+ fatal("chroot: %s", chroot_path);
}
if (setgroups(1, &gr->gr_gid) ||
setresgid(gr->gr_gid, gr->gr_gid, gr->gr_gid) ||
setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid))
- err(1, "fork_filter_process: cannot drop privileges");
+ fatal("fork_filter_process: cannot drop privileges");
if (closefrom(STDERR_FILENO + 1) == -1)
- err(1, "closefrom");
+ fatal("closefrom");
if (setsid() == -1)
- err(1, "setsid");
+ fatal("setsid");
if (signal(SIGPIPE, SIG_DFL) == SIG_ERR ||
signal(SIGINT, SIG_DFL) == SIG_ERR ||
signal(SIGTERM, SIG_DFL) == SIG_ERR ||
signal(SIGCHLD, SIG_DFL) == SIG_ERR ||
signal(SIGHUP, SIG_DFL) == SIG_ERR)
- err(1, "signal");
+ fatal("signal");
if (command[0] == '/')
execr = snprintf(exec, sizeof(exec), "exec %s", command);
@@ -1376,7 +1374,7 @@ fork_filter_process(const char *name, const char *command, const char *user, con
execr = snprintf(exec, sizeof(exec), "exec %s/%s",
PATH_LIBEXEC, command);
if (execr >= (int) sizeof(exec))
- errx(1, "%s: exec path too long", name);
+ fatalx("%s: exec path too long", name);
/*
* Wait for lka to acknowledge that it received the fd.
@@ -1387,9 +1385,9 @@ fork_filter_process(const char *name, const char *command, const char *user, con
* never going to be read from we can shutdown(2) the write-end in lka.
*/
if (read(STDERR_FILENO, &buf, 1) != 0)
- errx(1, "lka didn't properly close write end of error socket");
+ fatalx("lka didn't properly close write end of error socket");
if (system(exec) == -1)
- err(1, NULL);
+ fatal("system");
/* there's no successful exit from a processor */
_exit(1);
@@ -1521,25 +1519,25 @@ forkmda(struct mproc *p, uint64_t id, struct deliver *deliver)
mda_mbox_init(deliver);
if (chdir(pw_dir) == -1 && chdir("/") == -1)
- err(1, "chdir");
+ fatal("chdir");
if (setgroups(1, &pw_gid) ||
setresgid(pw_gid, pw_gid, pw_gid) ||
setresuid(pw_uid, pw_uid, pw_uid))
- err(1, "forkmda: cannot drop privileges");
+ fatal("forkmda: cannot drop privileges");
if (dup2(pipefd[0], STDIN_FILENO) == -1 ||
dup2(allout, STDOUT_FILENO) == -1 ||
dup2(allout, STDERR_FILENO) == -1)
- err(1, "forkmda: dup2");
+ fatal("forkmda: dup2");
if (closefrom(STDERR_FILENO + 1) == -1)
- err(1, "closefrom");
+ fatal("closefrom");
if (setsid() == -1)
- err(1, "setsid");
+ fatal("setsid");
if (signal(SIGPIPE, SIG_DFL) == SIG_ERR ||
signal(SIGINT, SIG_DFL) == SIG_ERR ||
signal(SIGTERM, SIG_DFL) == SIG_ERR ||
signal(SIGCHLD, SIG_DFL) == SIG_ERR ||
signal(SIGHUP, SIG_DFL) == SIG_ERR)
- err(1, "signal");
+ fatal("signal");
/* avoid hangs by setting 5m timeout */
alarm(300);
diff --git a/usr.sbin/smtpd/srs.c b/usr.sbin/smtpd/srs.c
index 05737d8d9c9..84e3d34595c 100644
--- a/usr.sbin/smtpd/srs.c
+++ b/usr.sbin/smtpd/srs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: srs.c,v 1.3 2019/09/29 10:03:49 gilles Exp $ */
+/* $OpenBSD: srs.c,v 1.4 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2019 Gilles Chehade <gilles@poolp.org>
@@ -22,7 +22,6 @@
#include <sys/socket.h>
#include <ctype.h>
-#include <err.h>
#include <errno.h>
#include <event.h>
#include <imsg.h>
diff --git a/usr.sbin/smtpd/table_db.c b/usr.sbin/smtpd/table_db.c
index 97013ed5170..8fb9d568ddd 100644
--- a/usr.sbin/smtpd/table_db.c
+++ b/usr.sbin/smtpd/table_db.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: table_db.c,v 1.22 2021/01/23 16:11:11 rob Exp $ */
+/* $OpenBSD: table_db.c,v 1.23 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@poolp.org>
@@ -27,7 +27,6 @@
#include <db.h>
#include <ctype.h>
-#include <err.h>
#include <event.h>
#include <fcntl.h>
#include <imsg.h>
@@ -261,7 +260,7 @@ table_db_get_entry(void *hdl, const char *key, size_t *len)
/* workaround the stupidity of the DB interface */
if (strlcpy(pkey, key, sizeof pkey) >= sizeof pkey)
- errx(1, "table_db_get_entry: key too long");
+ fatalx("table_db_get_entry: key too long");
dbk.data = pkey;
dbk.size = strlen(pkey) + 1;
diff --git a/usr.sbin/smtpd/table_getpwnam.c b/usr.sbin/smtpd/table_getpwnam.c
index 78e6edc26da..f8bcb613d0f 100644
--- a/usr.sbin/smtpd/table_getpwnam.c
+++ b/usr.sbin/smtpd/table_getpwnam.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: table_getpwnam.c,v 1.12 2018/12/27 14:23:41 eric Exp $ */
+/* $OpenBSD: table_getpwnam.c,v 1.13 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2012 Gilles Chehade <gilles@poolp.org>
@@ -22,7 +22,6 @@
#include <sys/socket.h>
#include <ctype.h>
-#include <err.h>
#include <errno.h>
#include <event.h>
#include <fcntl.h>
diff --git a/usr.sbin/smtpd/to.c b/usr.sbin/smtpd/to.c
index 8a285f666c6..930da94ae9d 100644
--- a/usr.sbin/smtpd/to.c
+++ b/usr.sbin/smtpd/to.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: to.c,v 1.46 2021/03/05 12:37:32 eric Exp $ */
+/* $OpenBSD: to.c,v 1.47 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2009 Jacek Masiulaniec <jacekm@dobremiasto.net>
@@ -29,7 +29,6 @@
#include <arpa/inet.h>
#include <ctype.h>
-#include <err.h>
#include <errno.h>
#include <event.h>
#include <fcntl.h>
diff --git a/usr.sbin/smtpd/tree.c b/usr.sbin/smtpd/tree.c
index 70aef047ebb..a3e9e443410 100644
--- a/usr.sbin/smtpd/tree.c
+++ b/usr.sbin/smtpd/tree.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tree.c,v 1.6 2018/12/23 16:06:24 gilles Exp $ */
+/* $OpenBSD: tree.c,v 1.7 2021/05/26 18:08:55 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
@@ -19,12 +19,12 @@
#include <sys/types.h>
#include <sys/tree.h>
-#include <err.h>
#include <inttypes.h>
#include <stdlib.h>
#include <limits.h>
#include "tree.h"
+#include "log.h"
struct treeentry {
SPLAY_ENTRY(treeentry) entry;
@@ -54,7 +54,7 @@ tree_set(struct tree *t, uint64_t id, void *data)
key.id = id;
if ((entry = SPLAY_FIND(_tree, &t->tree, &key)) == NULL) {
if ((entry = malloc(sizeof *entry)) == NULL)
- err(1, "tree_set: malloc");
+ fatal("tree_set: malloc");
entry->id = id;
SPLAY_INSERT(_tree, &t->tree, entry);
old = NULL;
@@ -73,11 +73,11 @@ tree_xset(struct tree *t, uint64_t id, void *data)
struct treeentry *entry;
if ((entry = malloc(sizeof *entry)) == NULL)
- err(1, "tree_xset: malloc");
+ fatal("tree_xset: malloc");
entry->id = id;
entry->data = data;
if (SPLAY_INSERT(_tree, &t->tree, entry))
- errx(1, "tree_xset(%p, 0x%016"PRIx64 ")", t, id);
+ fatalx("tree_xset(%p, 0x%016"PRIx64 ")", t, id);
t->count += 1;
}
@@ -100,7 +100,7 @@ tree_xget(struct tree *t, uint64_t id)
key.id = id;
if ((entry = SPLAY_FIND(_tree, &t->tree, &key)) == NULL)
- errx(1, "tree_get(%p, 0x%016"PRIx64 ")", t, id);
+ fatalx("tree_get(%p, 0x%016"PRIx64 ")", t, id);
return (entry->data);
}
@@ -131,7 +131,7 @@ tree_xpop(struct tree *t, uint64_t id)
key.id = id;
if ((entry = SPLAY_FIND(_tree, &t->tree, &key)) == NULL)
- errx(1, "tree_xpop(%p, 0x%016" PRIx64 ")", t, id);
+ fatalx("tree_xpop(%p, 0x%016" PRIx64 ")", t, id);
data = entry->data;
SPLAY_REMOVE(_tree, &t->tree, entry);
@@ -238,7 +238,7 @@ tree_merge(struct tree *dst, struct tree *src)
entry = SPLAY_ROOT(&src->tree);
SPLAY_REMOVE(_tree, &src->tree, entry);
if (SPLAY_INSERT(_tree, &dst->tree, entry))
- errx(1, "tree_merge: duplicate");
+ fatalx("tree_merge: duplicate");
}
dst->count += src->count;
src->count = 0;