44 with full access to all files via bind mounts, \
55 thanks to systemd-nspawn!"""
66
7- __version__ = "1.4.1 "
8-
7+ __version__ = "1.4.2 "
8+ __author__ = "Jip-Hop"
99__disclaimer__ = """USE THIS SCRIPT AT YOUR OWN RISK!
1010IT COMES WITHOUT WARRANTY AND IS NOT SUPPORTED BY IXSYSTEMS."""
1111
@@ -357,7 +357,9 @@ def passthrough_nvidia(
357357 nvidia_libraries = set (
358358 [
359359 x
360- for x in subprocess .check_output (["nvidia-container-cli" , "list" , "--libraries" ])
360+ for x in subprocess .check_output (
361+ ["nvidia-container-cli" , "list" , "--libraries" ]
362+ )
361363 .decode ()
362364 .split ("\n " )
363365 if x
@@ -371,8 +373,7 @@ def passthrough_nvidia(
371373 for x in subprocess .check_output (["nvidia-container-cli" , "list" ])
372374 .decode ()
373375 .split ("\n " )
374- if x
375- and x not in nvidia_libraries
376+ if x and x not in nvidia_libraries
376377 ]
377378 )
378379 )
@@ -503,6 +504,19 @@ def parse_config_file(jail_config_path):
503504 return
504505
505506
507+ def systemd_escape_path (path ):
508+ """
509+ Escape path containing spaces, while properly handling backslashes in filenames.
510+ https://manpages.debian.org/bookworm/systemd/systemd.syntax.7.en.html#QUOTING
511+ https://manpages.debian.org/bookworm/systemd/systemd.service.5.en.html#COMMAND_LINES
512+ """
513+ return "" .join (
514+ map (
515+ lambda char : "\s" if char == " " else "\\ \\ " if char == "\\ " else char , path
516+ )
517+ )
518+
519+
506520def add_hook (jail_path , systemd_run_additional_args , hook_command , hook_type ):
507521 if not hook_command :
508522 return
@@ -520,7 +534,9 @@ def add_hook(jail_path, systemd_run_additional_args, hook_command, hook_type):
520534 print (hook_command , file = open (hook_file , "w" ))
521535
522536 stat_chmod (hook_file , 0o700 )
523- systemd_run_additional_args += [f"--property={ hook_type } ={ hook_file } " ]
537+ systemd_run_additional_args += [
538+ f"--property={ hook_type } ={ systemd_escape_path (hook_file )} "
539+ ]
524540
525541
526542def start_jail (jail_name ):
@@ -1839,7 +1855,7 @@ def install_jailmaker():
18391855 f"Cannot create symlink because { symlink } is on a readonly filesystem."
18401856 )
18411857
1842- alias = f"alias jlmkr={ shlex . quote ( SCRIPT_PATH ) } # managed by jailmaker"
1858+ alias = f"alias jlmkr=' \" { SCRIPT_PATH } \" ' # managed by jailmaker"
18431859 alias_regex = re .compile (r"^\s*alias jlmkr=.*# managed by jailmaker\s*" )
18441860 shell_env = os .getenv ("SHELL" )
18451861
0 commit comments