File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change 28
28
import itertools
29
29
import logging
30
30
import os
31
+ from pathlib import Path
31
32
import pwd
32
33
import shutil
33
34
import stat
@@ -452,6 +453,14 @@ def get_files_to_backup(self):
452
453
if 0 in [vm .qid for vm in self .vms_for_backup ]:
453
454
local_user = grp .getgrnam ("qubes" ).gr_mem [0 ]
454
455
home_dir = pwd .getpwnam (local_user ).pw_dir
456
+
457
+ # Checking if target is not user home directory in dom0
458
+ if self .target_dir in ["" , "~" , None ] \
459
+ or Path (self .target_dir ).is_relative_to (home_dir ):
460
+ raise qubes .exc .QubesException (
461
+ "Can not backup dom0 home directory to itself!"
462
+ )
463
+
455
464
# Home dir should have only user-owned files, so fix it now
456
465
# to prevent permissions problems - some root-owned files can
457
466
# left after 'sudo bash' and similar commands
Original file line number Diff line number Diff line change @@ -575,6 +575,14 @@ def test_100_backup_dom0_no_restore(self):
575
575
self .make_backup ([self .app .domains [0 ]])
576
576
# TODO: think of some safe way to test restore...
577
577
578
+ def test_101_backup_dom0_to_homedir (self ):
579
+ # Test of backup into dom0 home itself results in error...
580
+ with self .assertRaises (qubes .exc .QubesException ):
581
+ self .make_backup ([self .app .domains [0 ]])
582
+ with self .assertRaises (qubes .exc .QubesException ):
583
+ self .backupdir = os .environ ["HOME" ]
584
+ self .make_backup ([self .app .domains [0 ]])
585
+
578
586
def test_200_restore_over_existing_directory (self ):
579
587
"""
580
588
Regression test for #1386
You can’t perform that action at this time.
0 commit comments