39 : socket_type_(
"unix"), socket_name_() {
41 isc_throw(DhcpConfigError,
"expected map type ("
42 << config->getPosition() <<
")");
49 "invalid type specified for parameter 'socket-type' ("
50 << socket_type->getPosition() <<
")");
52 socket_type_ = socket_type->stringValue();
53 if ((socket_type_ !=
"unix")) {
55 << socket_type_ <<
"' not 'unix'");
60 list<string> bad_keywords = {
61 "socket-address",
"socket-port",
"authentication",
62 "trust-anchor",
"cert-file",
"key-file",
"cert-required",
65 for (
auto const& keyword : bad_keywords) {
66 if (
config->contains(keyword)) {
68 "parameter '" << keyword <<
"' is not supported by UNIX "
80 isc_throw(DhcpConfigError,
81 "invalid type specified for parameter 'socket-name' ("
82 << socket_name->getPosition() <<
")");
86 socket_name_ = validatePath(socket_name->stringValue());
87 } catch (
const std::exception& ex) {
112 const std::string explicit_path ) {
113 if (!socket_path_checker_ || reset) {
114 socket_path_checker_.reset(
new PathChecker(CONTROL_SOCKET_DIR,
115 "KEA_CONTROL_SOCKET_DIR"));
116 if (!explicit_path.empty()) {
117 socket_path_checker_->getPath(
true, explicit_path);
121 return (socket_path_checker_->getPath());
126 if (!socket_path_checker_) {
130 std::string valid_path;
132 valid_path = socket_path_checker_->validatePath(socket_path);
140 auto parent_path = socket_path_checker_->getPath();
143 std::ostringstream oss;
144 oss <<
"socket path:" << parent_path
145 <<
" does not exist or has more relaxed permissions than "
static ElementPtr create(const Position &pos=ZERO_POSITION())
Create a NullElement.
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.
mode_t getPermissions(const std::string path)
Fetches the file permissions mask.
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.