This diff replaces calls to err(3)/errx(3) with fatal()/fatalx() from
log.c for code that runs in the deamon (we want errors logged to
syslog, not stderr). It's pretty mechanical, with two things to note:
The call to default_config() has to be done after log_init() in smtpd.c,
and log_init() is called early in smtpctl.c, since it uses files (iobuf.c)
that uses the log api. It still logs to stderr though.
Eric.
Index: bounce.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/bounce.c,v
retrieving revision 1.83
diff -u -p -r1.83 bounce.c
--- bounce.c 31 Dec 2020 08:27:15 -0000 1.83
+++ bounce.c 26 May 2021 11:14:04 -0000
@@ -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);
Index: ca.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/ca.c,v
retrieving revision 1.38
diff -u -p -r1.38 ca.c
--- ca.c 5 Mar 2021 12:37:32 -0000 1.38
+++ ca.c 26 May 2021 11:17:24 -0000
@@ -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 *im
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));
}
/*
Index: compress_gzip.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/compress_gzip.c,v
retrieving revision 1.11
diff -u -p -r1.11 compress_gzip.c
--- compress_gzip.c 23 Jan 2021 16:11:11 -0000 1.11
+++ compress_gzip.c 26 May 2021 11:14:58 -0000
@@ -24,7 +24,6 @@
#include <sys/stat.h>
#include <ctype.h>
-#include <err.h>
#include <fcntl.h>
#include <imsg.h>
#include <pwd.h>
Index: control.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/control.c,v
retrieving revision 1.126
diff -u -p -r1.126 control.c
--- control.c 31 Dec 2020 08:27:15 -0000 1.126
+++ control.c 26 May 2021 11:15:39 -0000
@@ -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 ims
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");
Index: dict.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/dict.c,v
retrieving revision 1.6
diff -u -p -r1.6 dict.c
--- dict.c 23 Dec 2018 16:06:24 -0000 1.6
+++ dict.c 26 May 2021 11:16:31 -0000
@@ -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,
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
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
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;
Index: dispatcher.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/dispatcher.c,v
retrieving revision 1.3
diff -u -p -r1.3 dispatcher.c
--- dispatcher.c 21 Apr 2021 07:54:10 -0000 1.3
+++ dispatcher.c 26 May 2021 11:17:09 -0000
@@ -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
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");
Index: envelope.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/envelope.c,v
retrieving revision 1.47
diff -u -p -r1.47 envelope.c
--- envelope.c 25 Nov 2019 14:18:32 -0000 1.47
+++ envelope.c 26 May 2021 11:18:02 -0000
@@ -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
/* 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),
Index: ioev.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/ioev.c,v
retrieving revision 1.46
diff -u -p -r1.46 ioev.c
--- ioev.c 20 May 2021 07:33:32 -0000 1.46
+++ ioev.c 26 May 2021 11:18:55 -0000
@@ -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
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, vo
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
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
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);
Index: limit.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/limit.c,v
retrieving revision 1.5
diff -u -p -r1.5 limit.c
--- limit.c 15 Jun 2016 19:59:03 -0000 1.5
+++ limit.c 26 May 2021 11:19:19 -0000
@@ -22,7 +22,6 @@
#include <sys/socket.h>
#include <ctype.h>
-#include <err.h>
#include <event.h>
#include <fcntl.h>
#include <imsg.h>
Index: lka.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/lka.c,v
retrieving revision 1.245
diff -u -p -r1.245 lka.c
--- lka.c 21 Apr 2021 07:54:10 -0000 1.245
+++ lka.c 26 May 2021 11:19:54 -0000
@@ -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 *i
/* 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 *i
}
- 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");
Index: mda.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/mda.c,v
retrieving revision 1.141
diff -u -p -r1.141 mda.c
--- mda.c 3 Oct 2019 08:50:08 -0000 1.141
+++ mda.c 26 May 2021 11:23:41 -0000
@@ -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 *i
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
Index: mproc.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/mproc.c,v
retrieving revision 1.37
diff -u -p -r1.37 mproc.c
--- mproc.c 20 Dec 2020 14:06:12 -0000 1.37
+++ mproc.c 26 May 2021 11:27:08 -0000
@@ -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 *
exit(1);
execv(path, argv);
- err(1, "execv: %s", path);
+ fatal("execv: %s", path);
}
/* parent process */
Index: mta.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/mta.c,v
retrieving revision 1.238
diff -u -p -r1.238 mta.c
--- mta.c 9 Apr 2021 16:43:43 -0000 1.238
+++ mta.c 26 May 2021 11:28:00 -0000
@@ -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 *i
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 *
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 f
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))) {
Index: mta_session.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/mta_session.c,v
retrieving revision 1.141
diff -u -p -r1.141 mta_session.c
--- mta_session.c 20 May 2021 07:33:32 -0000 1.141
+++ mta_session.c 26 May 2021 11:28:34 -0000
@@ -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
return;
default:
- errx(1, "mta_session_imsg: unexpected %s imsg",
+ fatalx("mta_session_imsg: unexpected %s imsg",
imsg_to_str(imsg->hdr.type));
}
}
Index: parse.y
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/parse.y,v
retrieving revision 1.287
diff -u -p -r1.287 parse.y
--- parse.y 9 Apr 2021 16:43:43 -0000 1.287
+++ parse.y 26 May 2021 14:12:04 -0000
@@ -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 *l
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 *l
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
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++) {
Index: proxy.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/proxy.c,v
retrieving revision 1.1
diff -u -p -r1.1 proxy.c
--- proxy.c 10 Aug 2019 16:07:01 -0000 1.1
+++ proxy.c 26 May 2021 11:30:19 -0000
@@ -19,7 +19,6 @@
#include <sys/tree.h>
#include <sys/un.h>
-#include <err.h>
#include <errno.h>
#include <event.h>
#include <imsg.h>
Index: queue.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/queue.c,v
retrieving revision 1.191
diff -u -p -r1.191 queue.c
--- queue.c 31 Dec 2020 08:27:15 -0000 1.191
+++ queue.c 26 May 2021 11:32:27 -0000
@@ -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
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");
Index: queue_backend.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/queue_backend.c,v
retrieving revision 1.66
diff -u -p -r1.66 queue_backend.c
--- queue_backend.c 22 Apr 2020 11:35:34 -0000 1.66
+++ queue_backend.c 26 May 2021 11:33:00 -0000
@@ -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);
Index: queue_fs.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/queue_fs.c,v
retrieving revision 1.20
diff -u -p -r1.20 queue_fs.c
--- queue_fs.c 25 Feb 2020 17:03:13 -0000 1.20
+++ queue_fs.c 26 May 2021 11:33:37 -0000
@@ -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 ser
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);
Index: queue_null.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/queue_null.c,v
retrieving revision 1.8
diff -u -p -r1.8 queue_null.c
--- queue_null.c 30 Dec 2018 23:09:58 -0000 1.8
+++ queue_null.c 26 May 2021 11:33:50 -0000
@@ -23,7 +23,6 @@
#include <sys/stat.h>
#include <ctype.h>
-#include <err.h>
#include <errno.h>
#include <event.h>
#include <fcntl.h>
Index: queue_ram.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/queue_ram.c,v
retrieving revision 1.9
diff -u -p -r1.9 queue_ram.c
--- queue_ram.c 30 Dec 2018 23:09:58 -0000 1.9
+++ queue_ram.c 26 May 2021 11:34:09 -0000
@@ -23,7 +23,6 @@
#include <sys/stat.h>
#include <ctype.h>
-#include <err.h>
#include <errno.h>
#include <event.h>
#include <fcntl.h>
Index: scheduler.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/scheduler.c,v
retrieving revision 1.60
diff -u -p -r1.60 scheduler.c
--- scheduler.c 30 Dec 2018 23:09:58 -0000 1.60
+++ scheduler.c 26 May 2021 11:34:48 -0000
@@ -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 i
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");
Index: scheduler_backend.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/scheduler_backend.c,v
retrieving revision 1.16
diff -u -p -r1.16 scheduler_backend.c
--- scheduler_backend.c 24 May 2018 11:38:24 -0000 1.16
+++ scheduler_backend.c 26 May 2021 11:35:02 -0000
@@ -22,7 +22,6 @@
#include <sys/socket.h>
#include <ctype.h>
-#include <err.h>
#include <event.h>
#include <fcntl.h>
#include <imsg.h>
Index: scheduler_null.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/scheduler_null.c,v
retrieving revision 1.9
diff -u -p -r1.9 scheduler_null.c
--- scheduler_null.c 20 Jan 2015 17:37:54 -0000 1.9
+++ scheduler_null.c 26 May 2021 11:35:14 -0000
@@ -22,7 +22,6 @@
#include <sys/socket.h>
#include <ctype.h>
-#include <err.h>
#include <event.h>
#include <fcntl.h>
#include <imsg.h>
Index: scheduler_ramqueue.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/scheduler_ramqueue.c,v
retrieving revision 1.45
diff -u -p -r1.45 scheduler_ramqueue.c
--- scheduler_ramqueue.c 31 May 2018 21:06:12 -0000 1.45
+++ scheduler_ramqueue.c 26 May 2021 11:36:46 -0000
@@ -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_in
/* 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, uint6
/* 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, st
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, st
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 *
(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)
Index: smtp.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/smtp.c,v
retrieving revision 1.169
diff -u -p -r1.169 smtp.c
--- smtp.c 9 Apr 2021 16:43:43 -0000 1.169
+++ smtp.c 26 May 2021 11:49:39 -0000
@@ -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 *
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
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];
Index: smtpctl.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/smtpctl.c,v
retrieving revision 1.167
diff -u -p -r1.167 smtpctl.c
--- smtpctl.c 24 Feb 2020 16:16:07 -0000 1.167
+++ smtpctl.c 26 May 2021 13:51:39 -0000
@@ -761,7 +761,6 @@ do_show_queue(int argc, struct parameter
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);
@@ -1043,6 +1042,8 @@ main(int argc, char **argv)
gid_t gid;
int privileged;
char *argv_mailq[] = { "show", "queue", NULL };
+
+ log_init(1, LOG_MAIL);
sendmail_compat(argc, argv);
privileged = geteuid() == 0;
Index: smtpd.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/smtpd.c,v
retrieving revision 1.338
diff -u -p -r1.338 smtpd.c
--- smtpd.c 21 Apr 2021 07:54:10 -0000 1.338
+++ smtpd.c 26 May 2021 13:13:56 -0000
@@ -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
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
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, co
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, co
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, co
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, co
* 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, st
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);
Index: srs.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/srs.c,v
retrieving revision 1.3
diff -u -p -r1.3 srs.c
--- srs.c 29 Sep 2019 10:03:49 -0000 1.3
+++ srs.c 26 May 2021 11:48:03 -0000
@@ -22,7 +22,6 @@
#include <sys/socket.h>
#include <ctype.h>
-#include <err.h>
#include <errno.h>
#include <event.h>
#include <imsg.h>
Index: table_db.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/table_db.c,v
retrieving revision 1.22
diff -u -p -r1.22 table_db.c
--- table_db.c 23 Jan 2021 16:11:11 -0000 1.22
+++ table_db.c 26 May 2021 11:48:32 -0000
@@ -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
/* 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;
Index: table_getpwnam.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/table_getpwnam.c,v
retrieving revision 1.12
diff -u -p -r1.12 table_getpwnam.c
--- table_getpwnam.c 27 Dec 2018 14:23:41 -0000 1.12
+++ table_getpwnam.c 26 May 2021 11:48:45 -0000
@@ -22,7 +22,6 @@
#include <sys/socket.h>
#include <ctype.h>
-#include <err.h>
#include <errno.h>
#include <event.h>
#include <fcntl.h>
Index: to.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/to.c,v
retrieving revision 1.46
diff -u -p -r1.46 to.c
--- to.c 5 Mar 2021 12:37:32 -0000 1.46
+++ to.c 26 May 2021 11:48:58 -0000
@@ -29,7 +29,6 @@
#include <arpa/inet.h>
#include <ctype.h>
-#include <err.h>
#include <errno.h>
#include <event.h>
#include <fcntl.h>
Index: tree.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/tree.c,v
retrieving revision 1.6
diff -u -p -r1.6 tree.c
--- tree.c 23 Dec 2018 16:06:24 -0000 1.6
+++ tree.c 26 May 2021 11:11:38 -0000
@@ -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, vo
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, v
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
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;