Skip to content

Commit 67061b0

Browse files
Merge pull request #9591 from borgbackup/backport-9590-to-master
[Backport master] mount: improve error msg when uid/gid cannot be resolved, fixes #9574
2 parents fe0be41 + f48905b commit 67061b0

2 files changed

Lines changed: 22 additions & 6 deletions

File tree

src/borg/fuse.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def async_wrapper(fn):
6262
from .archiver._common import build_matcher, build_filter
6363
from .archive import Archive, get_item_uid_gid
6464
from .hashindex import FuseVersionsIndex
65-
from .helpers import daemonize, daemonizing, signal_handler, format_file_size, bin_to_hex
65+
from .helpers import daemonize, daemonizing, signal_handler, format_file_size, bin_to_hex, Error
6666
from .helpers import HardLinkManager
6767
from .helpers import msgpack
6868
from .helpers.lrucache import LRUCache
@@ -574,8 +574,16 @@ def pop_option(options, key, present, not_present, wanted_type, int_base=0):
574574
dir_gid = self.gid_forced if self.gid_forced is not None else self.default_gid
575575
dir_user = uid2user(dir_uid)
576576
dir_group = gid2group(dir_gid)
577-
assert isinstance(dir_user, str)
578-
assert isinstance(dir_group, str)
577+
if not isinstance(dir_user, str):
578+
raise Error(
579+
f"uid {dir_uid} can not be resolved to a username. "
580+
f"Please check that the corresponding user exists or do not specify a uid mount option."
581+
)
582+
if not isinstance(dir_group, str):
583+
raise Error(
584+
f"gid {dir_gid} can not be resolved to a group name. "
585+
f"Please check that the corresponding group exists or do not specify a gid mount option."
586+
)
579587
dir_mode = 0o40755 & ~self.umask
580588
self.default_dir = Item(
581589
mode=dir_mode, mtime=int(time.time() * 1e9), user=dir_user, group=dir_group, uid=dir_uid, gid=dir_gid

src/borg/hlfuse.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from .archiver._common import build_matcher, build_filter
2525
from .archive import Archive, get_item_uid_gid
2626
from .hashindex import FuseVersionsIndex
27-
from .helpers import daemonize, daemonizing, signal_handler, bin_to_hex
27+
from .helpers import daemonize, daemonizing, signal_handler, bin_to_hex, Error
2828
from .helpers import HardLinkManager
2929
from .helpers import msgpack
3030
from .helpers.lrucache import LRUCache
@@ -510,8 +510,16 @@ def pop_option(options, key, present, not_present, wanted_type, int_base=0):
510510
dir_gid = self.gid_forced if self.gid_forced is not None else self.default_gid
511511
dir_user = uid2user(dir_uid)
512512
dir_group = gid2group(dir_gid)
513-
assert isinstance(dir_user, str)
514-
assert isinstance(dir_group, str)
513+
if not isinstance(dir_user, str):
514+
raise Error(
515+
f"uid {dir_uid} can not be resolved to a username. "
516+
f"Please check that the corresponding user exists or do not specify a uid mount option."
517+
)
518+
if not isinstance(dir_group, str):
519+
raise Error(
520+
f"gid {dir_gid} can not be resolved to a group name. "
521+
f"Please check that the corresponding group exists or do not specify a gid mount option."
522+
)
515523
dir_mode = 0o40755 & ~self.umask
516524
self.default_dir = Item(
517525
mode=dir_mode, mtime=int(time.time() * 1e9), user=dir_user, group=dir_group, uid=dir_uid, gid=dir_gid

0 commit comments

Comments
 (0)