Commit Graph

86 Commits

Author SHA1 Message Date
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 3017701958
simplify flake8 configuration
we use black since a while, so some stuff does not need to be ignored any more.
2023-07-25 23:56:31 +02:00
Thomas Waldmann bd9af62c07
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-07-01 15:35:03 +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 63e17d6da2
borgfs.statfs: add comments 2023-04-02 16:56:28 +02:00
Thomas Waldmann b92f4aa487
remove --consider-part-files, related stats code, update docs
we now just treat that one .borg_part file we might have inside
checkpoint archives as a normal file.

people can recognize via the file name it is a partial file.

nobody cares for statistics of checkpoint files and the final
archive now does not contain any partial files any more, thus
no needs to maintain statistics about count and size of part
files.
2023-02-01 13:04:18 +01:00
Thomas Waldmann 1672aee031
Item: symlinks: rename .source to .target, fixes #7245
Also, in JSON:
- rename "linktarget" to "target" for symlinks
- remove "source" for symlinks
2023-01-16 20:28:25 +01:00
Thomas Waldmann fa986a9f19 repoobj: add a layer to format/parse repo objects
borg < 2:

obj = encrypted(compressed(data))

borg 2:

obj = enc_meta_len32 + encrypted(msgpacked(meta)) + encrypted(compressed(data))

handle compr / decompr in repoobj

move the assert_id call from decrypt to RepoObj.parse

also:
- for AEADKeyBase, add a dummy assert_id (not needed here)
- only test assert_id for other if not AEADKeyBase instance
- remove test_getting_wrong_chunk. assert_id is called elsewhere
  and is not needed any more anyway with the new AEAD crypto.
- only give manifest (includes key, repo, repo_objs)
- only return manifest from Manifest.load (includes key, repo, repo_objs)
2022-09-04 00:49:38 +02:00
Thomas Waldmann 66e74e0471 archiver modules: rename to *_cmd[s]
this was already required for list_cmd (due to "list"
being a builtin), now renamed all else also.
2022-08-13 22:59:48 +02:00
Thomas Waldmann 578639b35e move lrucache module to borg.helpers 2022-08-13 22:02:04 +02:00
Thomas Waldmann b8e48c5036 mypy: fixes / annotations 2022-07-15 14:54:48 +02:00
Thomas Waldmann e05f7971da move build_filter/build_matcher to archiver.common 2022-07-09 15:13:13 +02:00
Thomas Waldmann 7957af562d blacken all the code
https://black.readthedocs.io/
2022-07-06 16:34:38 +02:00
Thomas Waldmann 6addafd784 borg mount -a ARCHIVE_GLOB mountpoint ... 2022-06-21 23:05:44 +02:00
Thomas Waldmann 281bbbc16b fix tests and benchmarks 2022-06-16 14:18:39 +02:00
Thomas Waldmann ace5957524 remove csize from item.chunks elements 2022-06-12 15:48:33 +02:00
Thomas Waldmann 6bfdb3f630 refactor hardlink_master processing globally
borg now has the chunks list in every item with content.
due to the symmetric way how borg now deals with hardlinks using
item.hlid, processing gets much simpler.

but some places where borg deals with other "sources" of hardlinks
still need to do some hardlink management:
borg uses the HardLinkManager there now (which is not much more
than a dict, but keeps documentation at one place and avoids some
code duplication we had before).

item.hlid is computed via hardlink_id function.

support hardlinked symlinks, fixes #2379
as we use item.hlid now to group hardlinks together,
there is no conflict with the item.source usage for
symlink targets any more.

2nd+ hardlinks now add to the files count as did the 1st one.
for borg, now all hardlinks are created equal.
so any hardlink item with chunks now adds to the "file" count.

