From 39496bf65a1666ca4d8315cdaa2901b81b64f8f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Tue, 13 May 2014 03:11:06 +0200 Subject: [PATCH] backups: use more restrictive pattern for directory canonicalization (#840) The --xform option affects all the names - including symlink targets. So make the pattern as precise as possible to not break symlinks in dom0 home backup. Still not ideal, but at least limit damage to relative symlinks pointing at directory (which hopefully user will not create). Previous version broke all relative symlinks... --- core/backup.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/backup.py b/core/backup.py index 623f93e1..fddd8cbb 100644 --- a/core/backup.py +++ b/core/backup.py @@ -511,7 +511,9 @@ def backup_do(base_backup_dir, files_to_backup, passphrase, "-f", backup_pipe, '--tape-length', str(100000), '-C', os.path.dirname(filename["path"]), - '--xform', 's:^[^/]:%s\\0:' % filename["subdir"], + '--xform', 's:^%s:%s\\0:' % ( + os.path.basename(filename["path"]), + filename["subdir"]), os.path.basename(filename["path"]) ] @@ -1674,7 +1676,7 @@ def backup_restore_do(restore_info, if format_version == 2: if 'dom0' in restore_info.keys() and restore_info['dom0']['good-to-go']: - vms_dirs.append('dom0-home') + vms_dirs.append(os.path.dirname(restore_info['dom0']['subdir'])) vms_size += restore_info['dom0']['size'] restore_vm_dirs (backup_location,