Commit graph

1742 commits

Author SHA1 Message Date
Björn Ketelaars
71fa056c47 1.2 - Remove unused code
#6473 Removed AEAD ciphers AES-OCB and CHACHA20-POLY1305 from 1.2. As a
result some additional code can be removed.

Passes regression tests.
2022-03-21 18:54:50 +01:00
Thomas Waldmann
aa57a3cb57 remove AEAD ciphers AES-OCB and CHACHA20-POLY1305, fixes #6472
not used in 1.2.x, we'll start using them in 1.3.
2022-03-20 23:05:30 +01:00
Andrey Bienkowski
a58fd3db5c 1.2: Make switch fallthrough explicit 2022-03-10 08:24:23 +03:00
TW
f698c12129
Merge pull request #6403 from ThomasWaldmann/fix-savefile-mode-1.2
respect umask for files / dirs (1.2)
2022-03-09 16:53:35 +01:00
braewoods
8b4c501d8d
[1.2-maint] Backport implicit warning patches from master (#6427)
* suppress -Wimplicit-fallthrough warning

These instances of implicit switch case fallthrough appear to be
intentional. Add comments that the compiler understands to suppress
the false positive warning.
2022-03-09 16:10:21 +01:00
Thomas Waldmann
dc811bda6f fix "'HMAC_CTX' already defined" cython warning 2022-03-08 21:47:14 +01:00
Thomas Waldmann
cd629d32cb fix "useless trailing comma" cython warnings 2022-03-08 21:27:20 +01:00
Andrey Bienkowski
f05036cbcb ‘PyUnicode_AsUnicode’ is deprecated
Fix compilation warnings:
```
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/opt/hostedtoolcache/Python/3.9.10/x64/include/python3.9 -c src/borg/platform/posix.c -o build/temp.linux-x86_64-3.9/src/borg/platform/posix.o
src/borg/platform/posix.c: In function ‘__pyx_pf_4borg_8platform_5posix_2swidth’:
src/borg/platform/posix.c:1572:3: warning: ‘PyUnicode_AsUnicode’ is deprecated [-Wdeprecated-declarations]
 1572 |   __pyx_t_2 = __Pyx_PyUnicode_AsUnicode(__pyx_v_s); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 19, __pyx_L1_error)
      |   ^~~~~~~~~
In file included from /opt/hostedtoolcache/Python/3.9.10/x64/include/python3.9/unicodeobject.h:1026,
                 from /opt/hostedtoolcache/Python/3.9.10/x64/include/python3.9/Python.h:93,
                 from src/borg/platform/posix.c:19:
/opt/hostedtoolcache/Python/3.9.10/x64/include/python3.9/cpython/unicodeobject.h:580:45: note: declared here
  580 | Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode(
      |                                             ^~~~~~~~~~~~~~~~~~~
```

Ref: https://docs.python.org/3/c-api/unicode.html#c.PyUnicode_AsUnicode
2022-03-07 21:40:39 +03:00
Thomas Waldmann
ce72a87f2d fixup: fix SELFTEST_COUNT 2022-03-06 11:31:05 +03:00
Thomas Waldmann
65ccbc2c69 fixup: remove now unused import 2022-03-06 11:31:05 +03:00
Thomas Waldmann
45ef108d46 remove our blake2b_128/256 tests
as we're just calling python stdlib there,
we can assume that they have tests for it.

 Conflicts:
	src/borg/testsuite/crypto.py
2022-03-06 11:30:58 +03:00
Thomas Waldmann
c2211a7ef9 remove our hmac_sha256 tests
as we're just calling python stdlib there,
we can assume that they have tests for it.

 Conflicts:
	src/borg/testsuite/crypto.py
2022-03-06 11:28:27 +03:00
Thomas Waldmann
72ccafb4b8 hmac.digest: some more minor optimizations
also some cosmetic changes:
- import hmac module
- use hmac.compare_digest
2022-03-06 11:26:04 +03:00
Thomas Waldmann
bcd1d49d3b hmac_sha256: replace own cython wrapper code by hmac.digest python stdlib (since py38)
i measured performance of both: pretty much the same.
2022-03-06 11:26:04 +03:00
TW
d0fb234f46
Merge pull request #6404 from ThomasWaldmann/import-tar-fixes-1.2
import-tar fixes
2022-03-05 14:26:59 +01:00
TW
8abb0aa7ab
Merge pull request #6375 from ThomasWaldmann/fix-6374-1.2
create: skip with warning if opening the parent dir of recursion root fails, fixes #6374
2022-03-05 14:18:40 +01:00
Thomas Waldmann
7dc800fecd kill filter process in case of borg exceptions, fixes #6401
in the finally-block, we wait for the filter process to die. but it only dies
voluntarily if all data was processed by the filter and it terminates due to EOF.

otoh, if borg has thrown an early exception, e.g. "archive already exists",
we need to kill the filter process to bring it to an early end. in that
case, we also do not need to check the filter rc, because we know we killed it.
2022-03-04 23:33:53 +01:00
Thomas Waldmann
33192e5e5d import-tar: fix mtime type bug
looks like with a .tar file created by the tar tool,
tarinfo.mtime is a float [s]. So, after converting to
nanoseconds, we need to cast to int because that's what
Item.mtime wants.

also added a safe_ns() there to clip values to the safe range.
2022-03-04 23:33:53 +01:00
Thomas Waldmann
f5a47d86e3 ensure_dir: respect umask for created directory modes, fixes #6400
we tried to be very private / secure here, but that created the issue
that a less secure umask (like e.g. 0o007) just did not work.

to make the umask work, we must start from 0o777 mode and let the
umask do its work, like e.g. 0o777 & ~0o007 --> 0o770.

with borg's default umask of 0o077, it usually ends up being 0o700,
so only permissions for the user (not group, not others).
2022-03-04 21:24:42 +01:00
Thomas Waldmann
9ea1d2a7d6 SaveFile: respect umask for final file mode, fixes #6400 2022-03-04 20:53:10 +01:00
Thomas Waldmann
8edb1dc085 manual formatting fixes (cosmetic / pep8) 2022-02-27 21:13:04 +01:00
Thomas Waldmann
c4ed840c7b pyupgrade --py38-plus ./**/*.py 2022-02-27 21:12:44 +01:00
TW
97de7e1fe2
Merge pull request #6380 from ThomasWaldmann/fix-zstd-include-1.2
fix zstd.h include for bundled zstd, fixes #6369
2022-02-27 14:39:09 +01:00
Thomas Waldmann
9390d2712b fix zstd.h include for bundled zstd, fixes #6369 2022-02-27 14:35:19 +01:00
Thomas Waldmann
da0ddacc54 create: skip with warning if opening the parent dir of recursion root fails, fixes #6374 2022-02-27 02:40:15 +01:00
James Buren
1618c98975 src/borg/cache_sync/unpack.h: fix compiler warnings
The key argument being sent to hashindex_get and hashindex_set by
multiple functions is a different signedness from what the functions
expect. This resolves the issue by changing the key type in the
unpack_user struct to unsigned char.
2022-02-26 16:13:07 -06:00
James Buren
4427c16d31 src/borg/_hashindex.c: fix compiler warnings
The value argument of hashindex_set is causing harmless pointer type
mismatches. This resolves the issue by changing the type to void*
which silences these types of warnings.
2022-02-26 16:13:02 -06:00
James Buren
8e640ae0f3 src/borg/compress.pyx: fix compiler warning, closes #6365
This resolves a compiler warning from the generated code that
resulted from a comparison of two local variables of different
signedness. The issue is resolved by changing the type of both
to int since this seems like the safest choice available.
2022-02-26 13:20:39 -06:00
James Buren
067dd10027 src/borg/crypto/low_level.pyx: fix compiler warning
The generated source code was producing a compiler warning due to
the pointers differing in constness. The called function expects
a non-const pointer while the generated code produces a const pointer
via a cast. This changes the cast to drop 'const' to make the compiler
happy.
2022-02-25 17:36:48 -06:00
TW
8a409ec1fb
Merge pull request #6306 from ThomasWaldmann/fix-savefile-races-master
SaveFile: fix race conditions
2022-02-17 16:51:43 +01:00
Laurent
6015ded828
docs: explain the difference between a path that ends with or without a slash (#6297)
docs: explain the difference between a path that ends with or without a slash
2022-02-16 23:53:11 +01:00
Thomas Waldmann
14b5c005d8 SaveFile: fix race conditions
Thanks to Andrey Bienkowski (@hexagonrecursion) for reporting this and writing reproducer code.

Changes:
- use different, randomly (but recognizably) named temp files while writing (securely made by os.mkstemp())
- make sure temp files are cleaned up in normal and error conditions
- SyncFile can now get corresponding pair of path + open os-level fd
- cleaned up: fd now means os-level fd, f means python-file-like object
- fixed a caller of SaveFile
2022-02-16 23:23:47 +01:00
Thomas Waldmann
b292e158a6 rename truncate_and_unlink to safe_unlink
it usually does not truncate any more,
only under "disk full" circumstances and only if there is only one hardlink.
2022-02-15 21:08:34 +01:00
Thomas Waldmann
4a2ab496e0 safer truncate_and_unlink implementation
the previous implementation caused collateral damage on hardlink-copies of a repository,
see: https://github.com/borgbackup/borg/discussions/6286
2022-02-15 12:58:37 +01:00
TW
4896fe1560
Merge pull request #6296 from ThomasWaldmann/cache-pre12-archive-meta
info: use a pre12-meta cache to accelerate stats for borg < 1.2 archives
2022-02-14 18:29:17 +01:00
Thomas Waldmann
a2fb9cde4e calc_stats progress display: add archive name 2022-02-14 18:00:02 +01:00
Thomas Waldmann
25e27a1539 info: use a pre12-meta cache to accelerate stats for borg < 1.2 archives
first time borg info is invoked on a borg 1.1 repo, it can take
a rather long time computing and caching some stats values for
1.1 archives, which borg 1.2 archives have in their archive
metadata structure. be patient, esp. if you have lots of old
archives.

following invocations are much faster.
2022-02-14 18:00:02 +01:00
Tomás Andrighetti
a2ae36bb54 Exclude directories in is_hardlink_master 2022-02-13 19:23:40 -03:00
TW
0cebe62264
Merge pull request #6290 from ThomasWaldmann/compact-free-space-master
compact segments: improve freeable / freed space log output
2022-02-13 18:25:01 +01:00
Thomas Waldmann
603b58f6a1 implement more standard hashindex.setdefault behaviour
the .get() like behaviour (== returning the value) was missing.

it's still not 100% like dict.setdefault, because there is no
default value None. but None doesn't make sense here, because we
usually need a N-tuple matching the hash table's value format.

note: this "bug" (or unusual implementation) was without consequences,
      because hashindex.setdefault is not used anywhere in borg, so
      it was also not used in a wrong way anywhere.

https://docs.python.org/3/library/stdtypes.html#dict.setdefault
2022-02-13 03:47:44 +01:00
Thomas Waldmann
17e8aef394 compact: not "freeable", but "maybe freeable"
e.g. if there is a ton of DELs in a segment, they all are maybe freeable,
but only if we also got rid of the respective PUTs (see also #6289).
2022-02-12 20:37:28 +01:00
Thomas Waldmann
e80b5c2272 compact: derive freed space from quota use before/after, fixes #5679
due to the way quota accounting is done, this is likely not
100% precise, but much better than selling the hints as the truth.
2022-02-12 20:37:18 +01:00
TW
c56b15f271
Merge branch 'master' into docs-links-master 2022-02-08 21:57:58 +01:00
Andrey Bienkowski
24e8b38f1a
Doc: borg init: explain the encryption modes better (#6184)
docs:borg init: explain the encryption modes better

The documentation for borg init was not structured logically:
1. The topic is switched from the general discussion of `borg init`
   to the discussion of encryption modes without a title.
2. Obscure technical details (chunking, id generation etc) were
   above the high-level overview and other key information.
2022-02-08 21:55:51 +01:00
Thomas Waldmann
3428b9f2b4 docs: link to python 3.8 docs
because py38 is our minimum requirement.
2022-02-07 23:23:15 +01:00
Thomas Waldmann
510ceb86f8 docs: link to borg_placeholders 2022-02-07 22:36:24 +01:00
Thomas Waldmann
d79b325494 docs: link to borg_patterns 2022-02-07 22:33:28 +01:00
Thomas Waldmann
42fb25d4a7 docs: use same phrasing in misc. help texts 2022-02-07 21:40:15 +01:00
bobthebadguy
45df345d29
Clarify usage of patternfile roots (#6242) 2022-02-07 20:53:25 +01:00
Thomas Waldmann
f0809cfeba docs: rst markup: remove accidental indentation in patterns help 2022-02-06 00:47:33 +01:00