38 : socket_type_(
"unix"), socket_name_() {
40 isc_throw(DhcpConfigError,
"expected map type ("
41 << config->getPosition() <<
")");
48 "invalid type specified for parameter 'socket-type' ("
49 << socket_type->getPosition() <<
")");
51 socket_type_ = socket_type->stringValue();
52 if ((socket_type_ !=
"unix")) {
54 << socket_type_ <<
"' not 'unix'");
58 if (
config->contains(
"socket-address")) {
59 isc_throw(DhcpConfigError,
60 "parameter 'socket-address' is not supported by UNIX "
70 isc_throw(DhcpConfigError,
71 "invalid type specified for parameter 'socket-name' ("
72 << socket_name->getPosition() <<
")");
76 socket_name_ = validatePath(socket_name->stringValue());
77 } catch (
const std::exception& ex) {
102 const std::string explicit_path ) {
103 if (!socket_path_checker_ || reset) {
104 socket_path_checker_.reset(
new PathChecker(CONTROL_SOCKET_DIR,
105 "KEA_CONTROL_SOCKET_DIR"));
106 if (!explicit_path.empty()) {
107 socket_path_checker_->getPath(
true, explicit_path);
111 return (socket_path_checker_->getPath());
116 if (!socket_path_checker_) {
120 std::string valid_path;
122 valid_path = socket_path_checker_->validatePath(socket_path);
130 auto parent_path = socket_path_checker_->getPath();
132 std::ostringstream oss;
133 oss <<
"socket path:" << parent_path
134 <<
" does not exist or does not have permssions = "
static ElementPtr create(const Position &pos=ZERO_POSITION())
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
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.
UnixCommandConfig(isc::data::ConstElementPtr config)
Constructor.
static const mode_t DEFAULT_SOCKET_PATH_PERMS
Defines the default permissions for unix socket parent directory.
static void setSocketPathPerms(mode_t perms=DEFAULT_SOCKET_PATH_PERMS)
Sets the required socket path permissions mask.
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
static std::string validatePath(const std::string socket_path)
Validates a path against the supported path for unix control sockets.
static mode_t socket_path_perms_
Stores the default permissions for unix socket parent directory.
To be removed. Please use ConfigError instead.
Embodies a supported path against which file paths can be validated.
static bool shouldEnforceSecurity()
Indicates security checks should be enforced.
A generic exception that is thrown if a parameter given violates security check but enforcement is la...
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
const isc::log::MessageID COMMAND_UNIX_SOCKET_PATH_SECURITY_WARNING
const isc::log::MessageID COMMAND_UNIX_SOCKET_PERMISSIONS_SECURITY_WARNING
isc::log::Logger command_logger("commands")
Command processing Logger.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
boost::shared_ptr< PathChecker > PathCheckerPtr
Defines a pointer to a PathChecker.
bool hasPermissions(const std::string path, const mode_t &permissions)
Check if there if file or directory has the given permissions.
Defines the logger used by the top-level component of kea-lfc.
void contextToElement(data::ElementPtr map) const
Merge unparse a user_context object.
void setContext(const data::ConstElementPtr &ctx)
Sets user context.