Commit graph

1958 commits

Author SHA1 Message Date
Felix Schwarz
13c6d1b710
include unistd.h in _chunker.c
With Python 3.13, Python.h no longer includes the <unistd.h> standard header file:
https://docs.python.org/3.13/whatsnew/3.13.html#id8
2023-12-01 23:58:24 +01:00
Thomas Waldmann
ec17b00411
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-16 15:59:28 +01:00
Thomas Waldmann
e006a6f368
create --*-from-command: run subcommands with a clean environment, fixes #7916
When borg invokes a system command, it needs to prepare the environment
for that. This is especially important when using a pyinstaller-made
borg fat binary that works with a modified env var LD_LIBRARY_PATH -
system commands may crash with that.

borg already had calls to prepare_subprocess_env at some places (e.g.
when invoking ssh for the remote repo connection), but they were
missing for:

borg create --content-from-command ...
borg create --paths-from-command ...
2023-11-06 17:41:52 +01:00
Thomas Waldmann
2a2b750b9d
shadow index: add more comments 2023-11-05 01:22:07 +01:00
TW
686714c366
Merge pull request #7896 from ThomasWaldmann/fix-shadow-index-1.2
fix shadow index update for double-put (1.2-maint)
2023-11-03 14:42:57 +01:00
Thomas Waldmann
a7809429b3
check --repair: recreate shadow index, see #6687
before this fix, borg check --repair just created an
empty shadow index, which can lead to incomplete
entries if entries are added later.

and such incomplete (but present) entries can lead to
compact_segments() resurrecting old PUTs by accidentally
dropping related DELs.
2023-10-29 01:12:15 +02:00
Thomas Waldmann
48feb28e11
check --repair: test if shadow index is recreated
still failing here, because it is not.
2023-10-29 01:01:17 +02:00
Thomas Waldmann
8a8837e255
shadow index updates: simplify and more comments
no functional change here.
2023-10-28 17:36:10 +02:00
Thomas Waldmann
b21ed3c658
update shadow index when doing a double-put, fixes #5661
this fixes the test added in previous commit (avoids
that the PUT reappears after index rebuild).
2023-10-28 17:17:47 +02:00
Thomas Waldmann
8e6449f28e
test the shadowing-by-double-put behaviour, see #5661
the new test is currently failing due to a bug in the
repository code.
2023-10-28 17:13:13 +02:00
TW
b83525cd4c
Merge pull request #7891 from ThomasWaldmann/sort-by-aliases-1.2
--sort-by: support "archive" as alias of "name", fixes #7873 (1.2-maint)
2023-10-27 22:27:59 +02:00
Thomas Waldmann
0e3773d8c7
--sort-by: support "archive" as alias of "name", fixes #7873 2023-10-27 20:46:03 +02:00
Thomas Waldmann
05cec8b3b0
docs: OS X -> macOS 2023-10-27 20:31:26 +02:00
Thomas Waldmann
5bfa417546
fix rc and msg if arg parsing throws an exception, fixes #7885
get_args() exception handling before this fix only dealt with
subclasses of "Error", but we have to expect other exceptions
there, too.

In any case, if we have some fatal exception here, we must
terminate with rc 2.

ArgumentTypeError: emit a short error message - usually this is
a user error, invoking borg in a wrong way.

