Kea: isc::config::UnixCommandConfig Class Reference

| Kea 3.2.0-git

isc::config::UnixCommandConfig Class Reference

UNIX command config aka UNIX control socket info class. More...

`#include <unix_command_config.h>`

Inheritance diagram for isc::config::UnixCommandConfig:
[legend]

## Public Member Functions
| UnixCommandConfig (isc::data::ConstElementPtr config)
| Constructor.
| ~UnixCommandConfig ()=default
| Virtual destructor.
std::string | getLockName ()
| Returns the lock file name.
std::string | getSocketName () const
| Returns socket name.
std::string | getSocketType () const
| Returns socket type.
void | setSocketName (const std::string &socket_name)
| Sets socket name.
void | setSocketType (const std::string &socket_type)
| Sets socket type.
virtual isc::data::ElementPtr | toElement () const
| Unparse a configuration object.
Public Member Functions inherited from isc::data::UserContext
void | contextToElement (data::ElementPtr map) const
| Merge unparse a user_context object.
data::ConstElementPtr | getContext () const
| Returns const pointer to the user context.
void | setContext (const data::ConstElementPtr &ctx)
| Sets user context.
Public Member Functions inherited from isc::data::CfgToElement
virtual | ~CfgToElement ()
| Destructor.

## Static Public Member Functions
static std::string | getSocketPath (bool reset=false, const std::string explicit_path="")
| Fetches the supported control socket path.
static mode_t | getSocketPathPerms ()
| Fetches the required socket path permissions mask.
static void | setSocketPathPerms (mode_t perms=DEFAULT_SOCKET_PATH_PERMS)
| Sets the required socket path permissions mask.
static std::string | validatePath (const std::string socket_path)
| Validates a path against the supported path for unix control sockets.
Static Public Member Functions inherited from isc::data::UserContext
static data::ElementPtr | toElement (data::ConstElementPtr map)
| Copy an Element map.

## Static Public Attributes
static const mode_t | DEFAULT_SOCKET_PATH_PERMS = (S_IRWXU | S_IRGRP | S_IXGRP)
| Defines the default permissions for unix socket parent directory.
static mode_t | socket_path_perms_ = UnixCommandConfig::DEFAULT_SOCKET_PATH_PERMS
| Stores the default permissions for unix socket parent directory.

## Additional Inherited Members
Protected Attributes inherited from isc::data::UserContext
data::ConstElementPtr | user_context_
| Pointer to the user context (may be NULL).

## Detailed Description

UNIX command config aka UNIX control socket info class.

Definition at line 22 of file unix_command_config.h.

## Constructor & Destructor Documentation

## ◆ UnixCommandConfig()

isc::config::UnixCommandConfig::UnixCommandConfig | ( | isc::data::ConstElementPtr | config | ) |

Constructor.

Parameters

  config | Pointer to the configuration to parse.

Definition at line 38 of file unix_command_config.cc.

References if(), isc_throw, Element::map, isc::data::UserContext::setContext(), and Element::string.

Here is the call graph for this function:

## ◆ ~UnixCommandConfig()

isc::config::UnixCommandConfig::~UnixCommandConfig | ( |  | ) |
| default

Virtual destructor.

References DEFAULT_SOCKET_PATH_PERMS.

## Member Function Documentation

## ◆ getLockName()

std::string isc::config::UnixCommandConfig::getLockName | ( |  | ) |
| inline

Returns the lock file name.

Definition at line 102 of file unix_command_config.h.

## ◆ getSocketName()

std::string isc::config::UnixCommandConfig::getSocketName | ( |  | ) | const
| inline

Returns socket name.

Returns
  The socket name.

Definition at line 90 of file unix_command_config.h.

## ◆ getSocketPath()

std::string isc::config::UnixCommandConfig::getSocketPath | ( | bool | reset = false,
|  | const std::string | explicit_path = "" )
| static

Fetches the supported control socket path.

