Commit Graph

8177 Commits

Author SHA1 Message Date
TW f43fcd3bdb
Merge pull request #7686 from ThomasWaldmann/fwd-ports
misc fwd ports
2023-06-30 00:20:01 +02:00
Thomas Waldmann 58d3dbcec0
keyfile: improve key sanity check, fixes #7561
check key file structure, make sure the binary key
is not way too short (or zero) length.

if key file looks strange, emit warnings.
2023-06-29 23:13:29 +02:00
Thomas Waldmann ec1f2dfbf1
--files-cache=size: fix crash, fixes #7658 2023-06-29 23:09:24 +02:00
Thomas Waldmann 4326813c05
do not upload gpg signature to pypi, fixes #7649 2023-06-29 23:06:28 +02:00
Thomas Waldmann 81c3cb957e
list: fix --pattern examples, fixes #7611
- pattern needs to start with + - !
- first match wins
- the default is to list everything, thus a 2nd pattern
  is needed to exclude everything not matched by 1st pattern.
2023-06-29 23:04:21 +02:00
TW b37c38afa9
Merge pull request #7685 from ThomasWaldmann/gha-reduce-master
github actions CI: misc improvements
2023-06-29 22:59:08 +02:00
Thomas Waldmann 06fa81aeb0
trivial change to trigger CI 2023-06-29 20:06:26 +02:00
Thomas Waldmann cab8e5d013
github actions CI: win/mac both need linux succeed first, fixes #7684
also:
- XDISTN=6, 3 cores on macOS machines
- XDISTN=4, 2 cores on windows/linux machines
2023-06-29 19:59:39 +02:00
Thomas Waldmann e9f766dbbf
gha: remove outdated borg2 branch 2023-06-28 15:27:26 +02:00
TW 349514446f
Merge pull request #7667 from ThomasWaldmann/skip-sparse-test-win32-master
test_sparse_file: skip test on win32
2023-06-23 00:15:44 +02:00
Thomas Waldmann 45cda981f9
test_sparse_file: skip test on win32
about 10-50% of the github windows CI runs fail due to
this - root cause unknown.

Example failure:

        # we first check if we could create a sparse input file:
        sparse_support = is_sparse(filename, total_size, hole_size)
        if sparse_support:
            # we could create a sparse input file, so creating a backup of it and
            # extracting it again (as sparse) should also work:
            self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION)
            self.cmd(f"--repo={self.repository_location}", "create", "test", "input")
            with changedir(self.output_path):
                self.cmd(f"--repo={self.repository_location}", "extract", "test", "--sparse")
            self.assert_dirs_equal("input", "output/input")
            filename = os.path.join(self.output_path, "input", "sparse")
            with open(filename, "rb") as fd:
                # check if file contents are as expected
>               self.assert_equal(fd.read(hole_size), b"\0" * hole_size)
E               AssertionError: b'\x0[8388602 chars]x00\xf0Y\xb5\xe3\xee\xf3\x1f\xe3L\xcf\xae\x92\[159253621 chars]\x00' != b'\x0[8388602 chars]x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0[159383505 chars]\x00'