Other exceptions: full info and traceback.
2023-10-25 12:06:27 +02:00
Thomas Waldmann
1bd015cdb5
fix invalid pattern argument error msg 2023-10-25 11:06:37 +02:00
Johannes Lade
d482251a3e
Clarify borg prune -a option description (#7871)
Clarify borg prune -a option description.

The -a option for borg prune accepts only glob pattern (i.e. sh:)
but not the actual prefix sh: which can be confusing especially for
people who don't actually know what glob pattern is.
2023-10-14 22:00:19 +02:00
Felix Schwarz
90de901ff4
replace "datetime.utcfromtimestamp" with custom helper to avoid deprecation warnings when using Python 3.12 2023-10-09 20:23:10 +02:00
Thomas Waldmann
39761ebadc
allow msgpack 1.0.7 2023-09-28 14:26:48 +02:00
TW
c9c495db0a
Merge pull request #7839 from ThomasWaldmann/traceback-for-tam-exceptions-1.2
activate tracebacks for TAM exceptions
2023-09-25 16:53:22 +02:00
Thomas Waldmann
1a24c2fa43
avoid tarfile deprecation warning for py312 2023-09-25 15:36:43 +02:00
Thomas Waldmann
93b93abc18
allow msgpack 1.0.6 2023-09-25 14:10:32 +02:00
Thomas Waldmann
6dbfbd6a19
activate tracebacks for TAM exceptions 2023-09-25 11:01:38 +02:00
Thomas Waldmann
7fd91f4bb8
check: improve logging for TAM issues, fixes #7797 2023-09-01 15:35:04 +02:00
Thomas Waldmann
d05d02f238
implement BORG_WORKAROUNDS=ignore_invalid_archive_tam, see #7791 2023-08-31 00:36:04 +02:00
Thomas Waldmann
5e0632a3d0
add tests for archive TAMs, upgrade 2023-08-30 02:52:32 +02:00
Thomas Waldmann
d78ed697ae
rebuild_refcounts: keep archive ID, if possible
rebuild_refcounts verifies and recreates the TAM.
Now it re-uses the salt, so that the archive ID does not change
just because of a new salt if the archive has still the same data.
2023-08-30 02:52:27 +02:00
Thomas Waldmann
85b173d3d1
TAM msgs: be more specific: archives vs. manifest 2023-08-30 02:52:23 +02:00
Thomas Waldmann
7d0d11b979
upgrade: allow enable/disable manifest TAM for unencrypted repos
Recent borg wrote TAM authenticated **archives**
even for unencrypted repos (encryption "none"),
so we also do that for the manifest.

It's kind of fake as there is no secret key involved then,
but it simplifies the code.
2023-08-30 02:52:21 +02:00
Thomas Waldmann
19a7809fe8
upgrade --archives-tam: make sure all archives are TAM authenticated
borg check (rebuild_manifest and rebuild_refcounts) drops archives without TAM,
so let's just always add the TAM.

for unencrypted repos (encryption=none) the TAM is insecure,
but without encryption and authentication, there is no expectation
of security anyway.
2023-08-30 02:52:17 +02:00
Thomas Waldmann
75518d945c
list: support {tam} placeholder. check archive TAM.
list: shows either "verified" or "none", depending on
whether a TAM auth tag could be verified or was
missing (old archives from borg < 1.0.9).

when loading an archive, we now try to verify the archive
TAM, but we do not require it. people might still have
old archives in their repos and we want to be able to
list such repos without fatal exceptions.
2023-08-30 02:52:15 +02:00
Thomas Waldmann
155d8ee23b
cache sync: check archive TAM 2023-08-30 02:52:13 +02:00
Thomas Waldmann
7da8738513
check: rebuild_refcounts verify and recreate TAM
This part of the archive checker recreates the Archive
items (always, just in case some missing chunks needed
repairing).

When loading the Archive item, we now verify the TAM.
When saving the (potentially modified) Archive item,
we now (re-)generate the TAM.

Archives without a valid TAM are dropped rather than TAM-authenticated
when saving them. There shouldn't be any archives without a valid TAM:

- borg writes an archive TAM since long (1.0.9)
- users are expected to TAM-authenticate archives created
  by older borg when upgrading to borg 1.2.5.

Also:

Archive.set_meta: TAM-authenticate new archive

This is also used by Archive.rename and .recreate.
2023-08-30 02:51:52 +02:00
Thomas Waldmann
1fd94bd38f
check: rebuild_manifest must verify archive TAM 2023-08-29 21:59:04 +02:00
Thomas Waldmann
de7e7e2a95
remove unused "flags_root" open flags 2023-07-29 23:42:36 +02:00
Thomas Waldmann
ed7a410084
create: do not try to read parent dir of recursion root, fixes #7746 2023-07-29 23:04:44 +02:00
Thomas Waldmann
453d35fa47
add a test for unreadable parent dir, see #7746 2023-07-29 22:48:13 +02:00
Thomas Waldmann
104cc196fc
bugfix: skip TAM check with BORG_WORKAROUNDS=authenticated_no_key
This is an emergency workaround for authenticated repos
if the user has lost the borg key.

We can't compute the TAM key without the borg key, so just
skip all the TAM stuff.
2023-07-20 18:02:58 +02:00
Daniel Rudolf
c6a6161c60
Docs: Rewrite borg check docs
This commit is a backport of the following commits to the `1.2-maint` branch:

    commit 9edbf4e931
    Author: Daniel Rudolf

        Docs: Rewrite `borg check` docs

    commit 9d59146de4
    Author: Daniel Rudolf

        Docs: Remove technical description from `borg check` docs

    commit a661da13ee
    Author: Daniel Rudolf

        Docs: Improve explanation of `borg check --max-duration`'s side effects

    commit 2647673dc8
    Author: Daniel Rudolf

        Docs: Improve `borg check` docs
2023-07-10 23:03:47 +02:00
TW
4721a35863
Merge pull request #7702 from ThomasWaldmann/authenticated-no-key-1.2
BORG_WORKAROUNDS=authenticated_no_key, fixes #7700
2023-07-07 01:02:41 +02:00
Felix Schwarz
98f547f278 add utcnow() helper function to avoid datetime.utcnow()
`datetime.utcnow()` is deprecated since Python 3.12. This causes additional lines of
output and thus breaks the test suite. I was not sure if all borg internals are
ready to deal with timezone-aware datetime instances so tried to keep the changes
minimal.
2023-07-06 21:44:09 +02:00
Thomas Waldmann
8ac7178ab9
BORG_WORKAROUNDS=authenticated_no_key to extract from authenticated repos without key, fixes #7700 2023-07-03 15:38:21 +02:00
TW
98cea7516b
Merge pull request #7691 from ThomasWaldmann/macfuse-volname-1.2
mount: make up volname if not given (macOS), fixes #7690
2023-07-01 14:41:14 +02:00
Thomas Waldmann
f5f5311e2b
extract: fix false warning about pattern never matching, fixes #4110 2023-07-01 02:05:58 +02:00
Thomas Waldmann
7c82969761
mount: make up volname if not given (macOS), fixes #7690
macFUSE supports a volname mount option to give what
finder displays on desktop / in directory list.

if the user did not specify it, we make something up,
because otherwise it would be "macFUSE Volume 0 (Python)".
2023-06-30 22:10:32 +02:00
Thomas Waldmann
c587e88830
diff: remove surrogates before output, fixes #7535 2023-06-30 17:10:56 +02:00
Thomas Waldmann
fbf287f825
RepositoryTestCaseBase: remove need for "with" after reopen()
setUp enters the context manager, so let's .reopen() leave it.
then create a fresh Repository instance in self.repository and
enter the context manager again. tearDown then will leave that.
2023-06-27 22:43:00 +02:00
Thomas Waldmann
0ac07b7a3f
RepositoryTestCaseBase: call __exit__
As we call __enter__ in setUp,
let's call __exit__ in tearDown.
2023-06-27 22:34:11 +02:00
Thomas Waldmann
83b2b5cb6c
fix RepositoryTestCaseBase.reopen method
"if self.repository" did not work as expected:
- Repository has a __len__ method, so the boolean evaluation was calling that.
- self.repository is also not set to None anywhere.
2023-06-27 22:33:57 +02:00
TW
0947e9fb22
Merge pull request #7680 from ThomasWaldmann/improve-key-sanity-check-1.2
keyfile: improve key sanity check, fixes #7561
2023-06-27 22:32:30 +02:00
TW
edc9a0843a
Merge pull request #7682 from ThomasWaldmann/test-cosmetics-1.2
tests: avoid long ids in pytest output
2023-06-27 22:30:16 +02:00