From b9a345fd70f7e730efb7a797ae1785e7143c2cc0 Mon Sep 17 00:00:00 2001 From: Poeloe <22234727+Poeloe@users.noreply.github.com> Date: Tue, 10 Sep 2024 05:25:47 -0700 Subject: [PATCH 1/4] Add option to unset allow_other option for FUSE for target-mount Fixes ##683 --- dissect/target/tools/mount.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/dissect/target/tools/mount.py b/dissect/target/tools/mount.py index e1a9c8e60..a88a97287 100644 --- a/dissect/target/tools/mount.py +++ b/dissect/target/tools/mount.py @@ -99,14 +99,23 @@ def main(): 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 allow_other in ["True", "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 allow_other in ["False", "false"]: + options["allow_other"] = False + + log.info(f"Mounting to {args.mount} with options: {_format_options(options)}") try: FUSE(DissectMount(vfs), args.mount, **options) except RuntimeError: - parser.exit("FUSE error") + log.error("Mounting target %s failed", t) + parser.exit(1) def _format_options(options: dict[str, Union[str, bool]]) -> str: From 4c2cabf03f56591aa8bd91f1e8582cc28d1842c6 Mon Sep 17 00:00:00 2001 From: Poeloe <22234727+Poeloe@users.noreply.github.com> Date: Tue, 10 Sep 2024 05:39:08 -0700 Subject: [PATCH 2/4] Process review feedback --- dissect/target/tools/mount.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dissect/target/tools/mount.py b/dissect/target/tools/mount.py index a88a97287..19e678803 100644 --- a/dissect/target/tools/mount.py +++ b/dissect/target/tools/mount.py @@ -110,7 +110,7 @@ def main(): elif allow_other in ["False", "false"]: options["allow_other"] = False - log.info(f"Mounting to {args.mount} with options: {_format_options(options)}") + log.info("Mounting to %s with options: %s", args.mount, _format_options(options)) try: FUSE(DissectMount(vfs), args.mount, **options) except RuntimeError: From 655d83fe8c1665e963955eebc4a994ef35f12292 Mon Sep 17 00:00:00 2001 From: Poeloe <22234727+Poeloe@users.noreply.github.com> Date: Tue, 10 Sep 2024 05:42:19 -0700 Subject: [PATCH 3/4] Process review feedback --- dissect/target/tools/mount.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dissect/target/tools/mount.py b/dissect/target/tools/mount.py index 19e678803..da660e2a6 100644 --- a/dissect/target/tools/mount.py +++ b/dissect/target/tools/mount.py @@ -101,13 +101,13 @@ def main(): options["nothreads"] = True options["ro"] = True # 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 allow_other in ["True", "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 allow_other in ["False", "false"]: + elif str(allow_other).lower() == "false": options["allow_other"] = False log.info("Mounting to %s with options: %s", args.mount, _format_options(options)) From de637b2b847906164527b4631be8242e1ae0bb26 Mon Sep 17 00:00:00 2001 From: Poeloe <22234727+Poeloe@users.noreply.github.com> Date: Tue, 10 Sep 2024 06:10:13 -0700 Subject: [PATCH 4/4] Proccess review feedback --- dissect/target/tools/mount.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dissect/target/tools/mount.py b/dissect/target/tools/mount.py index da660e2a6..948005cb2 100644 --- a/dissect/target/tools/mount.py +++ b/dissect/target/tools/mount.py @@ -113,8 +113,9 @@ def main(): log.info("Mounting to %s with options: %s", args.mount, _format_options(options)) try: FUSE(DissectMount(vfs), args.mount, **options) - except RuntimeError: + except RuntimeError as e: log.error("Mounting target %s failed", t) + log.debug("", exc_info=e) parser.exit(1)