diff options
author | Charles Longeau <chl@cvs.openbsd.org> | 2011-11-14 19:23:42 +0000 |
---|---|---|
committer | Charles Longeau <chl@cvs.openbsd.org> | 2011-11-14 19:23:42 +0000 |
commit | 3cdc9e7396dc6bfc44033c5a2fa492b936d0e203 (patch) | |
tree | 72009109e5daecd5fb43a8facf02b6ab882810e9 /usr.sbin | |
parent | 5405050e987e8e19afed4cd784410a28a487d946 (diff) |
when receiving an unexpected imsg, print its name.
with help and ideas from eric@
ok eric@ gilles@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/smtpd/control.c | 9 | ||||
-rw-r--r-- | usr.sbin/smtpd/lka.c | 5 | ||||
-rw-r--r-- | usr.sbin/smtpd/mda.c | 5 | ||||
-rw-r--r-- | usr.sbin/smtpd/mfa.c | 5 | ||||
-rw-r--r-- | usr.sbin/smtpd/mta.c | 5 | ||||
-rw-r--r-- | usr.sbin/smtpd/queue.c | 5 | ||||
-rw-r--r-- | usr.sbin/smtpd/runner.c | 4 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtp.c | 5 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.c | 13 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.h | 4 |
10 files changed, 36 insertions, 24 deletions
diff --git a/usr.sbin/smtpd/control.c b/usr.sbin/smtpd/control.c index efa95132f87..632c459b8f2 100644 --- a/usr.sbin/smtpd/control.c +++ b/usr.sbin/smtpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.62 2011/10/26 20:47:31 gilles Exp $ */ +/* $OpenBSD: control.c,v 1.63 2011/11/14 19:23:41 chl Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -25,6 +25,7 @@ #include <sys/socket.h> #include <sys/un.h> +#include <err.h> #include <errno.h> #include <event.h> #include <fcntl.h> @@ -95,7 +96,8 @@ control_imsg(struct imsgev *iev, struct imsg *imsg) } } - fatalx("control_imsg: unexpected imsg"); + errx(1, "control_imsg: unexpected %s imsg", + imsg_to_str(imsg->hdr.type)); } void @@ -515,7 +517,8 @@ control_dispatch_ext(int fd, short event, void *arg) } default: log_debug("control_dispatch_ext: " - "error handling imsg %d", imsg.hdr.type); + "error handling %s imsg", + imsg_to_str(imsg.hdr.type)); break; } imsg_free(&imsg); diff --git a/usr.sbin/smtpd/lka.c b/usr.sbin/smtpd/lka.c index 3f3f1bd6633..befbafc38d8 100644 --- a/usr.sbin/smtpd/lka.c +++ b/usr.sbin/smtpd/lka.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lka.c,v 1.130 2011/10/23 15:36:53 eric Exp $ */ +/* $OpenBSD: lka.c,v 1.131 2011/11/14 19:23:41 chl Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -27,6 +27,7 @@ #include <netinet/in.h> #include <ctype.h> +#include <err.h> #include <errno.h> #include <event.h> #include <imsg.h> @@ -201,7 +202,7 @@ lka_imsg(struct imsgev *iev, struct imsg *imsg) } } - fatalx("lka_imsg: unexpected imsg"); + errx(1, "lka_imsg: unexpected %s imsg", imsg_to_str(imsg->hdr.type)); } static void diff --git a/usr.sbin/smtpd/mda.c b/usr.sbin/smtpd/mda.c index 0e3c5c19175..0a86f5fd405 100644 --- a/usr.sbin/smtpd/mda.c +++ b/usr.sbin/smtpd/mda.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mda.c,v 1.62 2011/10/27 14:32:57 chl Exp $ */ +/* $OpenBSD: mda.c,v 1.63 2011/11/14 19:23:41 chl Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -24,6 +24,7 @@ #include <sys/param.h> #include <sys/socket.h> +#include <err.h> #include <event.h> #include <imsg.h> #include <inttypes.h> @@ -248,7 +249,7 @@ mda_imsg(struct imsgev *iev, struct imsg *imsg) } } - fatalx("mda_imsg: unexpected imsg"); + errx(1, "mda_imsg: unexpected %s imsg", imsg_to_str(imsg->hdr.type)); } static void diff --git a/usr.sbin/smtpd/mfa.c b/usr.sbin/smtpd/mfa.c index 4532b5c5080..16658d9121f 100644 --- a/usr.sbin/smtpd/mfa.c +++ b/usr.sbin/smtpd/mfa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mfa.c,v 1.65 2011/11/10 17:37:08 chl Exp $ */ +/* $OpenBSD: mfa.c,v 1.66 2011/11/14 19:23:41 chl Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -24,6 +24,7 @@ #include <sys/param.h> #include <sys/socket.h> +#include <err.h> #include <errno.h> #include <event.h> #include <imsg.h> @@ -119,7 +120,7 @@ mfa_imsg(struct imsgev *iev, struct imsg *imsg) } } - fatalx("mfa_imsg: unexpected imsg"); + errx(1, "mfa_imsg: unexpected %s imsg", imsg_to_str(imsg->hdr.type)); } static void diff --git a/usr.sbin/smtpd/mta.c b/usr.sbin/smtpd/mta.c index 7e4ff39d3d9..2af2c62e50b 100644 --- a/usr.sbin/smtpd/mta.c +++ b/usr.sbin/smtpd/mta.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mta.c,v 1.118 2011/10/27 14:32:57 chl Exp $ */ +/* $OpenBSD: mta.c,v 1.119 2011/11/14 19:23:41 chl Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -24,6 +24,7 @@ #include <sys/param.h> #include <sys/socket.h> +#include <err.h> #include <errno.h> #include <event.h> #include <imsg.h> @@ -240,7 +241,7 @@ mta_imsg(struct imsgev *iev, struct imsg *imsg) } } - fatalx("mta_imsg: unexpected imsg"); + errx(1, "mta_imsg: unexpected %s imsg", imsg_to_str(imsg->hdr.type)); } static void diff --git a/usr.sbin/smtpd/queue.c b/usr.sbin/smtpd/queue.c index 9d18574c42f..4c175fa39b5 100644 --- a/usr.sbin/smtpd/queue.c +++ b/usr.sbin/smtpd/queue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue.c,v 1.110 2011/11/07 11:14:10 eric Exp $ */ +/* $OpenBSD: queue.c,v 1.111 2011/11/14 19:23:41 chl Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -24,6 +24,7 @@ #include <sys/socket.h> #include <sys/stat.h> +#include <err.h> #include <event.h> #include <imsg.h> #include <libgen.h> @@ -203,7 +204,7 @@ queue_imsg(struct imsgev *iev, struct imsg *imsg) } } - fatalx("queue_imsg: unexpected imsg"); + errx(1, "queue_imsg: unexpected %s imsg", imsg_to_str(imsg->hdr.type)); } static void diff --git a/usr.sbin/smtpd/runner.c b/usr.sbin/smtpd/runner.c index 3ec10dcd932..ec689d279c1 100644 --- a/usr.sbin/smtpd/runner.c +++ b/usr.sbin/smtpd/runner.c @@ -1,4 +1,4 @@ -/* $OpenBSD: runner.c,v 1.123 2011/11/07 11:14:10 eric Exp $ */ +/* $OpenBSD: runner.c,v 1.124 2011/11/14 19:23:41 chl Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -175,7 +175,7 @@ runner_imsg(struct imsgev *iev, struct imsg *imsg) } } - fatalx("runner_imsg: unexpected imsg"); + errx(1, "runner_imsg: unexpected %s imsg", imsg_to_str(imsg->hdr.type)); } void diff --git a/usr.sbin/smtpd/smtp.c b/usr.sbin/smtpd/smtp.c index b3d9e9a21e5..3372833130d 100644 --- a/usr.sbin/smtpd/smtp.c +++ b/usr.sbin/smtpd/smtp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtp.c,v 1.93 2011/10/23 09:30:07 gilles Exp $ */ +/* $OpenBSD: smtp.c,v 1.94 2011/11/14 19:23:41 chl Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -24,6 +24,7 @@ #include <sys/param.h> #include <sys/socket.h> +#include <err.h> #include <errno.h> #include <event.h> #include <imsg.h> @@ -279,7 +280,7 @@ smtp_imsg(struct imsgev *iev, struct imsg *imsg) } } - fatalx("smtp_imsg: unexpected imsg"); + errx(1, "smtp_imsg: unexpected %s imsg", imsg_to_str(imsg->hdr.type)); } static void diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c index 17c01be3a36..7a3b9f2eb63 100644 --- a/usr.sbin/smtpd/smtpd.c +++ b/usr.sbin/smtpd/smtpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.c,v 1.136 2011/11/14 11:53:10 eric Exp $ */ +/* $OpenBSD: smtpd.c,v 1.137 2011/11/14 19:23:41 chl Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -161,7 +161,7 @@ parent_imsg(struct imsgev *iev, struct imsg *imsg) } } - fatalx("parent_imsg: unexpected imsg"); + errx(1, "parent_imsg: unexpected %s imsg", imsg_to_str(imsg->hdr.type)); } static void @@ -1155,9 +1155,6 @@ imsg_dispatch(int fd, short event, void *p) SPLAY_GENERATE(childtree, child, entry, child_cmp); -const char * proc_to_str(int); -const char * imsg_to_str(int); - void log_imsg(int to, int from, struct imsg *imsg) { @@ -1191,6 +1188,8 @@ proc_to_str(int proc) const char * imsg_to_str(int type) { + static char buf[32]; + switch(type) { CASE(IMSG_NONE); CASE(IMSG_CTL_OK); @@ -1260,6 +1259,8 @@ imsg_to_str(int type) CASE(IMSG_DNS_MX); CASE(IMSG_DNS_PTR); default: - return "IMSG_???"; + snprintf(buf, sizeof(buf), "IMSG_??? (%d)", type); + + return buf; } } diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h index cc2b2f0596f..57f72ae1191 100644 --- a/usr.sbin/smtpd/smtpd.h +++ b/usr.sbin/smtpd/smtpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.h,v 1.249 2011/11/14 11:53:10 eric Exp $ */ +/* $OpenBSD: smtpd.h,v 1.250 2011/11/14 19:23:41 chl Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -1162,6 +1162,8 @@ void imsg_event_add(struct imsgev *); void imsg_compose_event(struct imsgev *, u_int16_t, u_int32_t, pid_t, int, void *, u_int16_t); void imsg_dispatch(int, short, void *); +const char * proc_to_str(int); +const char * imsg_to_str(int); SPLAY_PROTOTYPE(childtree, child, entry, child_cmp); |