src/borg/testsuite/archiver/extract_cmd.py:212: AssertionError
2023-06-22 23:10:31 +02:00
TW c89eb98c18
Merge pull request #7665 from ThomasWaldmann/fix-benchmark
benchmark cpu: use sanitized path, fixes #7653
2023-06-22 21:56:31 +02:00
TW 67a32ee603
Merge pull request #7664 from ThomasWaldmann/test-for-backslashes
no backslashes
2023-06-22 21:41:37 +02:00
Thomas Waldmann 420eae6138
benchmark cpu: use sanitized path, fixes #7654 2023-06-22 21:22:18 +02:00
TW 44147fe5b3
Merge pull request #7663 from ThomasWaldmann/send-log-cb
remote logging/progress: add callback to send queued records, fixes #7662
2023-06-22 21:19:18 +02:00
Thomas Waldmann 4f49f9bae6
make_path_safe: remove test for backslashes, fixes #7651
looks like some tools use backslashes in linux/macOS paths.
2023-06-22 20:49:14 +02:00
Thomas Waldmann 3aec98ada9
remote logging/progress: use callback to send queued records, fixes #7662 2023-06-22 20:09:29 +02:00
Ted Lawson a5c4d0d310
Xattr.py unittest to pytest conversion (#7657) 2023-06-20 16:08:44 +02:00
azrdev 27bcc0f05a
automated-local.rst: Partition table UUID match works for MBR too
not only GPT
2023-06-16 23:28:36 +02:00
TW 96076a71d2
Merge pull request #7646 from ThomasWaldmann/rel200b6
Release 2.0.0b6
2023-06-12 10:35:23 +02:00
Thomas Waldmann 4dca508848
build_man 2023-06-11 23:10:23 +02:00
Thomas Waldmann 70602bda52
build_usage 2023-06-11 23:09:20 +02:00
Thomas Waldmann fbf463496b
docs: fix some markup / linking issues 2023-06-11 23:03:21 +02:00
Thomas Waldmann 82f180b3c4
update CHANGES, set release date 2023-06-11 22:53:11 +02:00
Tarrailt 616d5e7330
Add --format option to `borg diff`, resolve issue #4634 (#7534)
diff: add --format option

also: refactoring/improvements of BaseFormatter
2023-06-11 22:41:36 +02:00
TW 8506c05ab6
Merge pull request #7642 from Deric-W/typehints
replace `LRUCache` internals with `OrderedDict`
2023-06-11 17:11:41 +02:00
Eric Wolf ad3c890167
rephrase docstring and remove unused sentinel 2023-06-11 13:56:58 +02:00
TW e1e9b4031d
Merge pull request #7643 from ThomasWaldmann/vagrant-updates
Vagrant updates
2023-06-10 23:02:46 +02:00
Eric Wolf e683c80c75
replace `LRUCache` internals with `OrderedDict`
Replacing the internals should make the implementation faster
and simpler since the order tracking is done by the `OrderedDict`.

Furthermore, this commit adds type hints to `LRUCache` and
renames the `upd` method to `replace` to make its use more clear.
2023-06-10 20:57:32 +02:00
Thomas Waldmann 45e00f9df8
vagrant: darwin64 box: install openssl after xxhash
otherwise a openssl build error might manifest in complaints about xxhash not being installed.
2023-06-10 16:54:08 +02:00
Thomas Waldmann 47df6f5a5d
vagrant: use debian/bookworm64 box 2023-06-10 16:51:41 +02:00
TW 0aa165859e
Merge pull request #7637 from ThomasWaldmann/update-changes
update CHANGES
2023-06-10 14:54:21 +02:00
Thomas Waldmann a347e01919
update CHANGES 2023-06-10 14:53:29 +02:00
TW 4f76f595a9
Merge pull request #7635 from eoli3n/master
Improve patterns help
2023-06-10 14:39:31 +02:00
TW aca2021112
Merge pull request #7108 from pgerber/dotdot
Sanitize paths during archive creation and extraction
2023-06-10 14:38:57 +02:00
Thomas Waldmann 518c4fbca8
skip test_import_tar_with_dotdot for binary testing 2023-06-10 14:17:07 +02:00
eoli3n 095d5f463b improve patterns help: added declarative includes sample 2023-06-10 14:00:06 +02:00
eoli3n ba922d2e0a improve patterns help: define a pattern style 2023-06-10 14:00:06 +02:00
eoli3n 9bbb38d9ab improve patterns help 2023-06-10 14:00:06 +02:00
Thomas Waldmann b7ce3b1156
make sure we do not get backslashes into item paths
on windows, we also want slashes, not backslashes.
2023-06-10 12:52:00 +02:00
Thomas Waldmann db96c0c487
subclass MakePathSafeAction from Highlander 2023-06-10 11:41:31 +02:00
Peter Gerber 438cf2e7ef
Sanitize paths during archive creation/extraction/...
Paths are not always sanitized when creating an archive and,
more importantly, never when extracting one. The following example
shows how this can be used to attempt to write a file outside the
extraction directory:

$ echo abcdef | borg create -r ~/borg/a --stdin-name x/../../../../../etc/shadow archive-1 -
$ borg list -r ~/borg/a archive-1
-rw-rw---- root   root          7 Sun, 2022-10-23 19:14:27  x/../../../../../etc/shadow
$ mkdir borg/target
$ cd borg/target
$ borg extract -r ~/borg/a archive-1
x/../../../../../etc/shadow: makedirs: [Errno 13] Permission denied: '/home/user/borg/target/x/../../../../../etc'

Note that Borg tries to extract the file to /etc/shadow and the
permission error is a result of the user not having access.

This patch ensures file names are sanitized before archiving.
As for files extracted from the archive, paths are sanitized
by making all paths relative, removing '.' elements, and removing
superfluous slashes (as in '//'). '..' elements, however, are
rejected outright. The reasoning here is that it is easy to start
a path with './' or insert a '//' by accident (e.g. via --stdin-name
or import-tar). '..', however, seem unlikely to be the result
of an accident and could indicate a tampered repository.

With paths being sanitized as they are being read, this "errors"
will be corrected during the `borg transfer` required when upgrading
to Borg 2. Hence, the sanitation, when reading the archive,
can be removed once support for reading v1 repositories is dropped.
V2 repository will not contain non-sanitized paths. Of course,
a check for absolute paths and '..' elements needs to kept in
place to detect tempered archives.

I recommend treating this as a security issue. I see the following
cases where extracting a file outside the extraction path could
constitute a security risk:

a) When extraction is done as a different user than archive
creation. The user that created the archive may be able to
get a file overwritten as a different user.
b) When the archive is created on one host and extracted on
another. The user that created the archive may be able to
get a file overwritten on another host.
c) When an archive is created and extracted after a OS reinstall.
When a host is suspected compromised, it is common to reinstall
(or set up a new machine), extract the backups and then evaluate
their integrity. A user that manipulates the archive before such
a reinstall may be able to get a file overwritten outside the
extraction path and may evade integrity checks.

