Bug 203062 - ifconfig always has exit status 0
Summary: ifconfig always has exit status 0
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Many People
Assignee: Allan Jude
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-12 19:22 UTC by Kristof Provost
Modified: 2016-01-12 06:01 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kristof Provost freebsd_committer freebsd_triage 2015-09-12 19:22:14 UTC
ifconfig doesn't return errors if the ioctl() fails.
It prints the error, but always does exit(0).
This makes it annoying to use in scripts.

For example, when trying to rename an interface to conflict with an existing interface:
% sudo ifconfig lo0 name vtnet0 ; echo $?
ifconfig: ioctl (set name): File exists
0
Comment 1 Kristof Provost freebsd_committer freebsd_triage 2015-09-14 00:14:05 UTC
Allan posted a patch in https://reviews.freebsd.org/D3644
Comment 2 commit-hook freebsd_committer freebsd_triage 2015-09-16 03:03:49 UTC
A commit references this bug:

Author: allanjude
Date: Wed Sep 16 03:03:20 UTC 2015
New revision: 287842
URL: https://svnweb.freebsd.org/changeset/base/287842

Log:
  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

Changes:
  head/sbin/ifconfig/ifconfig.c
Comment 3 commit-hook freebsd_committer freebsd_triage 2016-01-12 05:57:48 UTC
A commit references this bug:

Author: allanjude
Date: Tue Jan 12 05:56:49 UTC 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

Changes:
_U  stable/10/
  stable/10/sbin/ifconfig/ifconfig.c