summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2017-02-12 15:53:16 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2017-02-12 15:53:16 +0000
commite0d022709b1895766e0aa7edeb04b5e9ed6aba67 (patch)
treea7799e17195a2474e137dffa171a1a892513781a
parentc4753dffce93b557829da7cc90df822d2be8bbb7 (diff)
Eliminate most strerror() invocations by using log_warn() and fatal()
instead of log_warnx() and fatalx(). A few log_info() to log_warn() for the same reason. Suggested by millert@.
-rw-r--r--sbin/dhclient/bpf.c31
-rw-r--r--sbin/dhclient/dhclient.c70
-rw-r--r--sbin/dhclient/dispatch.c24
-rw-r--r--sbin/dhclient/kroute.c61
-rw-r--r--sbin/dhclient/privsep.c5
5 files changed, 80 insertions, 111 deletions
diff --git a/sbin/dhclient/bpf.c b/sbin/dhclient/bpf.c
index af29ad03df3..bd0463dfab1 100644
--- a/sbin/dhclient/bpf.c
+++ b/sbin/dhclient/bpf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.c,v 1.46 2017/02/12 13:55:01 krw Exp $ */
+/* $OpenBSD: bpf.c,v 1.47 2017/02/12 15:53:15 krw Exp $ */
/* BPF socket interface code, originally contributed by Archie Cobbs. */
@@ -79,13 +79,12 @@ if_register_bpf(struct interface_info *ifi)
int sock;
if ((sock = open("/dev/bpf0", O_RDWR | O_CLOEXEC)) == -1)
- fatalx("Can't open bpf: %s", strerror(errno));
+ fatal("Can't open bpf");
/* Set the BPF device to point at this interface. */
strlcpy(ifr.ifr_name, ifi->name, IFNAMSIZ);
if (ioctl(sock, BIOCSETIF, &ifr) < 0)
- fatalx("Can't attach interface %s to /dev/bpf0: %s",
- ifi->name, strerror(errno));
+ fatal("Can't attach interface %s to /dev/bpf0", ifi->name);
return (sock);
}
@@ -99,13 +98,13 @@ if_register_send(struct interface_info *ifi)
* Use raw socket for unicast send.
*/
if ((sock = socket(AF_INET, SOCK_RAW, IPPROTO_UDP)) == -1)
- fatalx("socket(SOCK_RAW): %s", strerror(errno));
+ fatal("socket(SOCK_RAW)");
if (setsockopt(sock, IPPROTO_IP, IP_HDRINCL, &on,
sizeof(on)) == -1)
- fatalx("setsockopt(IP_HDRINCL): %s", strerror(errno));
+ fatal("setsockopt(IP_HDRINCL)");
if (setsockopt(sock, IPPROTO_IP, SO_RTABLE, &ifi->rdomain,
sizeof(ifi->rdomain)) == -1)
- fatalx("setsockopt(SO_RTABLE): %s", strerror(errno));
+ fatal("setsockopt(SO_RTABLE)");
ifi->ufdesc = sock;
}
@@ -197,7 +196,7 @@ if_register_receive(struct interface_info *ifi)
/* Make sure the BPF version is in range. */
if (ioctl(ifi->bfdesc, BIOCVERSION, &v) < 0)
- fatalx("Can't get BPF version: %s", strerror(errno));
+ fatal("Can't get BPF version");
if (v.bv_major != BPF_MAJOR_VERSION ||
v.bv_minor < BPF_MINOR_VERSION)
@@ -210,16 +209,14 @@ if_register_receive(struct interface_info *ifi)
* with packets.
*/
if (ioctl(ifi->bfdesc, BIOCIMMEDIATE, &flag) < 0)
- fatalx("Can't set immediate mode on bpf device: %s",
- strerror(errno));
+ fatal("Can't set immediate mode on bpf device");
if (ioctl(ifi->bfdesc, BIOCSFILDROP, &flag) < 0)
- fatalx("Can't set filter-drop mode on bpf device: %s",
- strerror(errno));
+ fatal("Can't set filter-drop mode on bpf device");
/* Get the required BPF buffer length from the kernel. */
if (ioctl(ifi->bfdesc, BIOCGBLEN, &sz) < 0)
- fatalx("Can't get bpf buffer length: %s", strerror(errno));
+ fatal("Can't get bpf buffer length");
ifi->rbuf_max = sz;
ifi->rbuf = malloc(ifi->rbuf_max);
if (!ifi->rbuf)
@@ -240,8 +237,7 @@ if_register_receive(struct interface_info *ifi)
dhcp_bpf_filter[8].k = LOCAL_PORT;
if (ioctl(ifi->bfdesc, BIOCSETF, &p) < 0)
- fatalx("Can't install packet filter program: %s",
- strerror(errno));
+ fatal("Can't install packet filter program");
/* Set up the bpf write filter program structure. */
p.bf_len = dhcp_bpf_wfilter_len;
@@ -251,8 +247,7 @@ if_register_receive(struct interface_info *ifi)
dhcp_bpf_wfilter[7].k = htons(IP_MF|IP_OFFMASK);
if (ioctl(ifi->bfdesc, BIOCSETWF, &p) < 0)
- fatalx("Can't install write filter program: %s",
- strerror(errno));
+ fatal("Can't install write filter program");
if (ioctl(ifi->bfdesc, BIOCLOCK, NULL) < 0)
fatalx("Cannot lock bpf");
@@ -331,7 +326,7 @@ send_packet(struct interface_info *ifi, struct in_addr from, struct in_addr to)
}
if (result == -1)
- log_warnx("send_packet: %s", strerror(errno));
+ log_warn("send_packet");
return (result);
}
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 41c2258f9bb..1ebbcb66077 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.396 2017/02/12 13:55:01 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.397 2017/02/12 15:53:15 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -523,15 +523,14 @@ main(int argc, char *argv[])
/* Put us into the correct rdomain */
ifi->rdomain = get_rdomain(ifi->name);
if (setrtable(ifi->rdomain) == -1)
- fatalx("setting routing table to %u: '%s'", ifi->rdomain,
- strerror(errno));
+ fatal("setting routing table to %u", ifi->rdomain);
if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC,
PF_UNSPEC, socket_fd) == -1)
- fatalx("socketpair: %s", strerror(errno));
+ fatal("socketpair");
if ((nullfd = open(_PATH_DEVNULL, O_RDWR, 0)) == -1)
- fatalx("cannot open %s: %s", _PATH_DEVNULL, strerror(errno));
+ fatal("cannot open %s", _PATH_DEVNULL);
fork_privchld(ifi, socket_fd[0], socket_fd[1]);
@@ -590,22 +589,19 @@ main(int argc, char *argv[])
tailfd = open("/etc/resolv.conf.tail", O_RDONLY);
if (tailfd == -1) {
if (errno != ENOENT)
- fatalx("Cannot open /etc/resolv.conf.tail: %s",
- strerror(errno));
+ fatal("Cannot open /etc/resolv.conf.tail");
} else if (fstat(tailfd, &sb) == -1) {
- fatalx("Cannot stat /etc/resolv.conf.tail: %s",
- strerror(errno));
+ fatal("Cannot stat /etc/resolv.conf.tail");
} else {
if (sb.st_size > 0 && sb.st_size < SIZE_MAX) {
config->resolv_tail = calloc(1, sb.st_size + 1);
if (config->resolv_tail == NULL) {
fatalx("no memory for resolv.conf.tail "
- "contents: %s", strerror(errno));
+ "contents");
}
tailn = read(tailfd, config->resolv_tail, sb.st_size);
if (tailn == -1)
- fatalx("Couldn't read resolv.conf.tail: %s",
- strerror(errno));
+ fatal("Couldn't read resolv.conf.tail");
else if (tailn == 0)
fatalx("Got no data from resolv.conf.tail");
else if (tailn != sb.st_size)
@@ -616,11 +612,10 @@ main(int argc, char *argv[])
if ((fd = open(path_dhclient_db,
O_RDONLY|O_EXLOCK|O_CREAT|O_NOFOLLOW, 0640)) == -1)
- fatalx("can't open and lock %s: %s", path_dhclient_db,
- strerror(errno));
+ fatal("can't open and lock %s", path_dhclient_db);
read_client_leases(ifi);
if ((leaseFile = fopen(path_dhclient_db, "w")) == NULL)
- fatalx("can't open %s: %s", path_dhclient_db, strerror(errno));
+ fatal("can't open %s", path_dhclient_db);
rewrite_client_leases(ifi);
close(fd);
@@ -635,17 +630,17 @@ main(int argc, char *argv[])
interface_link_forceup(ifi->name);
if ((routefd = socket(PF_ROUTE, SOCK_RAW, 0)) == -1)
- fatalx("socket(PF_ROUTE, SOCK_RAW): %s", strerror(errno));
+ fatal("socket(PF_ROUTE, SOCK_RAW)");
rtfilter = ROUTE_FILTER(RTM_NEWADDR) | ROUTE_FILTER(RTM_DELADDR) |
ROUTE_FILTER(RTM_IFINFO) | ROUTE_FILTER(RTM_IFANNOUNCE);
if (setsockopt(routefd, PF_ROUTE, ROUTE_MSGFILTER,
&rtfilter, sizeof(rtfilter)) == -1)
- fatalx("setsockopt(ROUTE_MSGFILTER): %s", strerror(errno));
+ fatal("setsockopt(ROUTE_MSGFILTER)");
if (setsockopt(routefd, AF_ROUTE, ROUTE_TABLEFILTER, &ifi->rdomain,
sizeof(ifi->rdomain)) == -1)
- fatalx("setsockopt(ROUTE_TABLEFILTER): %s", strerror(errno));
+ fatal("setsockopt(ROUTE_TABLEFILTER)");
/* Register the interface. */
if_register_receive(ifi);
@@ -1200,7 +1195,7 @@ addressinuse(struct interface_info *ifi, struct in_addr address, char *ifname)
int used = 0;
if (getifaddrs(&ifap) != 0) {
- log_warnx("addressinuse: getifaddrs: %s", strerror(errno));
+ log_warn("addressinuse: getifaddrs");
return (0);
}
@@ -2068,7 +2063,7 @@ go_daemon(void)
log_setverbose(0);
if (rdaemon(nullfd) == -1)
- fatalx("Cannot daemonize: %s", strerror(errno));
+ fatal("Cannot daemonize");
/* Catch stuff that might be trying to terminate the program. */
signal(SIGHUP, sighdlr);
@@ -2210,7 +2205,7 @@ fork_privchld(struct interface_info *ifi, int fd, int fd2)
pfd[0].events = POLLIN;
if ((nfds = poll(pfd, 1, INFTIM)) == -1) {
if (errno != EINTR) {
- log_warnx("poll error: %s", strerror(errno));
+ log_warn("poll error");
quit = INTERNALSIG;
}
continue;
@@ -2220,7 +2215,7 @@ fork_privchld(struct interface_info *ifi, int fd, int fd2)
continue;
if ((n = imsg_read(priv_ibuf)) == -1 && errno != EAGAIN) {
- log_warnx("imsg_read(priv_ibuf): %s", strerror(errno));
+ log_warn("imsg_read(priv_ibuf)");
quit = INTERNALSIG;
continue;
}
@@ -2241,8 +2236,7 @@ fork_privchld(struct interface_info *ifi, int fd, int fd2)
/* Truncate the file so monitoring process see exit. */
rslt = truncate(path_option_db, 0);
if (rslt == -1)
- log_warnx("Unable to truncate '%s': %s",
- path_option_db, strerror(errno));
+ log_warn("Unable to truncate '%s'", path_option_db);
}
/*
@@ -2261,8 +2255,7 @@ fork_privchld(struct interface_info *ifi, int fd, int fd2)
log_warnx("%s; restarting.", strsignal(quit));
signal(SIGHUP, SIG_IGN); /* will be restored after exec */
execvp(saved_argv[0], saved_argv);
- fatalx("RESTART FAILED: '%s': %s", saved_argv[0],
- strerror(errno));
+ fatal("RESTART FAILED: '%s'", saved_argv[0]);
}
if (quit != INTERNALSIG)
@@ -2287,13 +2280,13 @@ get_ifname(struct interface_info *ifi, char *arg)
if (ioctl(s, SIOCGIFGMEMB, (caddr_t)&ifgr) == -1) {
if (errno == ENOENT)
fatalx("no interface in group egress found");
- fatalx("ioctl SIOCGIFGMEMB: %s", strerror(errno));
+ fatal("ioctl SIOCGIFGMEMB");
}
len = ifgr.ifgr_len;
if ((ifgr.ifgr_groups = calloc(1, len)) == NULL)
fatalx("get_ifname");
if (ioctl(s, SIOCGIFGMEMB, (caddr_t)&ifgr) == -1)
- fatalx("ioctl SIOCGIFGMEMB: %s", strerror(errno));
+ fatal("ioctl SIOCGIFGMEMB");
arg = NULL;
for (ifg = ifgr.ifgr_groups;
@@ -2305,7 +2298,7 @@ get_ifname(struct interface_info *ifi, char *arg)
}
if (strlcpy(ifi->name, arg, IFNAMSIZ) >= IFNAMSIZ)
- fatalx("Interface name too long: %s", strerror(errno));
+ fatal("Interface name too long");
free(ifgr.ifgr_groups);
close(s);
@@ -2644,8 +2637,7 @@ write_resolv_conf(u_int8_t *contents, size_t sz)
rslt = imsg_compose(unpriv_ibuf, IMSG_WRITE_RESOLV_CONF,
0, 0, -1, contents, sz);
if (rslt == -1)
- log_warnx("write_resolv_conf: imsg_compose: %s",
- strerror(errno));
+ log_warn("write_resolv_conf: imsg_compose");
flush_unpriv_ibuf("write_resolv_conf");
}
@@ -2658,8 +2650,7 @@ write_option_db(u_int8_t *contents, size_t sz)
rslt = imsg_compose(unpriv_ibuf, IMSG_WRITE_OPTION_DB,
0, 0, -1, contents, sz);
if (rslt == -1)
- log_warnx("write_option_db: imsg_compose: %s",
- strerror(errno));
+ log_warn("write_option_db: imsg_compose");
flush_unpriv_ibuf("write_option_db");
}
@@ -2714,24 +2705,21 @@ priv_write_file(char *path, int flags, mode_t mode,
fd = open(path, flags, mode);
if (fd == -1) {
- log_info("Couldn't open '%s': %s", path, strerror(errno));
+ log_warn("Couldn't open '%s'", path);
return;
}
n = write(fd, contents, sz);
if (n == -1)
- log_info("Couldn't write contents to '%s': %s", path,
- strerror(errno));
+ log_warn("Couldn't write contents to '%s'", path);
else if (n < sz)
- log_info("Short contents write to '%s' (%zd vs %zu)", path,
+ log_warnx("Short contents write to '%s' (%zd vs %zu)", path,
n, sz);
if (fchown(fd, 0, 0) == -1)
- log_info("fchown(fd, %d, %d) of '%s' failed (%s)",
- 0, 0, path, strerror(errno));
+ log_warn("fchown(fd, %d, %d) of '%s' failed", 0, 0, path);
if (fchmod(fd, mode) == -1)
- log_info("fchmod(fd, 0x%x) of '%s' failed (%s)", mode,
- path, strerror(errno));
+ log_warn("fchmod(fd, 0x%x) of '%s' failed", mode, path);
close(fd);
}
diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c
index e3b159a7635..9c47b7bb8e7 100644
--- a/sbin/dhclient/dispatch.c
+++ b/sbin/dhclient/dispatch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dispatch.c,v 1.114 2017/02/12 13:55:01 krw Exp $ */
+/* $OpenBSD: dispatch.c,v 1.115 2017/02/12 15:53:15 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -169,7 +169,7 @@ dispatch(struct interface_info *ifi)
if (errno == EAGAIN || errno == EINTR) {
continue;
} else {
- log_warnx("poll: %s", strerror(errno));
+ log_warn("poll");
quit = INTERNALSIG;
continue;
}
@@ -207,8 +207,7 @@ packethandler(struct interface_info *ifi)
ssize_t result;
if ((result = receive_packet(ifi, &from, &hfrom)) == -1) {
- log_warnx("%s receive_packet failed: %s", ifi->name,
- strerror(errno));
+ log_warn("%s receive_packet failed", ifi->name);
ifi->errors++;
if (ifi->errors > 20) {
fatalx("%s too many receive_packet failures; exiting",
@@ -235,23 +234,20 @@ interface_link_forceup(char *ifname)
memset(&ifr, 0, sizeof(ifr));
strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(sock, SIOCGIFFLAGS, (caddr_t)&ifr) == -1) {
- log_info("interface_link_forceup: SIOCGIFFLAGS failed (%s)",
- strerror(errno));
+ log_warn("interface_link_forceup: SIOCGIFFLAGS failed");
return;
}
/* Force it down and up so others notice link state change. */
ifr.ifr_flags &= ~IFF_UP;
if (ioctl(sock, SIOCSIFFLAGS, (caddr_t)&ifr) == -1) {
- log_info("interface_link_forceup: SIOCSIFFLAGS DOWN "
- "failed (%s)", strerror(errno));
+ log_warn("interface_link_forceup: SIOCSIFFLAGS DOWN failed");
return;
}
ifr.ifr_flags |= IFF_UP;
if (ioctl(sock, SIOCSIFFLAGS, (caddr_t)&ifr) == -1) {
- log_info("interface_link_forceup: SIOCSIFFLAGS UP failed (%s)",
- strerror(errno));
+ log_warn("interface_link_forceup: SIOCSIFFLAGS UP failed");
return;
}
}
@@ -267,8 +263,7 @@ interface_status(struct interface_info *ifi)
memset(&ifr, 0, sizeof(ifr));
strlcpy(ifr.ifr_name, ifi->name, sizeof(ifr.ifr_name));
if (ioctl(sock, SIOCGIFFLAGS, &ifr) == -1) {
- fatalx("ioctl(SIOCGIFFLAGS) on %s: %s", ifi->name,
- strerror(errno));
+ fatal("ioctl(SIOCGIFFLAGS) on %s", ifi->name);
}
if ((ifr.ifr_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
@@ -286,8 +281,7 @@ interface_status(struct interface_info *ifi)
*/
#ifdef DEBUG
if (errno != EINVAL && errno != ENOTTY)
- log_debug("ioctl(SIOCGIFMEDIA) on %s: %s", ifi->name,
- strerror(errno));
+ log_debug("ioctl(SIOCGIFMEDIA) on %s", ifi->name);
#endif
ifi->flags |= IFI_NOMEDIA;
@@ -339,7 +333,7 @@ get_rdomain(char *name)
struct ifreq ifr;
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
- fatalx("get_rdomain socket: %s", strerror(errno));
+ fatal("get_rdomain socket");
memset(&ifr, 0, sizeof(ifr));
strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
diff --git a/sbin/dhclient/kroute.c b/sbin/dhclient/kroute.c
index 56c9a0a3cd9..cfe994eac20 100644
--- a/sbin/dhclient/kroute.c
+++ b/sbin/dhclient/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.83 2017/02/12 13:55:01 krw Exp $ */
+/* $OpenBSD: kroute.c,v 1.84 2017/02/12 15:53:15 krw Exp $ */
/*
* Copyright 2012 Kenneth R Westerback <krw@openbsd.org>
@@ -75,7 +75,7 @@ flush_routes(void)
rslt = imsg_compose(unpriv_ibuf, IMSG_FLUSH_ROUTES, 0, 0, -1,
&imsg, sizeof(imsg));
if (rslt == -1)
- log_warnx("flush_routes: imsg_compose: %s", strerror(errno));
+ log_warn("flush_routes: imsg_compose");
flush_unpriv_ibuf("flush_routes");
}
@@ -125,14 +125,14 @@ priv_flush_routes(struct interface_info *ifi, struct imsg_flush_routes *imsg)
}
if (errmsg) {
- log_warnx("route cleanup failed - %s %s (msize=%zu)",
- errmsg, strerror(errno), needed);
+ log_warn("route cleanup failed - %s (msize=%zu)", errmsg,
+ needed);
free(buf);
return;
}
if ((s = socket(AF_ROUTE, SOCK_RAW, 0)) == -1)
- fatalx("opening socket to flush routes: %s", strerror(errno));
+ fatal("opening socket to flush routes");
lim = buf + needed;
for (next = buf; next < lim; next += rtm->rtm_msglen) {
@@ -194,7 +194,7 @@ add_route(struct in_addr dest, struct in_addr netmask,
rslt = imsg_compose(unpriv_ibuf, IMSG_ADD_ROUTE, 0, 0, -1,
&imsg, sizeof(imsg));
if (rslt == -1)
- log_warnx("add_route: imsg_compose: %s", strerror(errno));
+ log_warn("add_route: imsg_compose");
flush_unpriv_ibuf("add_route");
}
@@ -211,7 +211,7 @@ priv_add_route(struct interface_info *ifi, struct imsg_add_route *imsg)
int s, i, iovcnt = 0;
if ((s = socket(AF_ROUTE, SOCK_RAW, 0)) == -1)
- fatalx("Routing Socket open failed: %s", strerror(errno));
+ fatal("Routing Socket open failed");
memset(destbuf, 0, sizeof(destbuf));
memset(maskbuf, 0, sizeof(maskbuf));
@@ -303,9 +303,8 @@ priv_add_route(struct interface_info *ifi, struct imsg_add_route *imsg)
if (writev(s, iov, iovcnt) != -1)
break;
if (i == 4)
- log_warnx("failed to add route (%s/%s via %s/%s): %s",
- destbuf, maskbuf, gatewaybuf, ifabuf,
- strerror(errno));
+ log_warn("failed to add route (%s/%s via %s/%s)",
+ destbuf, maskbuf, gatewaybuf, ifabuf);
else if (errno == EEXIST || errno == ENETUNREACH)
sleep(1);
}
@@ -323,7 +322,7 @@ delete_addresses(struct interface_info *ifi)
struct ifaddrs *ifap, *ifa;
if (getifaddrs(&ifap) != 0)
- fatalx("delete_addresses getifaddrs: %s", strerror(errno));
+ fatal("delete_addresses getifaddrs");
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
if ((ifa->ifa_flags & IFF_LOOPBACK) ||
@@ -361,7 +360,7 @@ delete_address(struct in_addr addr)
rslt = imsg_compose(unpriv_ibuf, IMSG_DELETE_ADDRESS, 0, 0 , -1, &imsg,
sizeof(imsg));
if (rslt == -1)
- log_warnx("delete_address: imsg_compose: %s", strerror(errno));
+ log_warn("delete_address: imsg_compose");
flush_unpriv_ibuf("delete_address");
}
@@ -379,7 +378,7 @@ priv_delete_address(struct interface_info *ifi,
*/
if ((s = socket(AF_INET, SOCK_STREAM, 0)) == -1)
- fatalx("socket open failed: %s", strerror(errno));
+ fatal("socket open failed");
memset(&ifaliasreq, 0, sizeof(ifaliasreq));
strncpy(ifaliasreq.ifra_name, ifi->name, sizeof(ifaliasreq.ifra_name));
@@ -392,8 +391,8 @@ priv_delete_address(struct interface_info *ifi,
/* SIOCDIFADDR will result in a RTM_DELADDR message we must catch! */
if (ioctl(s, SIOCDIFADDR, &ifaliasreq) == -1) {
if (errno != EADDRNOTAVAIL)
- log_warnx("SIOCDIFADDR failed (%s): %s",
- inet_ntoa(imsg->addr), strerror(errno));
+ log_warn("SIOCDIFADDR failed (%s)",
+ inet_ntoa(imsg->addr));
}
close(s);
@@ -415,8 +414,7 @@ set_interface_mtu(int mtu)
rslt = imsg_compose(unpriv_ibuf, IMSG_SET_INTERFACE_MTU, 0, 0, -1,
&imsg, sizeof(imsg));
if (rslt == -1)
- log_warnx("set_interface_mtu: imsg_compose: %s",
- strerror(errno));
+ log_warn("set_interface_mtu: imsg_compose");
flush_unpriv_ibuf("set_interface_mtu");
}
@@ -434,10 +432,9 @@ priv_set_interface_mtu(struct interface_info *ifi,
ifr.ifr_mtu = imsg->mtu;
if ((s = socket(AF_INET, SOCK_STREAM, 0)) == -1)
- fatalx("socket open failed: %s", strerror(errno));
+ fatal("socket open failed");
if (ioctl(s, SIOCSIFMTU, &ifr) == -1)
- log_warnx("SIOCSIFMTU failed (%d): %s", imsg->mtu,
- strerror(errno));
+ log_warn("SIOCSIFMTU failed (%d)", imsg->mtu);
close(s);
}
@@ -461,7 +458,7 @@ add_address(struct in_addr addr, struct in_addr mask)
rslt = imsg_compose(unpriv_ibuf, IMSG_ADD_ADDRESS, 0, 0, -1, &imsg,
sizeof(imsg));
if (rslt == -1)
- log_warnx("add_address: imsg_compose: %s", strerror(errno));
+ log_warn("add_address: imsg_compose");
flush_unpriv_ibuf("add_address");
}
@@ -485,7 +482,7 @@ priv_add_address(struct interface_info *ifi, struct imsg_add_address *imsg)
*/
if ((s = socket(AF_INET, SOCK_STREAM, 0)) == -1)
- fatalx("socket open failed: %s", strerror(errno));
+ fatal("socket open failed");
memset(&ifaliasreq, 0, sizeof(ifaliasreq));
strncpy(ifaliasreq.ifra_name, ifi->name, sizeof(ifaliasreq.ifra_name));
@@ -505,8 +502,7 @@ priv_add_address(struct interface_info *ifi, struct imsg_add_address *imsg)
/* No need to set broadcast address. Kernel can figure it out. */
if (ioctl(s, SIOCAIFADDR, &ifaliasreq) == -1)
- log_warnx("SIOCAIFADDR failed (%s): %s", inet_ntoa(imsg->addr),
- strerror(errno));
+ log_warn("SIOCAIFADDR failed (%s)", inet_ntoa(imsg->addr));
close(s);
@@ -530,7 +526,7 @@ sendhup(struct client_lease *active)
rslt = imsg_compose(unpriv_ibuf, IMSG_HUP, 0, 0, -1,
&imsg, sizeof(imsg));
if (rslt == -1)
- log_warnx("sendhup: imsg_compose: %s", strerror(errno));
+ log_warn("sendhup: imsg_compose");
flush_unpriv_ibuf("sendhup");
}
@@ -574,7 +570,7 @@ resolv_conf_priority(struct interface_info *ifi)
s = socket(PF_ROUTE, SOCK_RAW, AF_INET);
if (s == -1) {
- log_warnx("default route socket: %s", strerror(errno));
+ log_warn("default route socket");
return (0);
}
@@ -609,8 +605,7 @@ resolv_conf_priority(struct interface_info *ifi)
if (writev(s, iov, iovcnt) == -1) {
if (errno != ESRCH)
- log_warnx("RTM_GET of default route: %s",
- strerror(errno));
+ log_warn("RTM_GET of default route");
goto done;
}
@@ -619,8 +614,7 @@ resolv_conf_priority(struct interface_info *ifi)
do {
len = read(s, &m_rtmsg, sizeof(m_rtmsg));
if (len == -1) {
- log_warnx("get default route read: %s",
- strerror(errno));
+ log_warn("get default route read");
break;
} else if (len == 0) {
log_warnx("no data from default route read");
@@ -665,7 +659,7 @@ create_route_label(struct sockaddr_rtlabel *label)
(int)getpid());
if (len == -1) {
- log_warnx("creating route label: %s", strerror(errno));
+ log_warn("creating route label");
return (1);
}
@@ -740,7 +734,7 @@ delete_route(struct interface_info *ifi, int s, struct rt_msghdr *rtm)
rlen = write(s, (char *)rtm, rtm->rtm_msglen);
if (rlen == -1) {
if (errno != ESRCH)
- fatalx("RTM_DELETE write: %s", strerror(errno));
+ fatal("RTM_DELETE write");
} else if (rlen < (int)rtm->rtm_msglen)
fatalx("short RTM_DELETE write (%zd)\n", rlen);
}
@@ -755,8 +749,7 @@ flush_unpriv_ibuf(const char *who)
if (quit == 0)
quit = INTERNALSIG;
if (errno != EPIPE && errno != 0)
- log_warnx("%s: msgbuf_write: %s", who,
- strerror(errno));
+ log_warn("%s: msgbuf_write", who);
break;
}
}
diff --git a/sbin/dhclient/privsep.c b/sbin/dhclient/privsep.c
index e48a5d5c485..bdfd317fe1b 100644
--- a/sbin/dhclient/privsep.c
+++ b/sbin/dhclient/privsep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: privsep.c,v 1.43 2017/02/12 13:15:50 krw Exp $ */
+/* $OpenBSD: privsep.c,v 1.44 2017/02/12 15:53:15 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -43,8 +43,7 @@ dispatch_imsg(struct interface_info *ifi, struct imsgbuf *ibuf)
for (;;) {
if ((n = imsg_get(ibuf, &imsg)) == -1)
- fatalx("dispatch_imsg: imsg_get failure: %s",
- strerror(errno));
+ fatal("dispatch_imsg: imsg_get failure");
if (n == 0)
break;