File tree 3 files changed +22
-1
lines changed
3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -482,6 +482,19 @@ def _get_host_domainname(self) -> str:
482
482
except KeyError :
483
483
return "local"
484
484
485
+ def _get_usb_device (self ) -> typing .List [str ]:
486
+ devices = self .data ["usb_device" ].split () # type: typing.List[str]
487
+ return devices
488
+
489
+ def _set_usb_device (
490
+ self ,
491
+ value : typing .Union [typing .List [str ], str ]
492
+ ) -> None :
493
+ if isinstance (value , list ):
494
+ self .data ["usb_device" ] = " " .join (value )
495
+ else :
496
+ self .data ["usb_device" ] = value
497
+
485
498
def get_string (self , key : str ) -> str :
486
499
"""Get the stringified value of a configuration property."""
487
500
return self .stringify (self .__getitem__ (key ))
Original file line number Diff line number Diff line change @@ -104,6 +104,8 @@ class JailConfigDefaults(iocage.lib.Config.Jail.BaseConfig.BaseConfig):
104
104
"allow_mount_fdescfs" : 0 ,
105
105
"allow_mount_zfs" : 0 ,
106
106
"allow_mount_tmpfs" : 0 ,
107
+ "allow_usb" : 0 ,
108
+ "usb_device" : ["ugen*" ],
107
109
"allow_quotas" : 0 ,
108
110
"allow_socket_af" : 0 ,
109
111
"rlimits" : None ,
Original file line number Diff line number Diff line change @@ -1389,9 +1389,15 @@ def devfs_ruleset(self) -> iocage.lib.DevfsRules.DevfsRuleset:
1389
1389
if self ._dhcp_enabled is True :
1390
1390
devfs_ruleset .append ("add path 'bpf*' unhide" )
1391
1391
1392
- if self ._allow_mount_zfs == "1" :
1392
+ if self ._allow_mount_zfs is True :
1393
1393
devfs_ruleset .append ("add path zfs unhide" )
1394
1394
1395
+ if self .config ["allow_usb" ] is True :
1396
+ devfs_ruleset .append ("add path 'usb/*' unhide" )
1397
+ devfs_ruleset .append ("add path 'usbctl' unhide" )
1398
+ for usb_device in self .config ["usb_device" ]:
1399
+ devfs_ruleset .append (f"add path '{ usb_device } ' unhide" )
1400
+
1395
1401
# create if the final rule combination does not exist as ruleset
1396
1402
if devfs_ruleset not in self .host .devfs :
1397
1403
self .logger .verbose ("New devfs ruleset combination" )
You can’t perform that action at this time.
0 commit comments