From 2abdbc46284a8fe27358e055bca690c7059a7d90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 26 Jun 2017 18:45:59 +0200 Subject: [PATCH] firewall: minor simplification for old firewall.xml loading Have `default_policy_is_accept` variable of type bool, instead of `policy`, which is only compared to a constant value (`accept`). Suggested by @woju --- qubes/firewall.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/qubes/firewall.py b/qubes/firewall.py index 824dfe82e..a9d195e82 100644 --- a/qubes/firewall.py +++ b/qubes/firewall.py @@ -506,10 +506,7 @@ def load_v1(self, xml_root): '''Load old (Qubes < 4.0) firewall XML format''' policy_v1 = xml_root.get('policy') assert policy_v1 in ('allow', 'deny') - if policy_v1 == 'allow': - policy = Action('accept') - else: - policy = Action('drop') + default_policy_is_accept = (policy_v1 == 'allow') def _translate_action(key): if xml_root.get(key, policy_v1) == 'allow': @@ -524,7 +521,7 @@ def _translate_action(key): action=_translate_action('icmp'), proto=Proto.icmp)) - if policy == Action.accept: + if default_policy_is_accept: rule_action = Action.drop else: rule_action = Action.accept @@ -532,7 +529,7 @@ def _translate_action(key): for element in xml_root: rule = Rule.from_xml_v1(element, rule_action) self.rules.append(rule) - if policy == Action.accept: + if default_policy_is_accept: self.rules.append(Rule(None, action='accept')) def load_v2(self, xml_root):