4e9e3da307
http://www.firewalld.org/2017/06/firewalld-0-4-4-5-release - Fix build from spec - Fix –remove-service-from-zone option (RHBZ#1438127) - Support sctp and dccp in ports, source-ports, forward-ports, helpers and rich rules (RHBZ#1429808) - firewall-cmd: Fix –{set,get}-{short,description} for zone (RHBZ#1445238) - firewall.core.ipXtables: Use new wait option for restore commands if available - New services for oVirt: ctdb, ovirt-imageio, ovirt-storageconsole, ovirt-vmconsole and nrpe - Rename extension for policy choices (server and desktop) to .policy.choice (RHBZ#1449754) - D-Bus interfaces: Fix GetAll for interfaces without properties (RHBZ#1452017) - Load NAT helpers with conntrack helpers (RHBZ#1452681) - Translation updates - Additional upstream patches: - Rich-rule source validation (d69b7cb) - IPv6 ICMP type only rich-rule fix (cf50bd0)
60 lines
2.6 KiB
Diff
60 lines
2.6 KiB
Diff
From d69b7cb2724f041f257b90184a64e28a667ee7e9 Mon Sep 17 00:00:00 2001
|
|
From: Thomas Woerner <twoerner@redhat.com>
|
|
Date: Thu, 8 Jun 2017 15:31:11 +0200
|
|
Subject: [PATCH] firewall.core.rich: Add checks for Rich_Source validation
|
|
|
|
A rich-rule source needs to either contain a IP address, a MAC address or an
|
|
ipset.
|
|
---
|
|
src/firewall/core/rich.py | 24 +++++++++++++++++-------
|
|
1 file changed, 17 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/src/firewall/core/rich.py b/src/firewall/core/rich.py
|
|
index 3adcb4d9..04791da6 100644
|
|
--- a/src/firewall/core/rich.py
|
|
+++ b/src/firewall/core/rich.py
|
|
@@ -46,15 +46,21 @@ def __init__(self, addr, mac, ipset, invert=False):
|
|
if self.ipset == "":
|
|
self.ipset = None
|
|
self.invert = invert
|
|
+ if self.addr is None and self.mac is None and self.ipset is None:
|
|
+ raise FirewallError(errors.INVALID_RULE,
|
|
+ "no address, mac and ipset")
|
|
|
|
def __str__(self):
|
|
- if self.addr:
|
|
- x = ' address="%s"' % self.addr
|
|
- elif self.mac:
|
|
- x = ' mac="%s"' % self.mac
|
|
- elif self.ipset:
|
|
- x = ' ipset="%s"' % self.ipset
|
|
- return 'source%s%s' % (" NOT" if self.invert else "", x)
|
|
+ ret = 'source%s ' % (" NOT" if self.invert else "")
|
|
+ if self.addr is not None:
|
|
+ return ret + 'address="%s"' % self.addr
|
|
+ elif self.mac is not None:
|
|
+ return ret + 'mac="%s"' % self.mac
|
|
+ elif self.ipset is not None:
|
|
+ return ret + 'ipset="%s"' % self.ipset
|
|
+ else:
|
|
+ raise FirewallError(errors.INVALID_RULE,
|
|
+ "no address, mac and ipset")
|
|
|
|
class Rich_Destination(object):
|
|
def __init__(self, addr, invert=False):
|
|
@@ -542,10 +548,14 @@ def check(self):
|
|
raise FirewallError(errors.INVALID_FAMILY)
|
|
if self.source.mac is not None:
|
|
raise FirewallError(errors.INVALID_RULE, "address and mac")
|
|
+ if self.source.ipset is not None:
|
|
+ raise FirewallError(errors.INVALID_RULE, "address and ipset")
|
|
if not functions.check_address(self.family, self.source.addr):
|
|
raise FirewallError(errors.INVALID_ADDR, str(self.source.addr))
|
|
|
|
elif self.source.mac is not None:
|
|
+ if self.source.ipset is not None:
|
|
+ raise FirewallError(errors.INVALID_RULE, "mac and ipset")
|
|
if not functions.check_mac(self.source.mac):
|
|
raise FirewallError(errors.INVALID_MAC, str(self.source.mac))
|
|
|