Skip to content

Commit

Permalink
backup: fix naming qubes.xml.000 in the archive
Browse files Browse the repository at this point in the history
Restore old code for calculating subdir within the archive. The new one
had two problems:
 - set '/' for empty input subdir - which caused qubes.xml.000 to be
 named '/qubes.xml.000' (and then converted to '../../qubes.xml.000');
 among other things, this results in the wrong path used for encryption
 passphrase
 - resolved symlinks, which breaks calculating path for any symlinks
 within VM's directory (symlinks there should be treated as normal files
 to be sure that actual content is included in the backup)

This partially reverts 4e49b95.

Fixes QubesOS/qubes-issues#4493
  • Loading branch information
marmarek committed Nov 15, 2018
1 parent 85a2042 commit f023b3d
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions qubes/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import itertools
import logging
import os
import pathlib
import pwd
import re
import shutil
Expand Down Expand Up @@ -260,14 +259,17 @@ def __init__(self, file_path, subdir=None, name=None, size=None):
size = qubes.storage.file.get_disk_usage(file_path)

if subdir is None:
abs_file_dir = pathlib.Path(file_path).resolve().parent
abs_base_dir = pathlib.Path(
qubes.config.system_path["qubes_base_dir"]).resolve()
# this raises ValueError if abs_file_dir is not in abs_base_dir
subdir = str(abs_file_dir.relative_to(abs_base_dir))

if not subdir.endswith(os.path.sep):
subdir += os.path.sep
abs_file_path = os.path.abspath(file_path)
abs_base_dir = os.path.abspath(
qubes.config.system_path["qubes_base_dir"]) + '/'
abs_file_dir = os.path.dirname(abs_file_path) + '/'
(nothing, directory, subdir) = \
abs_file_dir.partition(abs_base_dir)
assert nothing == ""
assert directory == abs_base_dir
else:
if subdir and not subdir.endswith('/'):
subdir += '/'

#: real path to the file
self.path = file_path
Expand Down

0 comments on commit f023b3d

Please sign in to comment.