2929import sys
3030
3131import asyncio
32+ import grp
33+ import pwd
3234
3335import qubes
3436import qubes .backup
@@ -198,7 +200,9 @@ def make_backup(self, vms, target=None, expect_failure=False, **kwargs):
198200 if target is None :
199201 target = self .backupdir
200202 try :
201- backup = qubes .backup .Backup (self .app , vms , ** kwargs )
203+ backup = qubes .backup .Backup (
204+ self .app , vms , target_dir = target , ** kwargs
205+ )
202206 except qubes .exc .QubesException as e :
203207 if not expect_failure :
204208 self .fail ("QubesException during backup_prepare: %s" % str (e ))
@@ -207,7 +211,6 @@ def make_backup(self, vms, target=None, expect_failure=False, **kwargs):
207211
208212 if "passphrase" not in kwargs :
209213 backup .passphrase = "qubes"
210- backup .target_dir = target
211214
212215 try :
213216 self .loop .run_until_complete (backup .backup_do ())
@@ -575,6 +578,21 @@ def test_100_backup_dom0_no_restore(self):
575578 self .make_backup ([self .app .domains [0 ]])
576579 # TODO: think of some safe way to test restore...
577580
581+ def test_101_backup_dom0_to_dom0_home (self ):
582+ # Assure backing up dom0 to dom0 home itself is refused...
583+ local_user = grp .getgrnam ("qubes" ).gr_mem [0 ]
584+ home_dir = pwd .getpwnam (local_user ).pw_dir
585+ with self .assertRaises (qubes .exc .QubesException ):
586+ self .make_backup (
587+ [self .app .domains [0 ]], target = home_dir , expect_failure = True
588+ )
589+ with self .assertRaises (qubes .exc .QubesException ):
590+ self .make_backup (
591+ [self .app .domains [0 ]],
592+ target = os .path .join (home_dir , "somedir" ),
593+ expect_failure = True ,
594+ )
595+
578596 def test_200_restore_over_existing_directory (self ):
579597 """
580598 Regression test for #1386
0 commit comments