summaryrefslogtreecommitdiffstats
path: root/sbin/ifconfig/ifconfig.c
diff options
context:
space:
mode:
authorallanjude <allanjude@FreeBSD.org>2015-09-16 03:03:19 +0000
committerallanjude <allanjude@FreeBSD.org>2015-09-16 03:03:19 +0000
commit6093eb3b9f4368a35ac09c85817008b52cb55718 (patch)
tree403ecfc569560c117334579064ec74e4cc1e6cc6 /sbin/ifconfig/ifconfig.c
parent1b75a44eb37ee51b6ae6e06286bd87b446bc6ffe (diff)
downloadFreeBSD-src-6093eb3b9f4368a35ac09c85817008b52cb55718.zip
FreeBSD-src-6093eb3b9f4368a35ac09c85817008b52cb55718.tar.gz
Make ifconfig always exit with an error code if an important ioctl fails
PR: 203062 Arm Twisting by: Kristof Provost Reviewed by: kp Approved by: bapt (mentor) MFC after: 2 weeks Relnotes: yes Sponsored by: ScaleEngine Inc. Sponsored by: vBSDCon Differential Revision: https://reviews.freebsd.org/D3644
Diffstat (limited to 'sbin/ifconfig/ifconfig.c')
-rw-r--r--sbin/ifconfig/ifconfig.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
index 4a79992..52de660 100644
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -995,7 +995,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
@@ -1005,7 +1005,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
@@ -1015,15 +1015,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);
@@ -1050,7 +1047,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);
}
OpenPOWER on IntegriCloud