ItemFormatter: support {hlid} instead of {source} for hardlinks
2022-05-18 14:20:01 +02:00
Thomas Waldmann 2bed467e92 mount -o versions: give clear error msg instead of crashing
it does not make sense to request versions view if you only
look at 1 archive, but the code shall not crash in that case
as it did, but give a clear error msg.
2022-05-15 00:37:45 +02:00
Thomas Waldmann cbeef56454 pyupgrade --py38-plus ./**/*.py 2022-02-27 20:11:56 +01:00
Thomas Waldmann 6f9b9e5a53 s/numeric_owner/numeric_ids/g 2021-04-16 15:02:16 +02:00
Thomas Waldmann bbccdbd81c mount: implement --numeric-owner (default: False!), fixes #2377
this is different default behaviour than in borg < 1.2:

default (numeric_owner=False) is to use the user/group name from the archive,
look up the local uid / gid and then use that for the FUSE fs.

when --numeric-owner is given (numeric_owner=True), then the uid/gid
from the archive is directly used (as it was the default behaviour in
borg < 1.2).

this was implemented like this (changing the default behaviour) to make
borg mount and borg extract behave more similar considering usage of
user/group numeric archived ids or archived names mapped to corresponding
numeric local system ids.

also, both now use the same function to get the uid/gid from the item.

fuse:
- add user and group name entries to default_dir
- also: set internal_dict(!) of new Item with data from Item.as_dict()
2021-03-07 18:16:23 +01:00
Thomas Waldmann 49b1421682 FUSE: support pyfuse3 additionally to llfuse, fixes #5407
FUSE implementation can be switched via env var BORG_FUSE_IMPL.
2020-10-31 22:04:44 +01:00
Thomas Portmann ef9fdcf992 fix race condition in lock migration, fixes #4953
- add a daemonizing() ctx manager

The foreground borg mount process (local repo) survives until the lock
migration (performed by the background) is finished, so the lock to be
migrated is never stale, and the race condition is gone.

- add a test case revealing that locking is not safe during daemonization (borg mount)

- amend printing in testsuite.archiver
2020-07-09 21:31:13 +02:00
Thomas Waldmann 0ab987d5a9 fuse: set f_namemax in statfs result, fixes #2684
setting it to 255 for now (as seen on Linux / ext4),
better than the default 0.

the attribute is present since llfuse 1.3.0, which is
the minimum requirement currently anyway.
2020-04-12 21:05:38 +02:00
Thomas Waldmann cdb6334be4 fuse: remove more unneeded compat code
st_xtime_ns is there since long.
2020-04-12 17:55:24 +02:00
Thomas Waldmann 33519263ac fuse: remove unneeded version check and compat code
we require >= 1.3 now anyway, see setup.py.
2020-04-12 17:55:24 +02:00
Thomas Waldmann 392bc3e3b1 fuse: hot-spot micro-opt for versions view
this way it does not create/discard tons of lists
2020-04-12 00:22:07 +02:00
lexa-a cf8dac55de
Fix FUSE low linear read speed on large files (#5032)
Fix FUSE low linear read speed on large files

This patch is a quick fix for an inefficient seek algorithm used in read() function:
1) On each read call chunk list for given file is regenerated. 
2) Finding needed chunk takes a lot of time for large offsets.  

For 64 Gb files read speed drops to 16 MB/s, for 128 Gb - to 8 MB/s, and so on.

After applying this patch read speed becomes 270 MB/s, and does not depend on read position inside file.

Co-authored-by: Thomas Waldmann <tw@waldmann-edv.de>
2020-04-04 15:36:35 +02:00
Julien Lamy cfa76e066b Add missing attribute to FUSE entries 2019-09-22 17:12:01 +02:00
Thomas Waldmann 672c2c99a7 security fix: configure FUSE with "default_permissions", fixes #3903
"default_permissions" is now enforced by borg by default to let the
kernel check uid/gid/mode based permissions.

"ignore_permissions" can be given to not enforce "default_permissions".

note: man mount.fuse explicitly tells about the security issue:

    default_permissions
	By  default FUSE doesn't check file access permissions, ...
	This option enables permission checking, restricting access
	based on file mode.
	This option is usually useful together with the allow_other
	mount option.

We consider this a pitfall waiting for someone to fall into and this is
why we chose to change the default behaviour for borg.
2019-02-11 13:01:24 +01:00
Thomas Waldmann 3c173cc03b wrap msgpack, fixes #3632, fixes #2738
wrap msgpack to avoid future upstream api changes making troubles
or that we would have to globally spoil our code with extra params.

make sure the packing is always with use_bin_type=False,
thus generating "old" msgpack format (as borg always did) from
bytes objects.

make sure the unpacking is always with raw=True,
thus generating bytes objects.

note:

safe unicode encoding/decoding for some kinds of data types is done in Item
class (see item.pyx), so it is enough if we care for bytes objects on the
msgpack level.

also wrap exception handling, so borg code can catch msgpack specific
exceptions even if the upstream msgpack code raises way too generic
exceptions typed Exception, TypeError or ValueError.
We use own Exception classes for this, upstream classes are deprecated
2018-08-06 17:32:55 +02:00
Thomas Waldmann a497fe07ab use unpacker.tell() instead of deprecated write_bytes, fixes #3899 2018-06-24 00:14:53 +02:00
Thomas Waldmann cd70192bea borg mount: support umask= mount option
(cherry picked from commit eb61c2153b)
2018-05-18 21:56:37 +02:00
Thomas Waldmann c7d12e3fc0 borg mount: support uid= and gid= mount options
also: refactor popping an option, converting an options value
(cherry picked from commit f993f0fd49)
2018-05-18 21:43:10 +02:00
Thomas Waldmann 5cf48eeb16 borg mount: fix hardlink processing, fixes #3388
when the result list after stripping was empty,
os.path.join(*emptylist) fails as it want 1+ args.

(cherry picked from commit dc8de36109)
2017-12-02 18:13:11 +01:00
Thomas Waldmann caece370b8 borg mount: support --consider-part-files correctly, fixes #3347 2017-11-22 15:08:08 +01:00
Thomas Waldmann e97deafb16 borg mount: support hardlinks correctly, add tests
previous commit did not yet support hardlinks correctly, if the
hardlink master was excluded somehow.

added some tests for this, also refactored related tests slightly.
2017-11-21 15:39:47 +01:00
Thomas Waldmann 77df1cfe8c borg mount: support exclusion group options and paths, fixes #2138
borg mount [options] repo_or_archive mountpoint path [paths...]

paths: you can just give some "root paths" (like for borg extract) to
only partially populate the FUSE filesystem.

Similar for these exclusion group options:
--exclude
--exclude-from
--pattern
--patterns-from
--strip-components
2017-11-21 15:38:09 +01:00
Simon Frei b148a366fe fuse: Separate creation of filesystem from implementation of llfuse funcs (#3042)
fuse: Separate creation of filesystem from implementation of llfuse funcs
2017-11-01 03:02:25 +01:00
Thomas Waldmann 6f94949a36 migrate locks to child PID when daemonize is used
also:

increase platform api version due to change in get_process_id behaviour.
2017-08-08 03:46:44 +02:00
Milkey Mouse 6ef5c9c960
Use archive creation time as mtime for FUSE mount (fixes #2834) 2017-07-18 15:07:59 -07:00
Marian Beermann 9a856533ba fuse: versions view, linear numbering by archive time 2017-07-03 12:38:10 +02:00
Thomas Waldmann 51458b6b58 FUSE versions view: keep original file extension at end, fixes #2769
some tools depend on seeing the correct file extension to operate
correctly, so put our version to the left of the file extension.
2017-07-02 19:11:24 +02:00
Thomas Waldmann 7ebad4f803 FUSE vs. fuse 2017-06-24 01:24:14 +02:00
Marian Beermann 2766693706 fuse: update comments 2017-06-15 23:50:17 +02:00
Marian Beermann 3b928a4558 fuse: refactor ItemCache 2017-06-14 13:58:09 +02:00
Marian Beermann 9fd79a9e56 fuse: decrypted cache 2017-06-14 13:35:07 +02:00
Marian Beermann f04119c246 fuse: ItemCache on top of object cache 2017-06-14 13:35:07 +02:00
Marian Beermann ec532304d2 fuse: remove unnecessary normpaths 2017-06-14 13:34:34 +02:00
enkore 8e477414ee Merge pull request #2675 from enkore/f/fusecache
fuse: instrumentation
2017-06-14 09:31:55 +02:00