Bug 1257549 - Netstat tool does not throw correct exit code on wrong parameter
Netstat tool does not throw correct exit code on wrong parameter
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: net-tools (Show other bugs)
7.1
x86_64 Linux
high Severity medium
: rc
: ---
Assigned To: Michal Ruprich
Petr Sklenar
: Patch
Depends On: 1258941
Blocks: 1400961 1380362 1393869
  Show dependency treegraph
 
Reported: 2015-08-27 06:19 EDT by Michal Toth
Modified: 2017-08-01 12:09 EDT (History)
4 users (show)

See Also:
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 12:09:52 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Michal Toth 2015-08-27 06:19:29 EDT
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 12:09:52 EDT
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

Note You need to log in before you can comment on or make changes to this bug.