Bug 1372716 - firewall-cmd --query-* cmds should return valid exit code
Summary: firewall-cmd --query-* cmds should return valid exit code
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: firewalld
Version: 7.3
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Phil Sutter
QA Contact: Tomas Dolezal
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-09-02 13:06 UTC by Tomas Dolezal
Modified: 2018-04-10 10:31 UTC (History)
5 users (show)

Fixed In Version: firewalld-0.4.4.4-11.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-04-10 10:30:16 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHEA-2018:0702 0 None None None 2018-04-10 10:31:37 UTC

Description Tomas Dolezal 2016-09-02 13:06:30 UTC
Description of problem:
when the result of a query is negative, exitcode 1 is used. this code is undefined as per man:firewall-cmd(1). While the code is correctly zero/non-zero, 1 is usually result of Traceback, not a valid operation in firewalld.

Version-Release number of selected component (if applicable):
firewalld-0.4.3.2-6.el7.noarch

How reproducible:
always

Steps to Reproduce:
firewall-cmd --query-service ssh ; echo ec=$?
firewall-cmd --query-service dns ; echo ec=$?
firewall-cmd --query-panic ; echo ec=$?

Actual results:
yes
ec=0
no
ec=1
no
ec=1

Expected results:
yes
ec=0
no
ec=12 <--- CHANGED to NOT_ENABLED
no
ec=12 <--- CHANGED to NOT_ENABLED

Additional info:

Comment 2 Thomas Woerner 2016-09-02 13:59:36 UTC
All query methods either return 0 or 1 for a long time already. I do not know if it will be simply possible to change the values without breaking scripts using the current exit codes.

Comment 3 Eric Garver 2017-06-23 17:22:53 UTC
Tomas,

The man page sections for --query-* commands indicates that it may return 1. The 'EXIT CODES' section could be updated to indicate that for --query-* 1 means negative status, otherwise it's due to a traceback.

I agree with Thomas in comment 2 that changing the return code would be problematic. Best we can do is improve the man page. Do you agree?

Comment 4 Tomas Dolezal 2017-06-26 12:15:20 UTC
Hello Eric,
(In reply to Eric Garver from comment #3)
> I agree with Thomas in comment 2 that changing the return code would be
> problematic. Best we can do is improve the man page. Do you agree?
Yes, I agree. the possible change should be done in both downstream and upstream.

Comment 9 errata-xmlrpc 2018-04-10 10:30:16 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/RHEA-2018:0702


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