Преглед изворни кода

fix upgrade --tam crashing if repository is not encrypted

Marian Beermann пре 8 година
родитељ
комит
6a5b3018c1
2 измењених фајлова са 6 додато и 0 уклоњено
  1. 4 0
      borg/archiver.py
  2. 2 0
      docs/changes.rst

+ 4 - 0
borg/archiver.py

@@ -730,6 +730,10 @@ class Archiver:
         if args.tam:
         if args.tam:
             manifest, key = Manifest.load(repository, force_tam_not_required=args.force)
             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):
             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
                 # The standard archive listing doesn't include the archive ID like in borg 1.1.x
                 print('Manifest contents:')
                 print('Manifest contents:')

+ 2 - 0
docs/changes.rst

@@ -133,6 +133,8 @@ Bug fixes:
 
 
 - Avoid triggering an ObjectiveFS bug in xattr retrieval, #1992
 - Avoid triggering an ObjectiveFS bug in xattr retrieval, #1992
 - When running out of buffer memory when reading xattrs, only skip the current file, #1993
 - 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 <tam_vuln>` is
+  not relevant for unencrypted repositories, it now does nothing and prints an error, #1981.
 
 
 Version 1.0.9 (2016-12-20)
 Version 1.0.9 (2016-12-20)
 --------------------------
 --------------------------