MCPcopy Create free account
hub / github.com/USBGuard/usbguard / setDeviceAuthorizedDefault

Method setDeviceAuthorizedDefault

src/Library/DeviceManagerBase.cpp:186–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184 }
185
186 void DeviceManagerBase::setDeviceAuthorizedDefault(SysFSDevice* device, DeviceManager::AuthorizedDefaultType auth_default)
187 {
188 if (auth_default == DeviceManager::AuthorizedDefaultType::Keep) {
189 return;
190 }
191
192 std::string auth_default_str = std::to_string(DeviceManager::authorizedDefaultTypeToInteger(auth_default));
193 device->setAttribute("authorized_default", auth_default_str);
194
195 if (device->readAttribute("authorized_default", /*strip_last_null=*/true) != auth_default_str) {
196 if (auth_default == DeviceManager::AuthorizedDefaultType::Internal) {
197 USBGUARD_LOG(Warning) << "No kernel support for authorized_default = 2, falling back to 0";
198 setDeviceAuthorizedDefault(device, DeviceManager::AuthorizedDefaultType::None);
199 }
200 else {
201 throw Exception("DeviceBase", device->getPath(), "Failed to set authorized_default to \"" + auth_default_str + "\"");
202 }
203 }
204 }
205
206 void DeviceManagerBase::sysfsAuthorizeDevice(SysFSDevice& sysfs_device)
207 {

Callers

nothing calls this directly

Calls 3

ExceptionFunction · 0.85
readAttributeMethod · 0.80
setAttributeMethod · 0.45

Tested by

no test coverage detected