1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-02-25 07:23:28 +00:00

use correct path for security dir when accessing legacy repos (v1)

while on macOS the new and old security dir location is the same path,
this is not the case on e.g. Linux, it could move from .config/borg/security to
.local/share/borg/security .

See #5760.
This commit is contained in:
Thomas Waldmann 2023-05-19 20:54:45 +02:00
parent c8996aaf12
commit 989b0a2847
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01
3 changed files with 4 additions and 3 deletions

View file

@ -62,7 +62,7 @@ class SecurityManager:
def __init__(self, repository):
self.repository = repository
self.dir = get_security_dir(repository.id_str)
self.dir = get_security_dir(repository.id_str, legacy=(repository.version == 1))
self.cache_dir = cache_dir(repository)
self.key_type_file = os.path.join(self.dir, "key-type")
self.location_file = os.path.join(self.dir, "location")
@ -71,7 +71,7 @@ def __init__(self, repository):
@staticmethod
def destroy(repository, path=None):
"""destroy the security dir for ``repository`` or at ``path``"""
path = path or get_security_dir(repository.id_str)
path = path or get_security_dir(repository.id_str, legacy=(repository.version == 1))
if os.path.exists(path):
shutil.rmtree(path)

View file

@ -114,7 +114,7 @@ def key_factory(repository, manifest_chunk, *, ro_cls=RepoObj):
def tam_required_file(repository):
security_dir = get_security_dir(bin_to_hex(repository.id))
security_dir = get_security_dir(bin_to_hex(repository.id), legacy=(repository.version == 1))
return os.path.join(security_dir, "tam_required")

View file

@ -115,6 +115,7 @@ def canonical_path(self):
_location = _Location()
id = bytes(32)
id_str = bin_to_hex(id)
version = 2
def save_key(self, data):
self.key_data = data