@@ -520,10 +520,7 @@ def start(
520520 exec_start .append ("service ipfw onestop" )
521521
522522 if self .config ["jail_zfs" ] is True :
523- share_storage = libioc .ZFSShareStorage .QueuingZFSShareStorage (
524- jail = self ,
525- logger = self .logger
526- )
523+ share_storage = self ._zfs_share_storage
527524 share_storage .mount_zfs_shares ()
528525 exec_start += share_storage .read_commands ("jail" )
529526 exec_created += share_storage .read_commands ()
@@ -615,6 +612,15 @@ def _stop_failed_jail(
615612
616613 yield jailLaunchEvent .end (stdout = stdout )
617614
615+ @property
616+ def _zfs_share_storage (
617+ self
618+ ) -> libioc .ZFSShareStorage .QueuingZFSShareStorage :
619+ return libioc .ZFSShareStorage .QueuingZFSShareStorage (
620+ jail = self ,
621+ logger = self .logger
622+ )
623+
618624 def _start_dependant_jails (
619625 self ,
620626 terms : libioc .Filter .Terms ,
@@ -726,7 +732,7 @@ def _wrap_hook_script_command(
726732 self ,
727733 commands : typing .Optional [typing .Union [str , typing .List [str ]]],
728734 ignore_errors : bool = True ,
729- jailed : bool = False ,
735+ jailed : bool = False , # ToDo: remove unused argument
730736 write_env : bool = True
731737 ) -> typing .List [str ]:
732738
@@ -862,6 +868,7 @@ def _run_hook(self, hook_name: str) -> typing.Optional[
862868 raise NotImplementedError ("_run_hook only supports start/stop" )
863869
864870 def _ensure_script_dir (self ) -> None :
871+ """Ensure that the launch scripts dir exists."""
865872 realpath = os .path .realpath (self .launch_script_dir )
866873 if realpath .startswith (self .dataset .mountpoint ) is False :
867874 raise libioc .errors .SecurityViolationConfigJailEscape (
@@ -1602,6 +1609,30 @@ def devfs_ruleset(self) -> libioc.DevfsRules.DevfsRuleset:
16021609 if self ._allow_mount_zfs == "1" :
16031610 devfs_ruleset .append ("add path zfs unhide" )
16041611
1612+ if self .config ["jail_zfs" ] is True :
1613+ unhidden_parents : typing .Set [str ] = set ()
1614+ shared_datasets = self ._zfs_share_storage .get_zfs_datasets ()
1615+ if len (shared_datasets ) > 0 :
1616+ devfs_ruleset .append ("add path zvol unhide" )
1617+ for shared_dataset in shared_datasets :
1618+ current_dataset_name = "zvol"
1619+ for fragment in shared_dataset .name .split ("/" ):
1620+ current_dataset_name += f"/{ fragment } "
1621+ if current_dataset_name in unhidden_parents :
1622+ continue
1623+ unhidden_parents .add (current_dataset_name )
1624+ devfs_ruleset .append (
1625+ f"add path { current_dataset_name } unhide"
1626+ )
1627+ devfs_ruleset .append (
1628+ f"add path { current_dataset_name } /* unhide"
1629+ )
1630+
1631+ if self .config ["allow_vmm" ] is True :
1632+ devfs_ruleset .append ("add path vmm unhide" )
1633+ devfs_ruleset .append ("add path vmm/* unhide" )
1634+ devfs_ruleset .append ("add path nmdm* unhide" )
1635+
16051636 # create if the final rule combination does not exist as ruleset
16061637 if devfs_ruleset not in self .host .devfs :
16071638 self .logger .verbose ("New devfs ruleset combination" )
@@ -1680,6 +1711,9 @@ def _launch_command(self) -> typing.List[str]:
16801711 f"mount.devfs={ self ._get_value ('mount_devfs' )} "
16811712 ]
16821713
1714+ if self .config ["allow_vmm" ] is True :
1715+ command .append ("allow.vmm=1" )
1716+
16831717 if self .host .userland_version > 9.3 :
16841718 command += [
16851719 f"mount.fdescfs={ self ._get_value ('mount_fdescfs' )} " ,
@@ -2174,6 +2208,14 @@ def env(self) -> typing.Dict[str, str]:
21742208
21752209 jail_env ["IOC_JAIL_PATH" ] = self .root_dataset .mountpoint
21762210 jail_env ["IOC_JID" ] = str (self .jid )
2211+ jail_env ["PATH" ] = ":" .join ((
2212+ "/sbin" ,
2213+ "/bin" ,
2214+ "/usr/sbin" ,
2215+ "/usr/bin" ,
2216+ "/usr/local/sbin" ,
2217+ "/usr/local/bin" ,
2218+ ))
21772219
21782220 return jail_env
21792221
0 commit comments