vm: fix handling policy deny on admin.vm.List
vm.get_power_state() have specifically documented 'NA' state for cases when it's unable to get VM's power state. Use this when qrexec policy forbid checking it. Reported by @pietrushnic Fixes QubesOS/qubes-issues#3179
This commit is contained in:
parent
17670eae1b
commit
2f7d1ca476
@ -168,11 +168,14 @@ class QubesVM(qubesadmin.base.PropertyHolder):
|
|||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
try:
|
||||||
vm_list_info = [line
|
vm_list_info = [line
|
||||||
for line in self.qubesd_call(
|
for line in self.qubesd_call(
|
||||||
self._method_dest, 'admin.vm.List', None, None
|
self._method_dest, 'admin.vm.List', None, None
|
||||||
).decode('ascii').split('\n')
|
).decode('ascii').split('\n')
|
||||||
if line.startswith(self._method_dest+' ')]
|
if line.startswith(self._method_dest+' ')]
|
||||||
|
except qubesadmin.exc.QubesDaemonNoResponseError:
|
||||||
|
return 'NA'
|
||||||
assert len(vm_list_info) == 1
|
assert len(vm_list_info) == 1
|
||||||
# name class=... state=... other=...
|
# name class=... state=... other=...
|
||||||
# NOTE: when querying dom0, we get whole list
|
# NOTE: when querying dom0, we get whole list
|
||||||
@ -206,7 +209,7 @@ class QubesVM(qubesadmin.base.PropertyHolder):
|
|||||||
:rtype: bool
|
:rtype: bool
|
||||||
'''
|
'''
|
||||||
|
|
||||||
return self.get_power_state() != 'Halted'
|
return self.get_power_state() not in ('Halted', 'NA')
|
||||||
|
|
||||||
def is_networked(self):
|
def is_networked(self):
|
||||||
'''Check whether this VM can reach network (firewall notwithstanding).
|
'''Check whether this VM can reach network (firewall notwithstanding).
|
||||||
|
Loading…
Reference in New Issue
Block a user