Skip to content

Commit

Permalink
support USB in jails
Browse files Browse the repository at this point in the history
  • Loading branch information
gronke committed Sep 25, 2017
1 parent 8005be9 commit f6c95eb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
12 changes: 12 additions & 0 deletions iocage/lib/Config/Jail/BaseConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,18 @@ def _set_login_flags(self, value, **kwargs):
logger=self.logger
)

def _get_usb_device(self) -> typing.List[str]:
return self.data["usb_device"].split()

def _set_usb_device(
self,
value: typing.Union[typing.List[str], str]
) -> None:
if isinstance(value, list):
self.data["usb_device"] = " ".join(value)
else:
self.data["usb_device"] = value

def _get_host_hostuuid(self):
try:
return self.data["host_hostuuid"]
Expand Down
2 changes: 2 additions & 0 deletions iocage/lib/Config/Jail/Defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ class JailConfigDefaults(iocage.lib.Config.Jail.BaseConfig.BaseConfig):
"allow_mount_procfs": 0,
"allow_mount_zfs": 0,
"allow_mount_tmpfs": 0,
"allow_usb": 0,
"usb_device": ["ugen*"],
"allow_quotas": 0,
"allow_socket_af": 0,
"sysvmsg": "new",
Expand Down
8 changes: 7 additions & 1 deletion iocage/lib/Jail.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,9 +673,15 @@ def devfs_ruleset(self) -> iocage.lib.DevfsRules.DevfsRuleset:
devfs_ruleset = iocage.lib.DevfsRules.DevfsRuleset()
devfs_ruleset.clone(configured_devfs_ruleset)

if self._dhcp_enabled:
if self._dhcp_enabled is True:
devfs_ruleset.append("add path 'bpf*' unhide")

if self.config["allow_usb"] is True:
devfs_ruleset.append("add path 'usb/*' unhide")
devfs_ruleset.append("add path 'usbctl' unhide")
for usb_device in self.config["usb_device"]:
devfs_ruleset.append(f"add path '{usb_device}' unhide")

# create if the final rule combination does not exist as ruleset
if devfs_ruleset not in self.host.devfs:
self.logger.verbose("New devfs ruleset combination")
Expand Down

0 comments on commit f6c95eb

Please sign in to comment.