Notably absent is the creation and extraction on the same host as
the same user. In such case, an adversary must be assumed to be able
to replace any file directly.

This also (partially) fixes #7099.
2023-06-07 23:23:53 +02:00
TW ac4337a921
Merge pull request #7629 from ThomasWaldmann/update-changes-master
update CHANGES
2023-06-07 18:03:37 +02:00
Thomas Waldmann 57250d0c4b
update CHANGES 2023-06-07 17:46:02 +02:00
TW 97782f3f3c
Merge pull request #7624 from ThomasWaldmann/ci-xdistn-master
CI: try 4 parallel pytest-xdist workers
2023-06-07 00:14:40 +02:00
Thomas Waldmann 7092f24f4a
CI: try 4 parallel pytest-xdist workers 2023-06-06 23:22:03 +02:00
TW cad57e70c3
Merge pull request #7615 from ThomasWaldmann/serve-socket2
implement unix domain socket support
2023-06-06 23:21:15 +02:00
Thomas Waldmann ae97584218
fix logging, add some comments
shutting down logging is problematic as it is global
and we do multi-threaded execution, e.g. in tests.

thus, rather just flush the important loggers and keep
them alive.
2023-06-06 21:13:31 +02:00
Thomas Waldmann ffc59dd071
implement unix domain (ipc) socket support
server (listening) side:
borg serve --socket  # default location
borg serve --socket=/path/to/socket

client side:
borg -r socket:///path/to/repo create ...
borg --socket=/path/to/socket -r socket:///path/to/repo ...

served connections:
- for ssh: proto: one connection
- for socket: proto: many connections (one after the other)

The socket has user and group permissions (770).

skip socket tests on win32, they hang infinitely, until
github CI terminates them after 60 minutes.

socket tests: use unique socket name

don't use the standard / default socket name, otherwise tests
running in parallel would interfere with each other by using
the same socket / the same borg serve process.

write a .pid file, clean up .pid and .sock file at exit

add stderr print for accepted/finished socket connection
2023-06-06 21:12:54 +02:00
Thomas Waldmann 7878a34fd4
add get_runtime_dir / BORG_RUNTIME_DIR, tests, docs 2023-06-06 11:58:48 +02:00