Ver código fonte

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

Marek Marczykowski-Górecki 7 anos atrás
pai
commit
2a4af124f8
1 arquivos alterados com 6 adições e 2 exclusões
  1. 6 2
      qubes/app.py

+ 6 - 2
qubes/app.py

@@ -809,8 +809,12 @@ class Qubes(qubes.PropertyHolder):
         lxml.etree.ElementTree(self.__xml__()).write(
             fh_new, encoding='utf-8', pretty_print=True)
         fh_new.flush()
-        os.chmod(fh_new.name, 0o660)
-        os.chown(fh_new.name, -1, grp.getgrnam('qubes').gr_gid)
+        try:
+            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)
 
         # update stored mtime, in case of multiple save() calls without