From c99a47d192127c29aa8fc3420e807fce5c296e77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 7 Mar 2016 01:16:49 +0100 Subject: [PATCH] vm: fix handling firewall_conf path It may be (and by default is) path relative to VM directory. This code will be gone in the final version, after merging firewall configuration into qubes.xml. But for now have something testable. --- qubes/vm/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/qubes/vm/__init__.py b/qubes/vm/__init__.py index 6cb233c5..21efa0d9 100644 --- a/qubes/vm/__init__.py +++ b/qubes/vm/__init__.py @@ -542,7 +542,8 @@ class BaseVM(qubes.PropertyHolder): try: old_umask = os.umask(002) - with open(self.firewall_conf, 'w') as fd: + with open(os.path.join(self.dir_path, + self.firewall_conf), 'w') as fd: tree.write(fd, encoding="UTF-8", pretty_print=True) fd.close() os.umask(old_umask) @@ -568,7 +569,7 @@ class BaseVM(qubes.PropertyHolder): return True def has_firewall(self): - return os.path.exists(self.firewall_conf) + return os.path.exists(os.path.join(self.dir_path, self.firewall_conf)) @staticmethod def get_firewall_defaults(): @@ -583,7 +584,8 @@ class BaseVM(qubes.PropertyHolder): conf = self.get_firewall_defaults() try: - tree = lxml.etree.parse(self.firewall_conf) + tree = lxml.etree.parse(os.path.join(self.dir_path, + self.firewall_conf)) root = tree.getroot() conf["allow"] = (root.get("policy") == "allow")