qubes/app: don't fail on saving qubes.xml when 'qubes' group isn't there

This commit is contained in:
Marek Marczykowski-Górecki 2016-11-25 00:19:27 +01:00
parent da3eed582b
commit 2a4af124f8
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -809,8 +809,12 @@ class Qubes(qubes.PropertyHolder):
lxml.etree.ElementTree(self.__xml__()).write( lxml.etree.ElementTree(self.__xml__()).write(
fh_new, encoding='utf-8', pretty_print=True) fh_new, encoding='utf-8', pretty_print=True)
fh_new.flush() fh_new.flush()
os.chmod(fh_new.name, 0o660) try:
os.chown(fh_new.name, -1, grp.getgrnam('qubes').gr_gid) os.chown(fh_new.name, -1, grp.getgrnam('qubes').gr_gid)
os.chmod(fh_new.name, 0o660)
except KeyError: # group 'qubes' not found
# don't change mode if no 'qubes' group in the system
pass
os.rename(fh_new.name, self._store) os.rename(fh_new.name, self._store)
# update stored mtime, in case of multiple save() calls without # update stored mtime, in case of multiple save() calls without