fix(runtimeToPermanent): errors for interfaces not in zone

Resolves: rhbz2112982
This commit is contained in:
Eric Garver 2022-08-03 09:55:39 -04:00
parent c5e2505b73
commit 66a037bb45
3 changed files with 95 additions and 1 deletions

View File

@ -0,0 +1,42 @@
From f9e0fdd188e7730468bebdf35f573f2a1ef6bd9b Mon Sep 17 00:00:00 2001
From: Eric Garver <eric@garver.life>
Date: Tue, 2 Aug 2022 13:11:31 -0400
Subject: [PATCH 4/5] fix(runtimeToPermanent): errors for interfaces not in
zone
We should only consider the interfaces for the currently iterated over
zone. Otherwise we will attempt to remove an interface from a zone for
which it is does not belong.
Note this only occurs when NetworkManager is running.
Fixes: #976
Fixes: rhbz2112982
(cherry picked from commit 15f47354c4a078dc694df1541550b3e5156548fc)
---
src/firewall/server/firewalld.py | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/firewall/server/firewalld.py b/src/firewall/server/firewalld.py
index 5cf963dfbbd4..f5f902d6e712 100644
--- a/src/firewall/server/firewalld.py
+++ b/src/firewall/server/firewalld.py
@@ -447,10 +447,11 @@ class FirewallD(DbusServiceObject):
conf = self.getZoneSettings2(name)
settings = FirewallClientZoneSettings(conf)
changed = False
- for interface in self.fw._nm_assigned_interfaces:
- log.debug1("Zone '%s': interface binding for '%s' has been added by NM, ignoring." % (name, interface))
- settings.removeInterface(interface)
- changed = True
+ for interface in settings.getInterfaces():
+ if interface in self.fw._nm_assigned_interfaces:
+ log.debug1("Zone '%s': interface binding for '%s' has been added by NM, ignoring." % (name, interface))
+ settings.removeInterface(interface)
+ changed = True
# For the remaining interfaces, attempt to let NM manage them
for interface in settings.getInterfaces():
try:
--
2.31.1

View File

@ -0,0 +1,47 @@
From 5300da5cbb6c696baad71fb85ca36e65ab5ba292 Mon Sep 17 00:00:00 2001
From: Eric Garver <eric@garver.life>
Date: Mon, 1 Aug 2022 14:43:23 -0400
Subject: [PATCH 5/5] test(runtimeToPermanent): verify when NM interfaces
present
Coverage: #976
Coverage: rhbz2112982
(cherry picked from commit f4f67413e4db7c789bf9d7ba8e983505a6e6e6df)
---
src/tests/integration/gh976.at | 14 ++++++++++++++
src/tests/integration/networkmanager.at | 1 +
2 files changed, 15 insertions(+)
create mode 100644 src/tests/integration/gh976.at
diff --git a/src/tests/integration/gh976.at b/src/tests/integration/gh976.at
new file mode 100644
index 000000000000..977eca997a3a
--- /dev/null
+++ b/src/tests/integration/gh976.at
@@ -0,0 +1,14 @@
+FWD_START_TEST([interfaces during runtime to permanent])
+AT_KEYWORDS(gh976 rhbz2112982)
+
+START_NETWORKMANAGER()
+
+NMCLI_CHECK([connection add type dummy con-name dummy0 ifname dummy0 ip4 10.0.0.2 gw4 10.0.0.1], 0, [ignore])
+echo NS_CMD([nmcli connection delete dummy0]) >> ./cleanup
+NMCLI_CHECK([connection show dummy0], 0, [ignore])
+NMCLI_CHECK([connection up dummy0], 0, [ignore])
+
+FWD_CHECK([--add-service smtp], 0, [ignore])
+FWD_CHECK([--runtime-to-permanent], 0, [ignore])
+
+FWD_END_TEST()
diff --git a/src/tests/integration/networkmanager.at b/src/tests/integration/networkmanager.at
index 0b20adce0462..c93e92d70754 100644
--- a/src/tests/integration/networkmanager.at
+++ b/src/tests/integration/networkmanager.at
@@ -1,3 +1,4 @@
AT_BANNER([NetworkManager (FIREWALL_BACKEND)])
m4_include([integration/rhbz1773809.at])
m4_include([integration/rhbz1928860.at])
+m4_include([integration/gh976.at])
--
2.31.1

View File

@ -1,13 +1,15 @@
Summary: A firewall daemon with D-Bus interface providing a dynamic firewall
Name: firewalld
Version: 1.1.1
Release: 2%{?dist}
Release: 3%{?dist}
URL: http://www.firewalld.org
License: GPLv2+
Source0: https://github.com/firewalld/firewalld/releases/download/v%{version}/firewalld-%{version}.tar.gz
Patch1: 0001-RHEL-only-Add-cockpit-by-default-to-some-zones.patch
Patch2: 0002-test-functions-commonize-iptables-output-normalizati.patch
Patch3: 0003-test-functions-normalize-iptables-ipv6-icmp-icmpv6.patch
Patch4: 0004-fix-runtimeToPermanent-errors-for-interfaces-not-in-.patch
Patch5: 0005-test-runtimeToPermanent-verify-when-NM-interfaces-pr.patch
BuildArch: noarch
BuildRequires: autoconf
BuildRequires: automake
@ -229,6 +231,9 @@ rm -rf %{buildroot}%{_datadir}/firewalld/testsuite
%{_mandir}/man1/firewall-config*.1*
%changelog
* Wed Aug 03 2022 Eric Garver <egarver@redhat.com> - 1.1.1-3
- fix(runtimeToPermanent): errors for interfaces not in zone
* Fri Jul 15 2022 Eric Garver <egarver@redhat.com> - 1.1.1-2
- test(functions): normalize iptables ipv6-icmp/icmpv6