Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to unset allow_other option for FUSE for target-mount #844

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions dissect/target/tools/mount.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,24 @@
options = parse_options_string(args.options) if args.options else {}

options["nothreads"] = True
options["allow_other"] = True
options["ro"] = True

print(f"Mounting to {args.mount} with options: {_format_options(options)}")
# Check if the allow other option is either not set (None) or set to True with -o allow_other=True
if (allow_other := options.get("allow_other")) is None or str(allow_other).lower() == "true":
options["allow_other"] = True
# If allow_other was not set, warn the user that it will be set by default
if allow_other is None:
log.warning("Using option 'allow_other' by default, please use '-o allow_other=False' to unset")
# Let the user be able to unset the allow_other option by supplying -o allow_other=False
elif str(allow_other).lower() == "false":
options["allow_other"] = False

Check warning on line 111 in dissect/target/tools/mount.py

View check run for this annotation

Codecov / codecov/patch

dissect/target/tools/mount.py#L110-L111

Added lines #L110 - L111 were not covered by tests

log.info("Mounting to %s with options: %s", args.mount, _format_options(options))
try:
FUSE(DissectMount(vfs), args.mount, **options)
except RuntimeError:
parser.exit("FUSE error")
except RuntimeError as e:
log.error("Mounting target %s failed", t)
Schamper marked this conversation as resolved.
Show resolved Hide resolved
log.debug("", exc_info=e)
parser.exit(1)

Check warning on line 119 in dissect/target/tools/mount.py

View check run for this annotation

Codecov / codecov/patch

dissect/target/tools/mount.py#L116-L119

Added lines #L116 - L119 were not covered by tests


def _format_options(options: dict[str, Union[str, bool]]) -> str:
Expand Down