Commit Graph

987 Commits

Author SHA1 Message Date
Thomas Waldmann 54a85bf56d
format_timedelta: use 3 decimal digits (ms)
maybe this fixes the frequently failing test.
also, giving ms makes more sense than 10ms granularity.
2024-04-04 12:45:28 +02:00
Thomas Waldmann 7df170c946
FreeBSD: added tests, only get default ACL from dirs 2024-04-02 01:38:27 +02:00
Thomas Waldmann bafea3b5de
platform tests: misc. minor cleanups
- remove unused global / import
- use is_linux and is_darwin
- rename darwin acl test method
2024-04-02 01:38:17 +02:00
Thomas Waldmann d5396feebd
improve are_acls_working function
- ACLs are not working, if ENOTSUP ("Operation not supported") happens
- fix check for macOS
  On macOS borg uses "acl_extended", not "acl_access" and
  also the ACL text format is a bit different.
2024-04-02 01:38:15 +02:00
Thomas Waldmann e7bd18d7f3
create: add the slashdot hack, fixes #4685 2024-02-20 04:08:09 +01:00
Thomas Waldmann 334fbab897
refactor: use less binascii
our own hex_to_bin / bin_to_hex is more comfortable to use.

also: optimize remaining binascii usage / imports.
2024-02-19 02:16:19 +01:00
kmille 1f5cc355a3
borg with-lock: catch exception, print error msg, fixes #8022 2024-02-18 13:36:10 +01:00
Thomas Waldmann b53c86cf4c
refactor (re-)init of exit_code and warnings_list globals
stop directly accessing the variables from other modules.

prefix with underscore to indicate that these shall
only be used within this module and every other user
shall call the respective functions.
2024-02-17 22:29:18 +01:00
Thomas Waldmann abe6545853
do not return the rc from Archiver methods
this is not needed and getting rid of it makes
the code / behaviour simpler to understand:

if a fatal error is detected, we throw an exception.

if we encounter something warning worthy, we emit and collect the warning.

in a few cases, we directly call set_ec to set the
exit code as needed, e.g. if passing it through
from a subprocess.

also:
- get rid of Archiver.exit_code
- assert that return value of archiver methods is None
- fix a print_warning call to use the correct formatting method
2024-02-17 22:07:47 +01:00
Thomas Waldmann c704e5ea9e
new warnings infrastructure to support modern exit codes
- implement updating exit code based on severity, including modern codes
- extend print_warning with kwargs wc (warning code) and wt (warning type)
- update a global warnings_list with warning_info elements
- create a class hierarchy below BorgWarning class similar to Error class
- diff: change harmless warnings about speed to rc == 0
- delete --force --force: change harmless warnings to rc == 0

Also:

- have BackupRaceConditionError as a more precise subclass of BackupError
2024-02-14 01:26:12 +01:00
Thomas Waldmann bec02a36c8
use print_warning also in borg delete ::archive --force --force 2024-02-13 23:13:25 +01:00
Thomas Waldmann 9de07ebd46
update "modern" error RCs (docs and code) 2024-02-13 22:58:02 +01:00
TW 812eb352f6
Merge pull request #7955 from ThomasWaldmann/improve-session-key-gen-master
crypto: use a one-step kdf for session keys, fixes #7953
2024-01-04 18:42:22 +01:00
Thomas Waldmann e1fbd7d42e
fix mypy complaints 2024-01-02 20:57:42 +01:00
Thomas Waldmann 6720ab3aab
move conftest.py to src/borg/testsuite, see #6386
there, it will be packaged and installed, so
that when one runs the testsuite after installing
the pypi package, it will find the conftest.py.
2024-01-02 20:39:14 +01:00
Thomas Waldmann a4602c6f61
remove unused hkdf_hmac_sha512 and related tests 2023-12-02 20:35:14 +01:00
Thomas Waldmann 046f9fe392
LockRoster.modify: no KeyError if element was already gone, fixes #7937
The intention of LockRoster.modify(key, REMOVE) is to remove self.id.

Using set.discard will just ignore it if self.id is not present there anymore.

Previously, using set.remove triggered a KeyError that has been frequently
seen in tracebacks of teardowns involving Repository.__del__ and Repository.__exit__.

I added a REMOVE2 op to serve one caller that needs to get the KeyError if
self.id was not present.

Thanks to @herrmanntom for the workaround!
2023-11-18 17:39:30 +01:00
Thomas Waldmann 7892e4212b
check --repair: test if shadow index is recreated
still failing here, because it is not.
2023-11-05 18:41:31 +01:00
Thomas Waldmann 3b1c0df7c8
test the shadowing-by-double-put behaviour, see #5661
the new test is currently failing due to a bug in the
repository code.
2023-11-05 18:22:57 +01:00
Thomas Waldmann f0e9999768
zlib legacy decompress: fix tests 2023-10-24 23:33:42 +02:00
Thomas Waldmann d1fde11645
tests: borg check must not add a spoofed archive to manifest
also: do a small optimisation in borg check:

if the type of the repo object is not ROBJ_ARCHIVE_META, we
can skip the object, it can not contain valid archive meta data.

