Blame SOURCES/0045-fix-zone-detect-same-source-interface-in-zones.patch

343241
From 8311259a6e2a6ac475c3d8c9a2df099469bf8277 Mon Sep 17 00:00:00 2001
343241
From: Eric Garver <eric@garver.life>
343241
Date: Wed, 27 Oct 2021 10:13:59 -0400
343241
Subject: [PATCH 45/50] fix(zone): detect same source/interface in zones
343241
343241
Fixes: rhbz2014383
343241
(cherry picked from commit 4b721abb087a529596722a045a63a65af2e0566a)
343241
(cherry picked from commit 081fcfe7b255b2e0f91c4a3dc55539e4cfd4b7d1)
343241
---
343241
 src/firewall/core/io/zone.py | 15 +++++++++++++++
343241
 1 file changed, 15 insertions(+)
343241
343241
diff --git a/src/firewall/core/io/zone.py b/src/firewall/core/io/zone.py
343241
index 3aea94a13155..4291ec9cba00 100644
343241
--- a/src/firewall/core/io/zone.py
343241
+++ b/src/firewall/core/io/zone.py
343241
@@ -193,11 +193,26 @@ class Zone(IO_Object):
343241
             for interface in config:
343241
                 if not checkInterface(interface):
343241
                     raise FirewallError(errors.INVALID_INTERFACE, interface)
343241
+                if self.fw_config:
343241
+                    for zone in self.fw_config.get_zones():
343241
+                        if zone == self.name:
343241
+                            continue
343241
+                        if interface in self.fw_config.get_zone(zone).interfaces:
343241
+                            raise FirewallError(errors.INVALID_INTERFACE,
343241
+                                    "interface '{}' already bound to zone '{}'".format(interface, zone))
343241
         elif item == "sources":
343241
             for source in config:
343241
                 if not checkIPnMask(source) and not checkIP6nMask(source) and \
343241
                    not check_mac(source) and not source.startswith("ipset:"):
343241
                     raise FirewallError(errors.INVALID_ADDR, source)
343241
+                if self.fw_config:
343241
+                    for zone in self.fw_config.get_zones():
343241
+                        if zone == self.name:
343241
+                            continue
343241
+                        if source in self.fw_config.get_zone(zone).sources:
343241
+                            raise FirewallError(errors.INVALID_ADDR,
343241
+                                    "source '{}' already bound to zone '{}'".format(source, zone))
343241
+
343241
 
343241
     def check_name(self, name):
343241
         super(Zone, self).check_name(name)
343241
-- 
343241
2.27.0
343241