backup: don't crash when no 'qubes' group is present

This is specifically the case on Travis-CI. But since dom0 backup is
restored into separate directory now, instead of directly overriding
user home, this check is much less relevant now.
This commit is contained in:
Marek Marczykowski-Górecki 2018-02-14 04:13:21 +01:00
parent 060171f19f
commit 56dc984507
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -23,6 +23,7 @@
import errno
import fcntl
import functools
import getpass
import grp
import logging
import multiprocessing
@ -1552,7 +1553,11 @@ class BackupRestore(object):
vm = self.backup_app.domains['dom0']
vms_to_restore['dom0'] = self.Dom0ToRestore(vm,
self.backup_app.domains['dom0'].backup_path)
local_user = grp.getgrnam('qubes').gr_mem[0]
try:
local_user = grp.getgrnam('qubes').gr_mem[0]
except KeyError:
# if no qubes group is present, assume username matches
local_user = vms_to_restore['dom0'].username
if vms_to_restore['dom0'].username != local_user:
if not self.options.ignore_username_mismatch:
@ -1674,8 +1679,12 @@ class BackupRestore(object):
def _handle_dom0(self, stream):
'''Extract dom0 home'''
local_user = grp.getgrnam('qubes').gr_mem[0]
home_dir = pwd.getpwnam(local_user).pw_dir
try:
local_user = grp.getgrnam('qubes').gr_mem[0]
home_dir = pwd.getpwnam(local_user).pw_dir
except KeyError:
home_dir = os.path.expanduser('~')
local_user = getpass.getuser()
restore_home_backupdir = "home-restore-{0}".format(
time.strftime("%Y-%m-%d-%H%M%S"))