fix(firewall-cmd): handle no options when not running

Resolves: RHEL-60902
This commit is contained in:
Eric Garver 2026-07-31 16:38:23 -04:00
parent 5d78dec0f8
commit 3e04e69a20
2 changed files with 75 additions and 1 deletions

View File

@ -0,0 +1,70 @@
From e708b004c3f3bb31900051ad30b653040de674ea Mon Sep 17 00:00:00 2001
From: dharmik <dharmikparmar2004@yahoo.com>
Date: Sat, 4 Jul 2026 17:45:23 +0530
Subject: [PATCH 2/3] v2.5.0: fix(firewall-cmd): handle no options when not
running
Avoid reading the firewalld state property when the client is not
connected to the daemon. This lets firewall-cmd print the normal
no-options usage instead of an AttributeError traceback.
Fixes: #1570
Signed-off-by: dharmik <dharmikparmar2004@yahoo.com>
---
src/firewall-cmd.in | 2 +-
src/tests/regression/gh1570.at | 20 ++++++++++++++++++++
src/tests/regression/regression.at | 1 +
3 files changed, 22 insertions(+), 1 deletion(-)
create mode 100644 src/tests/regression/gh1570.at
diff --git a/src/firewall-cmd.in b/src/firewall-cmd.in
index 9c08de548e16..50a51874e100 100755
--- a/src/firewall-cmd.in
+++ b/src/firewall-cmd.in
@@ -1540,7 +1540,7 @@ if not (
or options_direct
or options_permanent_only
):
- state = fw.get_property("state")
+ state = fw.get_property("state") if fw.connected else None
if state == "RUNNING":
state = "State: running\n\n"
elif state == "FAILED":
diff --git a/src/tests/regression/gh1570.at b/src/tests/regression/gh1570.at
new file mode 100644
index 000000000000..fc365c515ec2
--- /dev/null
+++ b/src/tests/regression/gh1570.at
@@ -0,0 +1,20 @@
+FWD_START_TEST([cli - no arguments])
+AT_KEYWORDS([cli gh1570 RHEL-60902])
+
+FWD_STOP_FIREWALLD()
+
+dnl Verify CLI with no options does not crash if firewalld is not running.
+FWD_CHECK([], [2], [ignore], [dnl
+State: not running
+
+No options specified
+usage: 'firewall-cmd --help' for usage information or see firewall-cmd(1) man page
+])
+
+dnl Verify offline CLI with no options
+FWD_OFFLINE_CHECK([], [2], [ignore], [dnl
+usage: see firewall-offline-cmd man page
+No option specified.
+])
+
+FWD_END_TEST()
diff --git a/src/tests/regression/regression.at b/src/tests/regression/regression.at
index 0fe856f4ae9f..032a998ca94c 100644
--- a/src/tests/regression/regression.at
+++ b/src/tests/regression/regression.at
@@ -64,3 +64,4 @@ m4_include([regression/gh1406.at])
m4_include([regression/RHEL-67103.at])
m4_include([regression/gh1486.at])
m4_include([regression/RHEL-186856.at])
+m4_include([regression/gh1570.at])
--
2.52.0

View File

@ -1,11 +1,12 @@
Summary: A firewall daemon with D-Bus interface providing a dynamic firewall
Name: firewalld
Version: 2.4.3
Release: 2%{?dist}
Release: 3%{?dist}
URL: http://www.firewalld.org
License: GPL-2.0-or-later
Source0: https://github.com/firewalld/firewalld/releases/download/v%{version}/firewalld-%{version}.tar.bz2
Patch1: 0001-RHEL-only-Add-cockpit-by-default-to-some-zones.patch
Patch2: 0002-v2.5.0-fix-firewall-cmd-handle-no-options-when-not-r.patch
BuildArch: noarch
BuildRequires: autoconf
BuildRequires: automake
@ -253,6 +254,9 @@ end
%{_mandir}/man1/firewall-config*.1*
%changelog
* Fri Jun 31 2026 Eric Garver <egarver@redhat.com> - 2.4.3-3
- fix(firewall-cmd): handle no options when not running
* Fri Jun 26 2026 Eric Garver <egarver@redhat.com> - 2.4.3-2
- rebuild to bump NVR; no changes