From 02639b8d021f7d18972fff4c7d55d641ca7df9fe Mon Sep 17 00:00:00 2001 From: Wojtek Porczyk Date: Thu, 9 Feb 2017 20:16:23 +0100 Subject: [PATCH] qubes/mgmt: mgmt.vm.property.List QubesOS/qubes-issues#2622 --- qubes/mgmt.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/qubes/mgmt.py b/qubes/mgmt.py index 55079501..09e0c65f 100644 --- a/qubes/mgmt.py +++ b/qubes/mgmt.py @@ -114,6 +114,12 @@ class QubesMgmt(object): return self.src.fire_event_pre('mgmt-permission:{}'.format(self.method), self.dest, self.arg, *args, **kwargs) + @not_in_api + def fire_event_for_filter(self, iterable, *args, **kwargs): + for selector in self.fire_event_for_permission(*args, **kwargs): + iterable = filter(selector, iterable) + return iterable + @not_in_api def repr(self, *args, **kwargs): return self.prepr.repr(*args, **kwargs) @@ -128,9 +134,7 @@ class QubesMgmt(object): assert not untrusted_payload del untrusted_payload - domains = self.app.domains - for selector in self.fire_event_for_permission(): - domains = filter(selector, domains) + domains = self.fire_event_for_filter(self.app.domains) return ''.join('{} class={} state={}\n'.format( self.repr(vm), @@ -138,6 +142,15 @@ class QubesMgmt(object): vm.get_power_state()) for vm in sorted(domains)) + def vm_property_list(self, untrusted_payload): + assert not self.arg + assert not untrusted_payload + del untrusted_payload + + properties = self.fire_event_for_filter(self.dest.property_list()) + + return ''.join('{}\n'.format(prop.__name__) for prop in properties) + def vm_property_get(self, untrusted_payload): assert self.arg in self.dest.property_list() assert not untrusted_payload @@ -153,5 +166,3 @@ class QubesMgmt(object): return 'default={} {}'.format( str(self.dest.property_is_default(self.arg)), self.repr(value)) - -