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:
parent
060171f19f
commit
56dc984507
@ -23,6 +23,7 @@
|
|||||||
import errno
|
import errno
|
||||||
import fcntl
|
import fcntl
|
||||||
import functools
|
import functools
|
||||||
|
import getpass
|
||||||
import grp
|
import grp
|
||||||
import logging
|
import logging
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
@ -1552,7 +1553,11 @@ class BackupRestore(object):
|
|||||||
vm = self.backup_app.domains['dom0']
|
vm = self.backup_app.domains['dom0']
|
||||||
vms_to_restore['dom0'] = self.Dom0ToRestore(vm,
|
vms_to_restore['dom0'] = self.Dom0ToRestore(vm,
|
||||||
self.backup_app.domains['dom0'].backup_path)
|
self.backup_app.domains['dom0'].backup_path)
|
||||||
|
try:
|
||||||
local_user = grp.getgrnam('qubes').gr_mem[0]
|
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 vms_to_restore['dom0'].username != local_user:
|
||||||
if not self.options.ignore_username_mismatch:
|
if not self.options.ignore_username_mismatch:
|
||||||
@ -1674,8 +1679,12 @@ class BackupRestore(object):
|
|||||||
|
|
||||||
def _handle_dom0(self, stream):
|
def _handle_dom0(self, stream):
|
||||||
'''Extract dom0 home'''
|
'''Extract dom0 home'''
|
||||||
|
try:
|
||||||
local_user = grp.getgrnam('qubes').gr_mem[0]
|
local_user = grp.getgrnam('qubes').gr_mem[0]
|
||||||
home_dir = pwd.getpwnam(local_user).pw_dir
|
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(
|
restore_home_backupdir = "home-restore-{0}".format(
|
||||||
time.strftime("%Y-%m-%d-%H%M%S"))
|
time.strftime("%Y-%m-%d-%H%M%S"))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user