diff options
author | allanjude <allanjude@FreeBSD.org> | 2016-01-12 05:56:49 +0000 |
---|---|---|
committer | allanjude <allanjude@FreeBSD.org> | 2016-01-12 05:56:49 +0000 |
commit | 30790e76c24aea499d29d0d91d9b66ec174e60e0 (patch) | |
tree | dcc40e41442c619130ff51523f084a3161d2e20f /sbin/ifconfig | |
parent | 21f7a71da870fc371bcd24d41357527c94a3c6d9 (diff) | |
download | FreeBSD-src-30790e76c24aea499d29d0d91d9b66ec174e60e0.zip FreeBSD-src-30790e76c24aea499d29d0d91d9b66ec174e60e0.tar.gz |
MFC: r287842
Make ifconfig always exit with an error code if an important ioctl fails
PR: 203062
Diffstat (limited to 'sbin/ifconfig')
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 558c205..19bd1ac 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -838,7 +838,7 @@ setifmetric(const char *val, int dummy __unused, int s, strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name)); ifr.ifr_metric = atoi(val); if (ioctl(s, SIOCSIFMETRIC, (caddr_t)&ifr) < 0) - warn("ioctl (set metric)"); + err(1, "ioctl SIOCSIFMETRIC (set metric)"); } static void @@ -848,7 +848,7 @@ setifmtu(const char *val, int dummy __unused, int s, strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name)); ifr.ifr_mtu = atoi(val); if (ioctl(s, SIOCSIFMTU, (caddr_t)&ifr) < 0) - warn("ioctl (set mtu)"); + err(1, "ioctl SIOCSIFMTU (set mtu)"); } static void @@ -858,15 +858,12 @@ setifname(const char *val, int dummy __unused, int s, char *newname; newname = strdup(val); - if (newname == NULL) { - warn("no memory to set ifname"); - return; - } + if (newname == NULL) + err(1, "no memory to set ifname"); ifr.ifr_data = newname; if (ioctl(s, SIOCSIFNAME, (caddr_t)&ifr) < 0) { - warn("ioctl (set name)"); free(newname); - return; + err(1, "ioctl SIOCSIFNAME (set name)"); } strlcpy(name, newname, sizeof(name)); free(newname); @@ -893,7 +890,7 @@ setifdescr(const char *val, int dummy __unused, int s, } if (ioctl(s, SIOCSIFDESCR, (caddr_t)&ifr) < 0) - warn("ioctl (set descr)"); + err(1, "ioctl SIOCSIFDESCR (set descr)"); free(newdescr); } |