From 6a5b3018c1c1d3c8db13dd93bb22c7297ce78afd Mon Sep 17 00:00:00 2001 From: Marian Beermann Date: Tue, 3 Jan 2017 17:15:32 +0100 Subject: [PATCH 1/3] fix upgrade --tam crashing if repository is not encrypted --- borg/archiver.py | 4 ++++ docs/changes.rst | 2 ++ 2 files changed, 6 insertions(+) diff --git a/borg/archiver.py b/borg/archiver.py index 7ad2195d8..973ea6f7a 100644 --- a/borg/archiver.py +++ b/borg/archiver.py @@ -730,6 +730,10 @@ class Archiver: if args.tam: manifest, key = Manifest.load(repository, force_tam_not_required=args.force) + if not hasattr(key, 'change_passphrase'): + print('This repository is not encrypted, cannot enable TAM.') + return EXIT_ERROR + if not manifest.tam_verified or not manifest.config.get(b'tam_required', False): # The standard archive listing doesn't include the archive ID like in borg 1.1.x print('Manifest contents:') diff --git a/docs/changes.rst b/docs/changes.rst index 7e3c876fd..ae471af86 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -133,6 +133,8 @@ Bug fixes: - Avoid triggering an ObjectiveFS bug in xattr retrieval, #1992 - When running out of buffer memory when reading xattrs, only skip the current file, #1993 +- Fixed "borg upgrade --tam" crashing with unencrypted repositories. Since :ref:`the issue ` is + not relevant for unencrypted repositories, it now does nothing and prints an error, #1981. Version 1.0.9 (2016-12-20) -------------------------- From 7519bf8100a3aa9d664d39f2d4f0dd7a1ff7b10e Mon Sep 17 00:00:00 2001 From: Marian Beermann Date: Tue, 3 Jan 2017 17:15:59 +0100 Subject: [PATCH 2/3] fix change-passphrase crashing if repository is not encrypted --- borg/archiver.py | 3 +++ docs/changes.rst | 1 + 2 files changed, 4 insertions(+) diff --git a/borg/archiver.py b/borg/archiver.py index 973ea6f7a..1adbba895 100644 --- a/borg/archiver.py +++ b/borg/archiver.py @@ -177,6 +177,9 @@ class Archiver: @with_repository() def do_change_passphrase(self, args, repository, manifest, key): """Change repository key file passphrase""" + if not hasattr(key, 'change_passphrase'): + print('This repository is not encrypted, cannot change the passphrase.') + return EXIT_ERROR key.change_passphrase() logger.info('Key updated') return EXIT_SUCCESS diff --git a/docs/changes.rst b/docs/changes.rst index ae471af86..301246004 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -135,6 +135,7 @@ Bug fixes: - When running out of buffer memory when reading xattrs, only skip the current file, #1993 - Fixed "borg upgrade --tam" crashing with unencrypted repositories. Since :ref:`the issue ` is not relevant for unencrypted repositories, it now does nothing and prints an error, #1981. +- Fixed change-passphrase crashing with unencrypted repositories, #1978 Version 1.0.9 (2016-12-20) -------------------------- From 4b9a9f9b5ec8fd54be78569b2e5e9201a2a9dada Mon Sep 17 00:00:00 2001 From: Marian Beermann Date: Tue, 3 Jan 2017 13:00:37 +0100 Subject: [PATCH 3/3] change-passphrase: print key location --- borg/archiver.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/borg/archiver.py b/borg/archiver.py index 1adbba895..c8c80f37c 100644 --- a/borg/archiver.py +++ b/borg/archiver.py @@ -182,6 +182,9 @@ class Archiver: return EXIT_ERROR key.change_passphrase() logger.info('Key updated') + if hasattr(key, 'find_key'): + # print key location to make backing it up easier + logger.info('Key location: %s', key.find_key()) return EXIT_SUCCESS @with_repository(lock=False, exclusive=False, manifest=False, cache=False)