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);
 }
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to