blob: 0dfb736cf94e3195bb4f249f07b56ab61c21fb06 [file] [log] [blame]
// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "permission_broker/deny_usb_device_class_rule.h"
#include <libudev.h>
#include "base/stringprintf.h"
namespace permission_broker {
DenyUsbDeviceClassRule::DenyUsbDeviceClassRule(const uint8_t device_class)
: UsbSubsystemUdevRule("DenyUsbDeviceClassRule"),
device_class_(StringPrintf("%.2x", device_class)) {}
DenyUsbDeviceClassRule::~DenyUsbDeviceClassRule() {}
Rule::Result DenyUsbDeviceClassRule::ProcessUsbDevice(
struct udev_device *device) {
const char *device_class =
udev_device_get_sysattr_value(device, "bDeviceClass");
if (device_class && (device_class_ == device_class))
return DENY;
return IGNORE;
} // namespace permission_broker