RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1465078 - commandline options handling flaws
Summary: commandline options handling flaws
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: iptables
Version: 7.4
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Phil Sutter
QA Contact: Jiri Peska
URL:
Whiteboard:
Depends On:
Blocks: 1472751 1655128
TreeView+ depends on / blocked
 
Reported: 2017-06-26 15:33 UTC by Karel Volný
Modified: 2018-11-30 17:14 UTC (History)
4 users (show)

Fixed In Version: iptables-1.4.21-27.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1655128 (view as bug list)
Environment:
Last Closed: 2018-10-30 09:38:43 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2018:3093 0 None None None 2018-10-30 09:39:04 UTC

Description Karel Volný 2017-06-26 15:33:13 UTC
Description of problem:
When trying the new -W option, I have found some flaws handling the commandline.

Version-Release number of selected component (if applicable):
iptables-1.4.21-18.el7

How reproducible:
always

Steps to Reproduce:
1. iptables-restore -W
2. iptables-restore -W 0
3. iptables-restore --nonsense

Actual results:
1. # iptables-restore -W
dsfds
iptables-restore: line 1 failed

2. # iptables-restore -W 0
dssf
iptables-restore: line 1 failed

3. # iptables-restore --nonsense
iptables-restore: unrecognized option '--nonsense'
dsdsf
iptables-restore: line 1 failed

Expected results:
1. an error about missing value should be reported, program should exit without processing input

2. from man - "This option only works with -w." - so an error about missing "-w" should be reported and the program should exit without processing input

Plus I am not sure what sense makes setting this to 0, probably it should be rejected?

3. similar as above, the program should exit without processing input

While such behaviour isn't explicitly defined in manpage, it is a good practice not to continue processing when the options are wrong. Imagine e.g. if someone would like to use '--test' but made a typo, so that the option would be unrecognized and the undesired action performed ...

Comment 3 Phil Sutter 2017-09-20 17:41:06 UTC
Ignoring unknown parameters has been fixed by following upstream commit:

commit d89dc47ab3875f6fe6679cebceccd2000bf81b8e
Author: Vincent Bernat <vincent>
Date:   Sat Apr 15 12:16:47 2017 +0200

    iptables-restore/save: exit when given an unknown option
    
    When an unknown option is given, iptables-restore should exit instead of
    continue its operation. For example, if `--table` was misspelled, this
    could lead to an unwanted change. Moreover, exit with a status code of
    1. Make the same change for iptables-save.
    
    OTOH, exit with a status code of 0 when requesting help.
    
    Signed-off-by: Vincent Bernat <vincent>
    Signed-off-by: Pablo Neira Ayuso <pablo>


Patches fixing the parsing issues of wait-interval option have been sent upstream: https://marc.info/?l=netfilter-devel&m=150592888910234&w=2

I decided to not forbid '-W 0' since it is not invalid per se - if specified, xtables_lock() routine will busy loop until the lock could be acquired.

Comment 4 Phil Sutter 2017-10-06 15:40:17 UTC
Upstream accepted my patches:

commit 60e0ffd365a2d936b3df13c1289b2ef57b756d92
Author: Phil Sutter <phil>
Date:   Wed Sep 20 19:34:35 2017 +0200

    ip{,6}tables-restore: Don't ignore missing wait-interval value
    
    Passing -W without a value doesn't make sense so bail out if none was
    given.
    
    Signed-off-by: Phil Sutter <phil>
    Signed-off-by: Pablo Neira Ayuso <pablo>

commit 21ba5b3874fb3d0c4cccc9b59f65c8df575211e2
Author: Phil Sutter <phil>
Date:   Wed Sep 20 19:34:36 2017 +0200

    ip{,6}tables-restore: Don't accept wait-interval without wait
    
    If -W <val> was given, error out if -w wasn't since that doesn't make
    sense.
    
    Signed-off-by: Phil Sutter <phil>
    Signed-off-by: Pablo Neira Ayuso <pablo>

Comment 10 errata-xmlrpc 2018-10-30 09:38:43 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-2018:3093


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