From 9d20877a438202b8be40652b97354ffd25b0fcdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Thu, 19 Sep 2019 20:20:36 +0200 Subject: [PATCH] Fixed unexpected error on empty default template and incorrect error handling Qubesd wrongly required default_template global property to be not None. Furthermore, even without hard failure set, require_property method raised an exception in case of a property having incorrect None value. It now logs an error message instead, as designed. fixes QubesOS/qubes-issues#5326 --- qubes/__init__.py | 5 ++++- qubes/app.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/qubes/__init__.py b/qubes/__init__.py index 4bc8e41f..c46f3144 100644 --- a/qubes/__init__.py +++ b/qubes/__init__.py @@ -727,7 +727,10 @@ class PropertyHolder(qubes.events.Emitter): try: value = getattr(self, prop) if value is None and not allow_none: - raise ValueError('Property {!r} cannot be None'.format(prop)) + msg = 'Property {!r} cannot be None'.format(prop) + if hard: + raise ValueError(msg) + self.log.fatal(msg) except AttributeError: # pylint: disable=no-member msg = 'Required property {!r} not set on {!r}'.format(prop, self) diff --git a/qubes/app.py b/qubes/app.py index 087825db..2a74dac8 100644 --- a/qubes/app.py +++ b/qubes/app.py @@ -937,7 +937,7 @@ class Qubes(qubes.PropertyHolder): # stage 5: misc fixups self.property_require('default_netvm', allow_none=True) - self.property_require('default_template') + self.property_require('default_template', allow_none=True) self.property_require('clockvm', allow_none=True) self.property_require('updatevm', allow_none=True)