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
This commit is contained in:
Marta Marczykowska-Górecka 2019-09-19 20:20:36 +02:00
parent 46ad75a3ba
commit 9d20877a43
No known key found for this signature in database
GPG Key ID: 9A752C30B26FD04B
2 changed files with 5 additions and 2 deletions

View File

@ -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)

View File

@ -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)