USBGuard
Software framework that protects your computer against rogue USB devices by implementing basic whitelisting and blacklisting capabilities.
Classes | Public Member Functions | Static Public Member Functions | List of all members
usbguard::IPCServer Class Reference

Receives messages from IPC clients. Provides USBGuard service. More...

#include <IPCServer.hpp>

Inheritance diagram for usbguard::IPCServer:
usbguard::Interface

Classes

class  AccessControl
 Limits access to the USBGuard IPC interface. More...
 

Public Member Functions

 IPCServer ()
 Initializes main loop, creates IPC server and USBGuard service.
 
virtual ~IPCServer ()
 Default destructor.
 
void start ()
 Starts the main loop if it is not already running.
 
void stop ()
 Stops the main loop.
 
void DevicePresenceChanged (uint32_t id, DeviceManager::EventType event, Rule::Target target, const std::string &device_rule)
 Notify that a USB device was already present when USBGuard was started. More...
 
void DevicePolicyChanged (uint32_t id, Rule::Target target_old, Rule::Target target_new, const std::string &device_rule, uint32_t rule_id)
 Notify about a change of a USB device authorization target. More...
 
void PropertyParameterChanged (const std::string &name, const std::string &value_old, const std::string &value_new)
 Notify about a change of a property parameter. More...
 
void ExceptionMessage (const std::string &context, const std::string &object, const std::string &reason)
 Notify about an exception. More...
 
void addAllowedUID (uid_t uid, const IPCServer::AccessControl &ac)
 Adds user to a set of allowed users by specifying his user ID. More...
 
void addAllowedGID (gid_t gid, const IPCServer::AccessControl &ac)
 Adds group to a set of allowed groups by specifying its group ID. More...
 
void addAllowedUsername (const std::string &username, const IPCServer::AccessControl &ac)
 Adds user to a set of allowed users by specifying his user name. More...
 
void addAllowedGroupname (const std::string &groupname, const IPCServer::AccessControl &ac)
 Adds group to a set of allowed groups by specifying its group name. More...
 
- Public Member Functions inherited from usbguard::Interface
virtual std::string setParameter (const std::string &name, const std::string &value)=0
 Set value of a runtime parameter. More...
 
virtual std::string getParameter (const std::string &name)=0
 Get value of a runtime parameter. More...
 
virtual uint32_t appendRule (const std::string &rule_spec, uint32_t parent_id, bool permanent)=0
 Append a new rule to the current policy. More...
 
virtual void removeRule (uint32_t id)=0
 Remove a rule from the current policy. More...
 
virtual const std::vector< RulelistRules (const std::string &query)=0
 List the current rule set (policy) used by the USBGuard daemon. More...
 
virtual uint32_t applyDevicePolicy (uint32_t id, Rule::Target target, bool permanent)=0
 Apply an authorization target to a device. More...
 
virtual const std::vector< RulelistDevices (const std::string &query)=0
 List devices that match the specified query. More...
 

Static Public Member Functions

static void checkAccessControlName (const std::string &name)
 Checks whether given name is a valid access control name. More...
 

Detailed Description

Receives messages from IPC clients. Provides USBGuard service.

Member Function Documentation

◆ addAllowedGID()

void usbguard::IPCServer::addAllowedGID ( gid_t  gid,
const IPCServer::AccessControl ac 
)

Adds group to a set of allowed groups by specifying its group ID.

Parameters
gidGroup ID of group to allow.
acAccess control for given group.

◆ addAllowedGroupname()

void usbguard::IPCServer::addAllowedGroupname ( const std::string &  groupname,
const IPCServer::AccessControl ac 
)

Adds group to a set of allowed groups by specifying its group name.

Parameters
groupnameGroup name of group to allow.
acAccess control for given group.

◆ addAllowedUID()

void usbguard::IPCServer::addAllowedUID ( uid_t  uid,
const IPCServer::AccessControl ac 
)

Adds user to a set of allowed users by specifying his user ID.

Parameters
uidUser ID of user to allow.
acAccess control for given user.

◆ addAllowedUsername()

void usbguard::IPCServer::addAllowedUsername ( const std::string &  username,
const IPCServer::AccessControl ac 
)

Adds user to a set of allowed users by specifying his user name.

Parameters
usernameUser name of user to allow.
acAccess control for given user.

◆ checkAccessControlName()

void usbguard::IPCServer::checkAccessControlName ( const std::string &  name)
static

Checks whether given name is a valid access control name.

Name is a valid access control name if and only if:

  1. name is not longer then 32 characters.
  2. name consists only from characters from set { A-Z, a-z, 0-9, _ }.
Parameters
nameName to be verified.
Exceptions
ExceptionIf name is not a valid access control name.

◆ DevicePolicyChanged()

void usbguard::IPCServer::DevicePolicyChanged ( uint32_t  id,
Rule::Target  target_old,
Rule::Target  target_new,
const std::string &  device_rule,
uint32_t  rule_id 
)
virtual

Notify about a change of a USB device authorization target.

The device attribute dictionary contains the following attributes:

  • id (the USB device ID in the form VID:PID)
  • name
  • serial
  • via-port
  • hash
  • parent-hash
  • with-interface
Parameters
idID of the device.
target_oldPrevious authorization target.
target_newCurrent authorization target.
device_ruleDevice specific rule.
rule_idRule ID of the matched rule. Otherwise a reserved rule ID value is used.

Implements usbguard::Interface.

◆ DevicePresenceChanged()

void usbguard::IPCServer::DevicePresenceChanged ( uint32_t  id,
DeviceManager::EventType  event,
Rule::Target  target,
const std::string &  device_rule 
)
virtual

Notify that a USB device was already present when USBGuard was started.

The device attribute dictionary contains the following attributes:

  • id (the USB device ID in the form VID:PID)
  • name
  • serial
  • via-port
  • hash
  • parent-hash
  • with-interface

The USB interface types are represented as strings of the form AA:BB:CC, where AA, BB and CC are hexadecimal numbers representing the class, subclass and protocol of the interface as defined by the USB standard.

Parameters
idID of the device.
eventType of the presence change event.
targetThe current authorization target of the device.
device_ruleDevice specific rule.

Implements usbguard::Interface.

◆ ExceptionMessage()

void usbguard::IPCServer::ExceptionMessage ( const std::string &  context,
const std::string &  object,
const std::string &  reason 
)
virtual

Notify about an exception.

Parameters
contextDescription or identifier of the exception context.
objectDescription or identifier of the object which caused the exception.
reasonReason explaining why the exception was generated.

Implements usbguard::Interface.

◆ PropertyParameterChanged()

void usbguard::IPCServer::PropertyParameterChanged ( const std::string &  name,
const std::string &  value_old,
const std::string &  value_new 
)
virtual

Notify about a change of a property parameter.

Parameters
namePolicy name.
value_oldPrevious policy value.
value_newCurrent policy value.

Implements usbguard::Interface.


The documentation for this class was generated from the following files: