From 350393c9fdd606dc430373503bfe3bf2697d7b38 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Mon, 4 Jul 2022 23:57:17 +0200 Subject: [PATCH 1/5] remove unused imports --- setup.py | 2 +- src/borg/_hashindex.c | 1 - src/borg/archive.py | 3 +-- src/borg/chunker.pyx | 2 +- src/borg/crypto/key.py | 3 +-- src/borg/crypto/keymanager.py | 2 +- src/borg/crypto/low_level.pyx | 1 - src/borg/hashindex.pyx | 4 ---- src/borg/helpers/checks.py | 1 - src/borg/helpers/parseformat.py | 2 +- src/borg/platform/linux.pyx | 2 -- src/borg/testsuite/__init__.py | 1 - src/borg/testsuite/archiver.py | 2 -- src/borg/testsuite/hashindex.py | 1 - src/borg/testsuite/helpers.py | 1 - src/borg/testsuite/key.py | 4 ---- src/borg/testsuite/locking.py | 1 - src/borg/testsuite/platform.py | 1 - src/borg/testsuite/repository.py | 2 +- src/borg/upgrader.py | 0 20 files changed, 7 insertions(+), 29 deletions(-) delete mode 100644 src/borg/upgrader.py diff --git a/setup.py b/setup.py index 2d91a6a47..feed325ca 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ except ImportError: multiprocessing = None from setuptools.command.build_ext import build_ext -from setuptools import setup, find_packages, Extension, Command +from setuptools import setup, Extension, Command from setuptools.command.sdist import sdist try: diff --git a/src/borg/_hashindex.c b/src/borg/_hashindex.c index 7cd4cf31a..dd704d2de 100644 --- a/src/borg/_hashindex.c +++ b/src/borg/_hashindex.c @@ -1,4 +1,3 @@ - #include #include #include diff --git a/src/borg/archive.py b/src/borg/archive.py index 2c49c18fd..584f5f030 100644 --- a/src/borg/archive.py +++ b/src/borg/archive.py @@ -1,7 +1,6 @@ import base64 import json import os -import socket import stat import sys import time @@ -32,7 +31,7 @@ from .helpers import HardLinkManager from .helpers import ChunkIteratorFileWrapper, open_item from .helpers import Error, IntegrityError, set_ec from .platform import uid2user, user2uid, gid2group, group2gid -from .helpers import parse_timestamp, to_localtime +from .helpers import parse_timestamp from .helpers import OutputTimestamp, format_timedelta, format_file_size, file_status, FileSize from .helpers import safe_encode, make_path_safe, remove_surrogates from .helpers import StableDict diff --git a/src/borg/chunker.pyx b/src/borg/chunker.pyx index ee9773be4..d9c31d3e3 100644 --- a/src/borg/chunker.pyx +++ b/src/borg/chunker.pyx @@ -6,7 +6,7 @@ import errno import os from collections import namedtuple -from .constants import CH_DATA, CH_ALLOC, CH_HOLE, MAX_DATA_SIZE, zeros +from .constants import CH_DATA, CH_ALLOC, CH_HOLE, zeros from libc.stdlib cimport free diff --git a/src/borg/crypto/key.py b/src/borg/crypto/key.py index cd1fd9324..94f824942 100644 --- a/src/borg/crypto/key.py +++ b/src/borg/crypto/key.py @@ -1,4 +1,3 @@ -import configparser import hmac import os import textwrap @@ -26,7 +25,7 @@ from ..item import Key, EncryptedKey, want_bytes from ..platform import SaveFile from .nonces import NonceManager -from .low_level import AES, bytes_to_long, long_to_bytes, bytes_to_int, num_cipher_blocks, hmac_sha256, blake2b_256, hkdf_hmac_sha512 +from .low_level import AES, bytes_to_int, num_cipher_blocks, hmac_sha256, blake2b_256, hkdf_hmac_sha512 from .low_level import AES256_CTR_HMAC_SHA256, AES256_CTR_BLAKE2b, AES256_OCB, CHACHA20_POLY1305 from . import low_level diff --git a/src/borg/crypto/keymanager.py b/src/borg/crypto/keymanager.py index db5eb23c7..715d451a1 100644 --- a/src/borg/crypto/keymanager.py +++ b/src/borg/crypto/keymanager.py @@ -7,7 +7,7 @@ from hashlib import sha256 from ..helpers import Manifest, NoManifestError, Error, yes, bin_to_hex, dash_open from ..repository import Repository -from .key import CHPOKeyfileKey, KeyfileNotFoundError, RepoKeyNotFoundError, KeyBlobStorage, identify_key +from .key import CHPOKeyfileKey, RepoKeyNotFoundError, KeyBlobStorage, identify_key class UnencryptedRepo(Error): diff --git a/src/borg/crypto/low_level.pyx b/src/borg/crypto/low_level.pyx index d44160b50..c5b8c7c3f 100644 --- a/src/borg/crypto/low_level.pyx +++ b/src/borg/crypto/low_level.pyx @@ -40,7 +40,6 @@ from math import ceil from cpython cimport PyMem_Malloc, PyMem_Free from cpython.buffer cimport PyBUF_SIMPLE, PyObject_GetBuffer, PyBuffer_Release -from cpython.bytes cimport PyBytes_FromStringAndSize API_VERSION = '1.3_01' diff --git a/src/borg/hashindex.pyx b/src/borg/hashindex.pyx index 3cb8d5a4d..15b59b5da 100644 --- a/src/borg/hashindex.pyx +++ b/src/borg/hashindex.pyx @@ -1,13 +1,9 @@ # -*- coding: utf-8 -*- from collections import namedtuple -import locale -import os cimport cython from libc.stdint cimport uint32_t, UINT32_MAX, uint64_t -from libc.errno cimport errno from libc.string cimport memcpy -from cpython.exc cimport PyErr_SetFromErrnoWithFilename from cpython.buffer cimport PyBUF_SIMPLE, PyObject_GetBuffer, PyBuffer_Release from cpython.bytes cimport PyBytes_FromStringAndSize, PyBytes_CheckExact, PyBytes_GET_SIZE, PyBytes_AS_STRING diff --git a/src/borg/helpers/checks.py b/src/borg/helpers/checks.py index 316368b0c..26a6c0129 100644 --- a/src/borg/helpers/checks.py +++ b/src/borg/helpers/checks.py @@ -1,5 +1,4 @@ import os -import sys from .errors import Error from ..platformflags import is_win32, is_linux, is_freebsd, is_darwin diff --git a/src/borg/helpers/parseformat.py b/src/borg/helpers/parseformat.py index 808466776..a9d2ac960 100644 --- a/src/borg/helpers/parseformat.py +++ b/src/borg/helpers/parseformat.py @@ -20,7 +20,7 @@ logger = create_logger() from .errors import Error from .fs import get_keys_dir from .msgpack import Timestamp -from .time import OutputTimestamp, format_time, to_localtime, safe_timestamp, safe_s +from .time import OutputTimestamp, format_time, to_localtime, safe_timestamp from .. import __version__ as borg_version from .. import __version_tuple__ as borg_version_tuple from ..constants import * # NOQA diff --git a/src/borg/platform/linux.pyx b/src/borg/platform/linux.pyx index 01fe409fb..5fc37680d 100644 --- a/src/borg/platform/linux.pyx +++ b/src/borg/platform/linux.pyx @@ -1,7 +1,6 @@ import os import re import stat -import subprocess from .posix import posix_acl_use_stored_uid_gid from .posix import user2uid, group2gid @@ -17,7 +16,6 @@ except ImportError: SYNC_FILE_RANGE_LOADED = False from libc cimport errno -from libc.stdint cimport int64_t API_VERSION = '1.2_05' diff --git a/src/borg/testsuite/__init__.py b/src/borg/testsuite/__init__.py index 307798e64..0ad942482 100644 --- a/src/borg/testsuite/__init__.py +++ b/src/borg/testsuite/__init__.py @@ -12,7 +12,6 @@ import sys import sysconfig import tempfile import time -import uuid import unittest from ..xattr import get_all diff --git a/src/borg/testsuite/archiver.py b/src/borg/testsuite/archiver.py index d568d2a9c..4a29440d4 100644 --- a/src/borg/testsuite/archiver.py +++ b/src/borg/testsuite/archiver.py @@ -35,7 +35,6 @@ from ..archiver import Archiver, parse_storage_quota, PURE_PYTHON_MSGPACK_WARNIN from ..cache import Cache, LocalCache from ..chunker import has_seek_hole from ..constants import * # NOQA -from ..crypto.low_level import bytes_to_long, num_cipher_blocks from ..crypto.key import FlexiKey, AESOCBRepoKey, AESOCBKeyfileKey, CHPOKeyfileKey, Passphrase, TAMRequiredError from ..crypto.keymanager import RepoIdMismatch, NotABorgKeyFile from ..crypto.file_integrity import FileIntegrityError @@ -43,7 +42,6 @@ from ..helpers import Location, get_security_dir from ..helpers import Manifest, MandatoryFeatureUnsupported from ..helpers import EXIT_SUCCESS, EXIT_WARNING, EXIT_ERROR from ..helpers import bin_to_hex -from ..helpers import MAX_S from ..helpers import msgpack from ..helpers import flags_noatime, flags_normal from ..nanorst import RstToTextLazy, rst_to_terminal diff --git a/src/borg/testsuite/hashindex.py b/src/borg/testsuite/hashindex.py index b05ff77fd..b98444c3a 100644 --- a/src/borg/testsuite/hashindex.py +++ b/src/borg/testsuite/hashindex.py @@ -9,7 +9,6 @@ import tempfile import zlib from ..hashindex import NSIndex, ChunkIndex, ChunkIndexEntry -from .. import hashindex from ..crypto.file_integrity import IntegrityCheckedFile, FileIntegrityError from . import BaseTestCase, unopened_tempfile diff --git a/src/borg/testsuite/helpers.py b/src/borg/testsuite/helpers.py index ca2b89bf1..7a532c9d6 100644 --- a/src/borg/testsuite/helpers.py +++ b/src/borg/testsuite/helpers.py @@ -7,7 +7,6 @@ import sys from argparse import ArgumentTypeError from datetime import datetime, timezone, timedelta from io import StringIO, BytesIO -from time import sleep import pytest diff --git a/src/borg/testsuite/key.py b/src/borg/testsuite/key.py index b202d1078..2b69e73b0 100644 --- a/src/borg/testsuite/key.py +++ b/src/borg/testsuite/key.py @@ -1,5 +1,3 @@ -import getpass -import os.path import re import tempfile from binascii import hexlify, unhexlify, a2b_base64 @@ -15,12 +13,10 @@ from ..crypto.key import Blake2AESOCBRepoKey, Blake2AESOCBKeyfileKey, Blake2CHPO from ..crypto.key import ID_HMAC_SHA_256, ID_BLAKE2b_256 from ..crypto.key import TAMRequiredError, TAMInvalid, TAMUnsupportedSuiteError, UnsupportedManifestError, UnsupportedKeyFormatError from ..crypto.key import identify_key -from ..crypto.low_level import bytes_to_long from ..crypto.low_level import IntegrityError as IntegrityErrorBase from ..helpers import IntegrityError from ..helpers import Location from ..helpers import StableDict -from ..helpers import get_security_dir from ..helpers import msgpack from ..constants import KEY_ALGORITHMS diff --git a/src/borg/testsuite/locking.py b/src/borg/testsuite/locking.py index 7a0f219cd..656909ac5 100644 --- a/src/borg/testsuite/locking.py +++ b/src/borg/testsuite/locking.py @@ -5,7 +5,6 @@ from traceback import format_exc import pytest -from ..helpers import daemonize from ..platform import get_process_id, process_alive from ..locking import TimeoutTimer, ExclusiveLock, Lock, LockRoster, \ ADD, REMOVE, SHARED, EXCLUSIVE, LockTimeout, NotLocked, NotMyLock diff --git a/src/borg/testsuite/platform.py b/src/borg/testsuite/platform.py index 659e4376e..35d444845 100644 --- a/src/borg/testsuite/platform.py +++ b/src/borg/testsuite/platform.py @@ -1,6 +1,5 @@ import functools import os -import random import shutil import sys import tempfile diff --git a/src/borg/testsuite/repository.py b/src/borg/testsuite/repository.py index a794f98ec..9248e5d8f 100644 --- a/src/borg/testsuite/repository.py +++ b/src/borg/testsuite/repository.py @@ -13,7 +13,7 @@ from ..helpers import Location from ..helpers import IntegrityError from ..helpers import msgpack from ..locking import Lock, LockFailed -from ..remote import RemoteRepository, InvalidRPCMethod, PathNotAllowed, ConnectionClosedWithHint, handle_remote_line +from ..remote import RemoteRepository, InvalidRPCMethod, PathNotAllowed, handle_remote_line from ..repository import Repository, LoggedIO, MAGIC, MAX_DATA_SIZE, TAG_DELETE, TAG_PUT2, TAG_PUT, TAG_COMMIT from . import BaseTestCase from .hashindex import H diff --git a/src/borg/upgrader.py b/src/borg/upgrader.py deleted file mode 100644 index e69de29bb..000000000 From f04b2bd25550b95db776f865c645e8dad8660899 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Tue, 5 Jul 2022 00:08:51 +0200 Subject: [PATCH 2/5] remove coding: from cython files, utf-8 is default encoding --- src/borg/chunker.pyx | 2 -- src/borg/hashindex.pyx | 1 - 2 files changed, 3 deletions(-) diff --git a/src/borg/chunker.pyx b/src/borg/chunker.pyx index d9c31d3e3..f11e93b2d 100644 --- a/src/borg/chunker.pyx +++ b/src/borg/chunker.pyx @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - API_VERSION = '1.2_01' import errno diff --git a/src/borg/hashindex.pyx b/src/borg/hashindex.pyx index 15b59b5da..3df89f365 100644 --- a/src/borg/hashindex.pyx +++ b/src/borg/hashindex.pyx @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from collections import namedtuple cimport cython From ff46a03b4212fab583f13ebf70ca608d268f06c4 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Tue, 5 Jul 2022 00:16:48 +0200 Subject: [PATCH 3/5] use language_level = 3str for cython this will be the default in cython 3. --- setup.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/setup.py b/setup.py index feed325ca..b0b380354 100644 --- a/setup.py +++ b/setup.py @@ -225,9 +225,7 @@ if not on_rtd: if cythonize and cythonizing: cython_opts = dict( - # default language_level will be '3str' starting from Cython 3.0.0, - # but old cython versions (< 0.29) do not know that, thus we use 3 for now. - compiler_directives={'language_level': 3}, + compiler_directives={'language_level': '3str'}, ) if not is_win32: # compile .pyx extensions to .c in parallel, does not work on windows From dbe62b8074d94788638ed19f2b9cdc64d0c69545 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Tue, 5 Jul 2022 00:21:03 +0200 Subject: [PATCH 4/5] docs: replaced tabs by spaces --- docs/deployment/hosting-repositories.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/deployment/hosting-repositories.rst b/docs/deployment/hosting-repositories.rst index fd534e734..24dc5213d 100644 --- a/docs/deployment/hosting-repositories.rst +++ b/docs/deployment/hosting-repositories.rst @@ -37,11 +37,11 @@ SSH access to safe operations only. .. warning:: - If this file should be automatically updated (e.g. by a web console), - pay **utmost attention** to sanitizing user input. Strip all whitespace - around the user-supplied key, ensure that it **only** contains ASCII - with no control characters and that it consists of three parts separated - by a single space. Ensure that no newlines are contained within the key. + If this file should be automatically updated (e.g. by a web console), + pay **utmost attention** to sanitizing user input. Strip all whitespace + around the user-supplied key, ensure that it **only** contains ASCII + with no control characters and that it consists of three parts separated + by a single space. Ensure that no newlines are contained within the key. The ``restrict`` keyword enables all restrictions, i.e. disables port, agent and X11 forwarding, as well as disabling PTY allocation and execution of ~/.ssh/rc. @@ -59,7 +59,7 @@ which allows for encryption. **Storage quotas** can be enabled by adding the ``--storage-quota`` option to the ``borg serve`` command line:: - restrict,command="borg serve --storage-quota 20G ..." ... + restrict,command="borg serve --storage-quota 20G ..." ... The storage quotas of repositories are completely independent. If a client is able to access multiple repositories, each repository From dbb63f874bb50b5978f56af0580fcb05a729973c Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Tue, 5 Jul 2022 00:38:37 +0200 Subject: [PATCH 5/5] docs: fix rst literal blocks --- docs/development.rst | 2 ++ docs/usage/compact.rst | 1 + docs/usage/create.rst | 1 + docs/usage/delete.rst | 1 + docs/usage/diff.rst | 1 + docs/usage/extract.rst | 1 + docs/usage/info.rst | 1 + docs/usage/list.rst | 1 + docs/usage/notes.rst | 1 + docs/usage/rcreate.rst | 1 + docs/usage/rdelete.rst | 1 + docs/usage/recreate.rst | 1 + docs/usage/rename.rst | 1 + docs/usage/rinfo.rst | 1 + docs/usage/transfer.rst | 1 + 15 files changed, 16 insertions(+) diff --git a/docs/development.rst b/docs/development.rst index 5eeaae83b..5051829d9 100644 --- a/docs/development.rst +++ b/docs/development.rst @@ -349,11 +349,13 @@ Checklist: scripts/sdist-sign X.Y.Z scripts/upload-pypi X.Y.Z test scripts/upload-pypi X.Y.Z + - Put binaries into dist/borg-OSNAME and sign them: :: scripts/sign-binaries 201912312359 + - Close the release milestone on GitHub. - `Update borgbackup.org `_ with the diff --git a/docs/usage/compact.rst b/docs/usage/compact.rst index 6a3a15ad0..3a1389a67 100644 --- a/docs/usage/compact.rst +++ b/docs/usage/compact.rst @@ -6,3 +6,4 @@ Examples # compact segments and free repo disk space $ borg compact + diff --git a/docs/usage/create.rst b/docs/usage/create.rst index 9d88b5469..a64d63b96 100644 --- a/docs/usage/create.rst +++ b/docs/usage/create.rst @@ -83,3 +83,4 @@ Examples --paths-from-stdin \ --paths-delimiter "\0" \ smallfiles-handle-newline + diff --git a/docs/usage/delete.rst b/docs/usage/delete.rst index 56fc6e4e8..d62ef4927 100644 --- a/docs/usage/delete.rst +++ b/docs/usage/delete.rst @@ -17,3 +17,4 @@ Examples # see what would be deleted if delete was run without --dry-run $ borg delete --list --dry-run -a '*-May-*' + diff --git a/docs/usage/diff.rst b/docs/usage/diff.rst index c758aceff..c372c3c06 100644 --- a/docs/usage/diff.rst +++ b/docs/usage/diff.rst @@ -15,3 +15,4 @@ Examples {"path": "file2", "changes": [{"type": "modified", "added": 135, "removed": 252}]} {"path": "file4", "changes": [{"type": "added", "size": 0}]} {"path": "file3", "changes": [{"type": "removed", "size": 0}]} + diff --git a/docs/usage/extract.rst b/docs/usage/extract.rst index 1d53fb338..95703eaf0 100644 --- a/docs/usage/extract.rst +++ b/docs/usage/extract.rst @@ -21,3 +21,4 @@ Examples # Restore a raw device (must not be active/in use/mounted at that time) $ borg extract --stdout my-sdx | dd of=/dev/sdx bs=10M + diff --git a/docs/usage/info.rst b/docs/usage/info.rst index 36aa623fa..b248aaeeb 100644 --- a/docs/usage/info.rst +++ b/docs/usage/info.rst @@ -18,3 +18,4 @@ Examples Number of files: 244 Original size: 13.80 MB Deduplicated size: 531 B + diff --git a/docs/usage/list.rst b/docs/usage/list.rst index 7fdc8d5d4..e168faf46 100644 --- a/docs/usage/list.rst +++ b/docs/usage/list.rst @@ -35,3 +35,4 @@ Examples -rw-rw-r-- user user 1416192 Sun, 2015-02-01 11:00:00 code/myproject/file.ext -rw-rw-r-- user user 1416192 Sun, 2015-02-01 11:00:00 code/myproject/file.text ... + diff --git a/docs/usage/notes.rst b/docs/usage/notes.rst index 7ecdcdca4..b4e1637a5 100644 --- a/docs/usage/notes.rst +++ b/docs/usage/notes.rst @@ -333,3 +333,4 @@ When running Borg using an automated script, ``ssh`` might still ask for a passw even if there is an SSH key for the target server. Use this to make scripts more robust:: export BORG_RSH='ssh -oBatchMode=yes' + diff --git a/docs/usage/rcreate.rst b/docs/usage/rcreate.rst index 967387b01..985c29c34 100644 --- a/docs/usage/rcreate.rst +++ b/docs/usage/rcreate.rst @@ -23,3 +23,4 @@ Examples $ borg rcreate --encryption=repokey-aes-ocb # keyfile: stores the (encrypted) key into ~/.config/borg/keys/ $ borg rcreate --encryption=keyfile-aes-ocb + diff --git a/docs/usage/rdelete.rst b/docs/usage/rdelete.rst index ee189f2cc..e7b3acdda 100644 --- a/docs/usage/rdelete.rst +++ b/docs/usage/rdelete.rst @@ -11,3 +11,4 @@ Examples root-2016-02-15 Mon, 2016-02-15 19:36:29 newname Mon, 2016-02-15 19:50:19 Type 'YES' if you understand this and want to continue: YES + diff --git a/docs/usage/recreate.rst b/docs/usage/recreate.rst index 7f520acf2..c10df4ae5 100644 --- a/docs/usage/recreate.rst +++ b/docs/usage/recreate.rst @@ -27,3 +27,4 @@ Examples Fingerprint: ... Comment: This is a better comment ... + diff --git a/docs/usage/rename.rst b/docs/usage/rename.rst index a4a9bc9ee..2fb046726 100644 --- a/docs/usage/rename.rst +++ b/docs/usage/rename.rst @@ -11,3 +11,4 @@ Examples $ borg rename archivename newname $ borg rlist newname Mon, 2016-02-15 19:50:19 + diff --git a/docs/usage/rinfo.rst b/docs/usage/rinfo.rst index 0b1097207..c2d09cb40 100644 --- a/docs/usage/rinfo.rst +++ b/docs/usage/rinfo.rst @@ -14,3 +14,4 @@ Examples Deduplicated size: 30.38 MB Unique chunks: 654 Total chunks: 3302 + diff --git a/docs/usage/transfer.rst b/docs/usage/transfer.rst index 45f370b8c..cab2d2a62 100644 --- a/docs/usage/transfer.rst +++ b/docs/usage/transfer.rst @@ -29,3 +29,4 @@ Examples # 4. Check if we have everything (same as 2.): $ borg --repo ssh://borg2@borgbackup/./tests/b20 transfer \ --other-repo ssh://borg2@borgbackup/./tests/b12 --dry-run +