Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 Jan 2016 05:56:49 +0000 (UTC)
From:      Allan Jude <allanjude@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r293729 - stable/10/sbin/ifconfig
Message-ID:  <201601120556.u0C5unJ4055537@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: allanjude
Date: Tue Jan 12 05:56:49 2016
New Revision: 293729
URL: https://svnweb.freebsd.org/changeset/base/293729

Log:
  MFC: r287842
    Make ifconfig always exit with an error code if an important ioctl fails
  
  PR:		203062

Modified:
  stable/10/sbin/ifconfig/ifconfig.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sbin/ifconfig/ifconfig.c
==============================================================================
--- stable/10/sbin/ifconfig/ifconfig.c	Tue Jan 12 05:55:28 2016	(r293728)
+++ stable/10/sbin/ifconfig/ifconfig.c	Tue Jan 12 05:56:49 2016	(r293729)
@@ -838,7 +838,7 @@ setifmetric(const char *val, int dummy _
 	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 __un
 	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 __u
 	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 __
 	}
 
 	if (ioctl(s, SIOCSIFDESCR, (caddr_t)&ifr) < 0)
-		warn("ioctl (set descr)");
+		err(1, "ioctl SIOCSIFDESCR (set descr)");
 
 	free(newdescr);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201601120556.u0C5unJ4055537>