Bug 1257549

Summary: Netstat tool does not throw correct exit code on wrong parameter
Product: Red Hat Enterprise Linux 7 Reporter: Michal Toth <mtoth>
Component: net-toolsAssignee: Michal Ruprich <mruprich>
Status: CLOSED ERRATA QA Contact: Petr Sklenar <psklenar>
Severity: medium Docs Contact:
Priority: high    
Version: 7.1CC: jpopelka, mruprich, psklenar, thozza
Target Milestone: rcKeywords: Patch
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: net-tools-2.0-0.19.20131004git.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1258941 (view as bug list) Environment:
Last Closed: 2017-08-01 16:09:52 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1258941    
Bug Blocks: 1380362, 1393869, 1400961    

Description Michal Toth 2015-08-27 10:19:29 UTC
Description of problem:
netstat tool does not throw any exit code other then 0. 
You can provide any input parameter and still get error code 0.

Version-Release number of selected component (if applicable):
net-tools-2.0-0.17.20131004git.el7.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Issue any arbitrary parameter to netstat
$ netstat --asd
netstat: unrecognized option '--asd'
usage: netstat [-vWeenNcCF] [<Af>] -r         netstat {-V|--version|-h|--help}
       netstat [-vWnNcaeol] [<Socket> ...]
       netstat { [-vWeenNac] -I[<Iface>] | [-veenNac] -i | [-cnNe] -M | -s [-6tuw] } [delay]

        -r, --route              display routing table
        -I, --interfaces=<Iface> display interface table for <Iface>
        -i, --interfaces         display interface table
        -g, --groups             display multicast group memberships
        -s, --statistics         display networking statistics (like SNMP)
        -M, --masquerade         display masqueraded connections

        -v, --verbose            be verbose
        -W, --wide               don't truncate IP addresses
        -n, --numeric            don't resolve names
        --numeric-hosts          don't resolve host names
        --numeric-ports          don't resolve port names
        --numeric-users          don't resolve user names
        -N, --symbolic           resolve hardware names
        -e, --extend             display other/more information
        -p, --programs           display PID/Program name for sockets
        -o, --timers             display timers
        -c, --continuous         continuous listing

        -l, --listening          display listening server sockets
        -a, --all                display all sockets (default: connected)
        -F, --fib                display Forwarding Information Base (default)
        -C, --cache              display routing cache instead of FIB
        -Z, --context            display SELinux security context for sockets

  <Socket>={-t|--tcp} {-u|--udp} {-U|--udplite} {-w|--raw} {-x|--unix}
           --ax25 --ipx --netrom
  <AF>=Use '-6|-4' or '-A <af>' or '--<af>'; default: inet
  List of possible address families (which support routing):
    inet (DARPA Internet) inet6 (IPv6) ax25 (AMPR AX.25) 
    netrom (AMPR NET/ROM) ipx (Novell IPX) ddp (Appletalk DDP) 
    x25 (CCITT X.25) 


2. Observe the exit code
$ echo $?
0

Actual results:
Exit code is always 0

Expected results:
Exit differs from 0

Additional info:
In RHEL6 & net-tools-1.60-110.el6_2 I can see exit code "4" when provided given wrong input parameter.
Also, this error is present in various distributions like Fedora 19, 22 and Gentoo
net-tools-2.0-0.31.20141124git.fc22.x86_64

Comment 16 errata-xmlrpc 2017-08-01 16:09:52 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2017:1873