commit 0a9b252ff29e006693bf1f19fdcb0dca3bd118ec
parent b1be3e4e5449f268d4c075717d5d3d6f6b98660f
Author: Jan Pobříslo <ccx@te2000.cz>
Date: Thu, 22 Feb 2024 09:10:20 +0100
Chdir to the original directory by default
Diffstat:
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/userns_sandbox.py b/userns_sandbox.py
@@ -375,7 +375,7 @@ def sandbox_run(settings, command):
m.mount(settings.root)
os.chroot(str(settings.root))
- os.chdir('/')
+ os.chdir(settings.chdir)
exec_command(command)
@@ -404,6 +404,13 @@ argument_parser.add_argument(
type=pathlib.PosixPath,
help="versions dir (e.g. /versions)",
)
+argument_parser.add_argument(
+ '--chdir',
+ '-C',
+ type=pathlib.PosixPath,
+ default=pathlib.PosixPath(os.getcwd()),
+ help="set working directory inside sandbox",
+)
argument_parser.add_argument('--extra-mount', action='append', type=parse_mount)
argument_parser.add_argument('root_dir', type=pathlib.PosixPath)
argument_parser.add_argument('environment')