浏览代码

Merge pull request #6836 from ThomasWaldmann/cleanups

Cleanups
TW 2 年之前
父节点
当前提交
dbb9f62afd

+ 6 - 6
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

+ 2 - 0
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
   <https://github.com/borgbackup/borgbackup.github.io/pull/53/files>`_ with the

+ 1 - 0
docs/usage/compact.rst

@@ -6,3 +6,4 @@ Examples
 
     # compact segments and free repo disk space
     $ borg compact
+

+ 1 - 0
docs/usage/create.rst

@@ -83,3 +83,4 @@ Examples
         --paths-from-stdin \
         --paths-delimiter "\0" \
         smallfiles-handle-newline
+

+ 1 - 0
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-*'
+

+ 1 - 0
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}]}
+

+ 1 - 0
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
+

+ 1 - 0
docs/usage/info.rst

@@ -18,3 +18,4 @@ Examples
     Number of files: 244
     Original size: 13.80 MB
     Deduplicated size: 531 B
+

+ 1 - 0
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
     ...
+

+ 1 - 0
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'
+

+ 1 - 0
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
+

+ 1 - 0
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
+

+ 1 - 0
docs/usage/recreate.rst

@@ -27,3 +27,4 @@ Examples
     Fingerprint: ...
     Comment: This is a better comment
     ...
+

+ 1 - 0
docs/usage/rename.rst

@@ -11,3 +11,4 @@ Examples
     $ borg rename archivename newname
     $ borg rlist
     newname                              Mon, 2016-02-15 19:50:19
+

+ 1 - 0
docs/usage/rinfo.rst

@@ -14,3 +14,4 @@ Examples
     Deduplicated size: 30.38 MB
     Unique chunks: 654
     Total chunks: 3302
+

+ 1 - 0
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
+

+ 2 - 4
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:
@@ -224,9 +224,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

+ 0 - 1
src/borg/_hashindex.c

@@ -1,4 +1,3 @@
-
 #include <assert.h>
 #include <errno.h>
 #include <stdio.h>

+ 1 - 2
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

+ 1 - 3
src/borg/chunker.pyx

@@ -1,12 +1,10 @@
-# -*- coding: utf-8 -*-
-
 API_VERSION = '1.2_01'
 
 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
 

+ 1 - 2
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
 

+ 1 - 1
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):

+ 0 - 1
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'
 

+ 0 - 5
src/borg/hashindex.pyx

@@ -1,13 +1,8 @@
-# -*- 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
 

+ 0 - 1
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

+ 1 - 1
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

+ 0 - 2
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'
 

+ 0 - 1
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

+ 0 - 2
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

+ 0 - 1
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
 

+ 0 - 1
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
 

+ 0 - 4
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
 

+ 0 - 1
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

+ 0 - 1
src/borg/testsuite/platform.py

@@ -1,6 +1,5 @@
 import functools
 import os
-import random
 import shutil
 import sys
 import tempfile

+ 1 - 1
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

+ 0 - 0
src/borg/upgrader.py