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 @@ -1395,9 +1395,15 @@ def devfs_ruleset(self) -> iocage.lib.DevfsRules.DevfsRuleset:
1395
1395
if self ._dhcp_enabled is True :
1396
1396
devfs_ruleset .append ("add path 'bpf*' unhide" )
1397
1397
1398
- if self ._allow_mount_zfs == "1" :
1398
+ if self ._allow_mount_zfs is True :
1399
1399
devfs_ruleset .append ("add path zfs unhide" )
1400
1400
1401
+ if self .config ["allow_usb" ] is True :
1402
+ devfs_ruleset .append ("add path 'usb/*' unhide" )
1403
+ devfs_ruleset .append ("add path 'usbctl' unhide" )
1404
+ for usb_device in self .config ["usb_device" ]:
1405
+ devfs_ruleset .append (f"add path '{ usb_device } ' unhide" )
1406
+
1401
1407
# create if the final rule combination does not exist as ruleset
1402
1408
if devfs_ruleset not in self .host .devfs :
1403
1409
self .logger .verbose ("New devfs ruleset combination" )
You can’t perform that action at this time.
0 commit comments