Bug 1258941

Summary: Netstat tool does not throw correct exit code on wrong parameter
Product: [Fedora] Fedora Reporter: Tomáš Hozza <thozza>
Component: net-toolsAssignee: Jiri Popelka <jpopelka>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 23CC: jpopelka, mtoth, odehnal.tomas136, qe-baseos-daemons
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: net-tools-2.0-0.37.20160329git.fc24 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1257549 Environment:
Last Closed: 2016-04-02 15:54:38 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:    
Bug Blocks: 1257549    
Attachments:
Description Flags
Fix exit code (urecognized argument)
none
netstat: Fix exit code (unrecognized argument) none

Description Tomáš Hozza 2015-09-01 14:37:47 UTC
+++ This bug was initially created as a clone of Bug #1257549 +++

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

--- Additional comment from RHEL Product and Program Management on 2015-08-27 12:27:48 CEST ---

Since this bug report was entered in bugzilla, the release flag has been
set to ? to ensure that it is properly evaluated for this release.

Comment 1 Tomáš Odehnal 2015-09-10 07:02:04 UTC
Created attachment 1072034 [details]
Fix exit code (urecognized argument)

Comment 2 Jiri Popelka 2015-09-10 07:53:36 UTC
Tomáš & Michael:

Can we use
exit(E_USAGE);
instead of
usage(0);
?


Also, can you create a patch against upstream git repo, so we can send it upstream ?

$ git config --global user.name "John Doe"
$ git config --global user.email johndoe
$ git clone git://git.code.sf.net/p/net-tools/code net-tools
$ cd net-tools
apply your change
$ git commit -am "netstat: Fix exit code (urecognized argument)"
$ git format-patch HEAD~1
attach the 0001-*.patch

thanks

Comment 3 Tomáš Odehnal 2015-09-10 10:38:30 UTC
Created attachment 1072083 [details]
netstat: Fix exit code (unrecognized argument)

Comment 4 Jiri Popelka 2015-10-30 14:41:39 UTC
Merged upstream:
sourceforge.net/p/net-tools/code/ci/adf6f5793fb74c723391a14efa8c2e4c7ef354f0

Comment 5 Mike McCune 2016-03-28 22:49:28 UTC
This bug was accidentally moved from POST to MODIFIED via an error in automation, please see mmccune with any questions

Comment 6 Fedora Update System 2016-03-30 14:39:23 UTC
net-tools-2.0-0.37.20160329git.fc24 has been submitted as an update to Fedora 24. https://bodhi.fedoraproject.org/updates/FEDORA-2016-b1e3346c50

Comment 7 Fedora Update System 2016-03-30 22:25:06 UTC
net-tools-2.0-0.37.20160329git.fc24 has been pushed to the Fedora 24 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-b1e3346c50

Comment 8 Fedora Update System 2016-04-02 15:54:36 UTC
net-tools-2.0-0.37.20160329git.fc24 has been pushed to the Fedora 24 stable repository. If problems still persist, please make note of it in this bug report.