The first call to this function with no arguments will set the default path to either the value of CONTROL_SOCKET_DIR or the environment variable KEA_CONTROL_SOCKET_DIR if it is defined. Subsequent calls with no arguments will simply return this value.

Parameters

  reset | recalculate when true, defaults to false.
  explicit_path | set the default socket path to this value. This is for testing purposes only.

Returns
  String containing the default socket path.

Definition at line 111 of file unix_command_config.cc.

Referenced by validatePath().

## ◆ getSocketPathPerms()

mode_t isc::config::UnixCommandConfig::getSocketPathPerms | ( |  | ) |
| static

Fetches the required socket path permissions mask.

Returns
  permissions mask

Definition at line 160 of file unix_command_config.cc.

References socket_path_perms_.

## ◆ getSocketType()

std::string isc::config::UnixCommandConfig::getSocketType | ( |  | ) | const
| inline

Returns socket type.

Returns
  The socket type ("unix").

Definition at line 76 of file unix_command_config.h.

## ◆ setSocketName()

void isc::config::UnixCommandConfig::setSocketName | ( | const std::string & | socket_name | ) |
| inline

Sets socket name.

Parameters

  socket_name | The new socket name.

Definition at line 97 of file unix_command_config.h.

## ◆ setSocketPathPerms()

void isc::config::UnixCommandConfig::setSocketPathPerms | ( | mode_t | perms = DEFAULT_SOCKET_PATH_PERMS | ) |
| static

Sets the required socket path permissions mask.

This is for testing purposes only.

Parameters

  perms | permissions mask to use

Definition at line 165 of file unix_command_config.cc.

References socket_path_perms_.

## ◆ setSocketType()

void isc::config::UnixCommandConfig::setSocketType | ( | const std::string & | socket_type | ) |
| inline

Sets socket type.

Parameters

  socket_type | The new socket type (should be "unix").

Definition at line 83 of file unix_command_config.h.

## ◆ toElement()

ElementPtr isc::config::UnixCommandConfig::toElement | ( |  | ) | const
| virtual

Unparse a configuration object.

Returns
  A pointer to configuration.

Implements isc::data::CfgToElement.

Definition at line 99 of file unix_command_config.cc.

References isc::data::UserContext::contextToElement(), Element::create(), and Element::createMap().

Here is the call graph for this function:

## ◆ validatePath()

std::string isc::config::UnixCommandConfig::validatePath | ( | const std::string | socket_path | ) |
| static

Validates a path against the supported path for unix control sockets.

Parameters

  socket_path | path to validate.

Returns
  validated path

Definition at line 125 of file unix_command_config.cc.

References isc::config::command_logger, isc::config::COMMAND_UNIX_SOCKET_PATH_SECURITY_WARNING, isc::config::COMMAND_UNIX_SOCKET_PERMISSIONS_SECURITY_WARNING, isc::util::file::getPermissions(), getSocketPath(), isc_throw, LOG_WARN, isc::util::file::PathChecker::shouldEnforceSecurity(), socket_path_perms_, and isc::Exception::what().

Referenced by isc::netconf::ControlSocketConfigParser::parse().

Here is the call graph for this function:

## Member Data Documentation

## ◆ DEFAULT_SOCKET_PATH_PERMS

const mode_t isc::config::UnixCommandConfig::DEFAULT_SOCKET_PATH_PERMS = (S_IRWXU | S_IRGRP | S_IXGRP)
| static

Defines the default permissions for unix socket parent directory.

Definition at line 26 of file unix_command_config.h.

Referenced by ~UnixCommandConfig().

## ◆ socket_path_perms_

mode_t isc::config::UnixCommandConfig::socket_path_perms_ = UnixCommandConfig::DEFAULT_SOCKET_PATH_PERMS
| static

Stores the default permissions for unix socket parent directory.

Definition at line 29 of file unix_command_config.h.

Referenced by getSocketPathPerms(), setSocketPathPerms(), and validatePath().

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

- unix_command_config.h
- unix_command_config.cc