From 678b6df280036bc9f51c819057369be322fc753d Mon Sep 17 00:00:00 2001 From: Giulio Date: Tue, 13 Jul 2021 12:38:48 +0200 Subject: [PATCH] First working qdb external/internal draft --- qubes/vm/mix/net.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/qubes/vm/mix/net.py b/qubes/vm/mix/net.py index ee9e20a2..4108abcd 100644 --- a/qubes/vm/mix/net.py +++ b/qubes/vm/mix/net.py @@ -368,7 +368,7 @@ class NetVMMixin(qubes.events.Emitter): '''Recursively resolve netvm until no netvm is set, order is important''' netpath = list() - netvm = self.netvm + netvm = self while netvm: netpath.append(netvm) netvm = netvm.netvm @@ -399,14 +399,22 @@ class NetVMMixin(qubes.events.Emitter): # write new forward rules for key, value in vm.firewall.qdb_forward_entries( addr_family=addr_family, type="internal").items(): - print() - # code here - # signal its done + self.untrusted_qdb.write(base_dir + key, value) + ''' + with open("/tmp/log.internal.txt", "a") as f: + f.write("VMName: {}\t\tPath: {}\t\tRule: {}\n".format(self.name, base_dir+key, value)) + ''' for key, value in vm.firewall.qdb_forward_entries( addr_family=addr_family, type="external").items(): - # to fix - for netvm in netpath: - self.untrusted_qdb.write(base_dir + key, value) + current_ip = ip + for netvm in netpath: + base_dir = '/qubes-firewall-forward/{}/'.format(current_ip) + netvm.untrusted_qdb.write(base_dir + key, value) + ''' + with open("/tmp/log.external.txt", "a") as f: + f.write("VMName: {}\t\tPath: {}\t\tRule: {}\n".format(netvm.name, base_dir+key, value)) + ''' + current_ip = netvm.ip # signal its done self.untrusted_qdb.write(base_dir[:-1], '')