Bug 1258941 - 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: Fedora
Classification: Fedora
Component: net-tools (Show other bugs)
23
Unspecified Unspecified
unspecified Severity medium
: ---
: ---
Assigned To: Jiri Popelka
Fedora Extras Quality Assurance
:
Depends On:
Blocks: 1257549
  Show dependency treegraph
 
Reported: 2015-09-01 10:37 EDT by Tomáš Hozza
Modified: 2016-04-02 11:54 EDT (History)
4 users (show)

See Also:
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 11:54:38 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)
Fix exit code (urecognized argument) (1.64 KB, patch)
2015-09-10 03:02 EDT, Tomáš Odehnal
no flags Details | Diff
netstat: Fix exit code (unrecognized argument) (1.39 KB, patch)
2015-09-10 06:38 EDT, Tomáš Odehnal
no flags Details | Diff

  None (edit)
Description Tomáš Hozza 2015-09-01 10:37:47 EDT
+++ 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 03:02:04 EDT
Created attachment 1072034 [details]
Fix exit code (urecognized argument)
Comment 2 Jiri Popelka 2015-09-10 03:53:36 EDT
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@example.com
$ 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 06:38:30 EDT
Created attachment 1072083 [details]
netstat: Fix exit code (unrecognized argument)
Comment 4 Jiri Popelka 2015-10-30 10:41:39 EDT
Merged upstream:
sourceforge.net/p/net-tools/code/ci/adf6f5793fb74c723391a14efa8c2e4c7ef354f0
Comment 5 Mike McCune 2016-03-28 18:49:28 EDT
This bug was accidentally moved from POST to MODIFIED via an error in automation, please see mmccune@redhat.com with any questions
Comment 6 Fedora Update System 2016-03-30 10:39:23 EDT
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 18:25:06 EDT
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 11:54:36 EDT
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.

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