File tree Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -490,6 +490,19 @@ def _get_host_domainname(self) -> str:
490490 except KeyError :
491491 return "local"
492492
493+ def _get_usb_device (self ) -> typing .List [str ]:
494+ devices = self .data ["usb_device" ].split () # type: typing.List[str]
495+ return devices
496+
497+ def _set_usb_device (
498+ self ,
499+ value : typing .Union [typing .List [str ], str ]
500+ ) -> None :
501+ if isinstance (value , list ):
502+ self .data ["usb_device" ] = " " .join (value )
503+ else :
504+ self .data ["usb_device" ] = value
505+
493506 def get_string (self , key : str ) -> str :
494507 """Get the stringified value of a configuration property."""
495508 return self .stringify (self .__getitem__ (key ))
Original file line number Diff line number Diff line change @@ -104,6 +104,8 @@ class JailConfigDefaults(iocage.Config.Jail.BaseConfig.BaseConfig):
104104 "allow_mount_fdescfs" : 0 ,
105105 "allow_mount_zfs" : 0 ,
106106 "allow_mount_tmpfs" : 0 ,
107+ "allow_usb" : 0 ,
108+ "usb_device" : ["ugen*" ],
107109 "allow_quotas" : 0 ,
108110 "allow_socket_af" : 0 ,
109111 "rlimits" : None ,
Original file line number Diff line number Diff line change @@ -1437,9 +1437,15 @@ def devfs_ruleset(self) -> iocage.DevfsRules.DevfsRuleset:
14371437 if self ._dhcp_enabled is True :
14381438 devfs_ruleset .append ("add path 'bpf*' unhide" )
14391439
1440- if self ._allow_mount_zfs == "1" :
1440+ if self ._allow_mount_zfs is True :
14411441 devfs_ruleset .append ("add path zfs unhide" )
14421442
1443+ if self .config ["allow_usb" ] is True :
1444+ devfs_ruleset .append ("add path 'usb/*' unhide" )
1445+ devfs_ruleset .append ("add path 'usbctl' unhide" )
1446+ for usb_device in self .config ["usb_device" ]:
1447+ devfs_ruleset .append (f"add path '{ usb_device } ' unhide" )
1448+
14431449 # create if the final rule combination does not exist as ruleset
14441450 if devfs_ruleset not in self .host .devfs :
14451451 self .logger .verbose ("New devfs ruleset combination" )
You can’t perform that action at this time.
0 commit comments