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 @@ -490,6 +490,19 @@ def _get_host_domainname(self) -> str:
490
490
except KeyError :
491
491
return "local"
492
492
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
+
493
506
def get_string (self , key : str ) -> str :
494
507
"""Get the stringified value of a configuration property."""
495
508
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):
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 @@ -1437,9 +1437,15 @@ def devfs_ruleset(self) -> iocage.DevfsRules.DevfsRuleset:
1437
1437
if self ._dhcp_enabled is True :
1438
1438
devfs_ruleset .append ("add path 'bpf*' unhide" )
1439
1439
1440
- if self ._allow_mount_zfs == "1" :
1440
+ if self ._allow_mount_zfs is True :
1441
1441
devfs_ruleset .append ("add path zfs unhide" )
1442
1442
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
+
1443
1449
# create if the final rule combination does not exist as ruleset
1444
1450
if devfs_ruleset not in self .host .devfs :
1445
1451
self .logger .verbose ("New devfs ruleset combination" )
You can’t perform that action at this time.
0 commit comments