| 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 | { |
nothing calls this directly
no test coverage detected