Pārlūkot izejas kodu

BORG_MSGPACK_VERSION_CHECK=no to disable the version check, fixes #9109

Thomas Waldmann 12 stundas atpakaļ
vecāks
revīzija
2d63dc9a4f

+ 2 - 0
docs/changes.rst

@@ -430,6 +430,8 @@ New features:
 - create: --files-changed=MODE option (controls how borg detects whether
   a file has changed while it is being backed up)
 - improved tty-less progress reporting (--progress)
+- BORG_MSGPACK_VERSION_CHECK=no to optionally disable the msgpack version
+  check; default is "yes", use at your own risk, #9109.
 
 Fixes:
 

+ 5 - 0
docs/usage/general/environment.rst.inc

@@ -70,6 +70,11 @@ General:
         When set to no (default: yes), system information (like OS, Python version, ...) in
         exceptions is not shown.
         Please only use for good reasons as it makes issues harder to analyze.
+    BORG_MSGPACK_VERSION_CHECK
+        Controls whether Borg checks the ``msgpack`` version.
+        The default is ``yes`` (strict check). Set to ``no`` to disable the version check and
+        allow any installed ``msgpack`` version. Use this at your own risk; malfunctioning or
+        incompatible ``msgpack`` versions may cause subtle bugs or repository data corruption.
     BORG_FUSE_IMPL
         Choose the lowlevel FUSE implementation borg shall use for ``borg mount``.
         This is a comma-separated list of implementation names, they are tried in the

+ 11 - 2
src/borg/helpers/msgpack.py

@@ -1,3 +1,5 @@
+import os
+
 from .datastruct import StableDict
 from ..constants import *  # NOQA
 
@@ -136,9 +138,16 @@ def is_slow_msgpack():
 
 def is_supported_msgpack():
     # DO NOT CHANGE OR REMOVE! See also requirements and comments in pyproject.toml.
+    # This function now also respects the env var BORG_MSGPACK_VERSION_CHECK.
+    # Set BORG_MSGPACK_VERSION_CHECK=no to disable the version check on your own risk.
     import msgpack
-    return (1, 0, 3) <= msgpack.version[:3] <= (1, 1, 2) and \
-           msgpack.version not in []  # < add bad releases here to deny list
+
+    version_check = os.environ.get('BORG_MSGPACK_VERSION_CHECK', 'yes').strip().lower()
+
+    return version_check == 'no' or (
+        (1, 0, 3) <= msgpack.version[:3] <= (1, 1, 2) and
+        msgpack.version not in []
+    )
 
 
 def get_limited_unpacker(kind):