if the type is correct, this is already a sufficient check, so
we can be quite sure that there will be valid archive metadata
in the object.
2023-09-24 20:10:58 +02:00
Thomas Waldmann 6b4697b479
tests: borg check notices/repairs a spoofed manifest 2023-09-24 20:10:57 +02:00
Thomas Waldmann 170380c657
raise IntegrityError if ro_type is not as expected 2023-09-24 20:10:56 +02:00
Thomas Waldmann 1cf62d8fc7
remove manifest TAMs 2023-09-24 20:10:53 +02:00
Thomas Waldmann 6a68ad5cd6
remove archive TAMs 2023-09-24 20:10:51 +02:00
Thomas Waldmann 1b6f928917
ro_type: typed repo objects, see #7670
writing: put type into repoobj metadata
reading: check wanted type against type we got

repoobj metadata is encrypted and authenticated.
repoobj data is encrypted and authenticated, also (separately).
encryption and decryption of both metadata and data get the
same "chunk ID" as AAD, so both are "bound" to that (same) ID.

a repo-side attacker can neither see cleartext metadata/data,
nor successfully tamper with it (AEAD decryption would fail).

also, a repo-side attacker could not replace a repoobj A with a
differently typed repoobj B without borg noticing:
- the metadata/data is cryptographically bound to its ID.
  authentication/decryption would fail on mismatch.
- the type check would fail.

thus, the problem (see CVEs in changelog) solved in borg 1 by the
manifest and archive TAMs is now already solved by the type check.
2023-09-24 20:10:50 +02:00
Thomas Waldmann 0fcd3e9479
add_chunk: remove overwrite parameter 2023-09-23 00:10:35 +02:00
Thomas Waldmann 15c24cbe7e
recreate: remove --recompress option
For many use cases, the repo-wide "rcompress" is more efficient.

Also, recreate --recompress calls add_chunk with overwrite=True,
which is unsupported with the AdHocCache.
2023-09-23 00:01:39 +02:00
Thomas Waldmann 2195558eea
fix post-test permission issues 2023-09-20 22:45:57 +02:00
Thomas Waldmann 12e224613e
test_is_slow_msgpack: skip test on expected slow msgpack environments 2023-09-14 14:47:30 +02:00
Thomas Waldmann a0f5264cbd
rlist: remove support for {tam} placeholder
archives are now always TAM-authenticated.
2023-09-03 22:27:24 +02:00
Thomas Waldmann 2d78fa89a5
always implicitly require archive TAMs
they must be there since the upgrade to borg 1.2.6 (or other
borg versions that also have a fix for CVE-2023-36811).
2023-09-03 22:02:35 +02:00
Thomas Waldmann 21d4407170
always implicitly require manifest TAMs
remove a lot of complexity from the code that was just there to
support legacy borg versions < 1.0.9 which did not TAM authenticate
the manifest.

since then, borg writes TAM authentication to the manifest,
even if the repo is unencrypted.
if the repo is unencrypted, it did not check the somehow pointless
authentication that was generated without any secret, but
if we add that fake TAM, we can also verify the fake TAM.

if somebody explicitly switches off all crypto, they can not
expect authentication.

for everybody else, borg now always generates the TAM and also
verifies it.
2023-09-03 22:01:46 +02:00
Thomas Waldmann 56da398711
add tests for archive TAMs 2023-08-30 02:28:57 +02:00
Thomas Waldmann a2ee13fd34
check: rebuild_manifest must verify archive TAM 2023-08-29 21:10:32 +02:00
Thomas Waldmann aa5168a21e
use skipif_acls_not_working decorator for freebsd also
use platform-specific ACLs to check.
for unsupported platform, just return False.
2023-08-27 05:07:56 +02:00
Thomas Waldmann 9c1088c95c
linux: move ACL definitions to platform_linux test module
they are only used from there.
2023-08-27 05:06:17 +02:00
Thomas Waldmann 7f8eba4fbf
freebsd: add some ACL tests, fixes #7745
enable ACL support in freebsd vagrant machine's filesystem
2023-08-27 05:05:55 +02:00
Thomas Waldmann 836b517451
get_*_dir tests: use create=False
In these tests, we only compare paths, but we do not
need to create these paths for that. By not trying to
create them, we can avoid permission issues, e.g. under
fakeroot.
2023-08-27 03:23:50 +02:00
TW 1c8da8f98a
Merge pull request #7750 from ThomasWaldmann/fix-unreadable-parent-of-root-master
do not try to read parent dir of recursion root (master)
2023-07-30 01:18:27 +02:00
Ted Lawson f29fd80311
`platform_freebsd.py` dummy test file (#7748) 2023-07-30 01:17:56 +02:00
Thomas Waldmann 3e640a38c0
add a test for unreadable parent dir, see #7746 2023-07-29 23:21:10 +02:00
bigtedde a09c8ad940 reverted import grouping 2023-07-29 09:40:24 -07:00
bigtedde dc83735e1d Merge remote-tracking branch 'upstream/master' into remove-BaseTestCase 2023-07-28 12:31:24 -07:00
bigtedde ffebd8b044 parametrize helper.py 2023-07-28 12:30:27 -07:00
bigtedde 8eed958829 seperated platform tests into seperate modules 2023-07-27 15:38:21 -07:00
bigtedde be53037b9d linux tests converted, renamed tests for consistency 2023-07-27 11:45:58 -07:00
bigtedde d2dd792164 mac and posix tests converted, removed BaseTestCase and unittest 2023-07-26 21:59:12 -07:00
bigtedde 7b753453e5 removed BaseTestCase from chunker_slow.py 2023-07-26 14:59:45 -07:00
bigtedde 67334c4e83 removed BaseTestCase from helpers.py 2023-07-26 14:50:52 -07:00