23#include <flow/error/error.hpp>
35 using boost::system::system_category;
41 if (flow::error::exec_void_and_throw_on_error
44 err_code,
"session::ensure_resource_owner_is_app(1)"))
50 FLOW_LOG_SET_CONTEXT(logger_ptr, Log_component::S_SESSION);
57 int native_handle = open(path.c_str(), O_PATH);
58 if (native_handle == -1)
60 *err_code =
Error_code(errno, system_category());
61 FLOW_LOG_WARNING(
"Tried to check ownership of resource at [" << path <<
"] but while obtaining info-only handle "
62 "encountered error [" << *err_code <<
"] [" << err_code->message() <<
"]; unable to check.");
72 FLOW_LOG_WARNING(
"Check of ownership of resource at [" << path <<
"], upon successfully opening probe-only "
73 "descriptor/handle, resulted in error in checking or "
74 "unexpected ownership; see preceding WARNING referencing all other details.");
83 using boost::system::system_category;
90 if (flow::error::exec_void_and_throw_on_error
93 err_code,
"session::ensure_resource_owner_is_app(2)"))
99 assert((!handle.
null()) &&
"Disallowed per contract.");
101 FLOW_LOG_SET_CONTEXT(logger_ptr, Log_component::S_SESSION);
108 *err_code =
Error_code(errno, system_category());
109 FLOW_LOG_WARNING(
"Tried to check ownership via descriptor/handle [" << handle <<
"] but encountered "
110 "error [" << *err_code <<
"] [" << err_code->message() <<
"]; unable to check.");
115 FLOW_LOG_WARNING(
"Checked ownership via descriptor/handle [" << handle <<
"] but encountered "
116 "error [" << *err_code <<
"] [" << err_code->message() <<
"]; unable to check.");
126 return os <<
'[' << val.
m_name <<
"] "
131 return os << static_cast<const App&>(val);
136 using boost::algorithm::join;
138 return os << static_cast<const App&>(val) <<
" allowed_cli_apps[" << join(val.
m_allowed_client_apps,
" ") <<
']';
@ S_RESOURCE_OWNER_UNEXPECTED
A resource in the file system (file, SHM pool, MQ, etc.) has or could have unexpected owner; ipc::ses...
Flow-IPC module providing the broad lifecycle and shared-resource organization – via the session conc...
void ensure_resource_owner_is_app(flow::log::Logger *logger_ptr, const fs::path &path, const App &app, Error_code *err_code)
Utility, used internally but exposed in public API in case it is of general use, that checks that the...
std::ostream & operator<<(std::ostream &os, const App &val)
Prints string representation of the given App to the given ostream.
util::Native_handle Native_handle
Convenience alias for the commonly used type util::Native_handle.
flow::Error_code Error_code
Short-hand for flow::Error_code which is very common.
A description of an application in this ipc::session inter-process communication universe.
util::group_id_t m_group_id
The application must run as this group ID (GID). Files and other shared resources shall have this own...
std::string m_name
Brief application name, readable to humans and unique across all other applications' names; used both...
util::user_id_t m_user_id
The application must run as this user ID (UID). Files and other shared resources shall have this owne...
fs::path m_exec_path
Absolute, lexically normalized canonical path to the executable entity (which is not a directory),...
An App that is used as a client in at least one client-server IPC split.
An App that is used as a server in at least one client-server IPC split.
Client_app_set m_allowed_client_apps
A given Client_app (as identified by its distinct App::m_name) may request to establish an IPC sessio...
A monolayer-thin wrapper around a native handle, a/k/a descriptor a/k/a FD.
bool null() const
Returns true if and only if m_native_handle equals S_NULL_HANDLE.
handle_t m_native_handle
The native handle (possibly equal to S_NULL_HANDLE), the exact payload of this Native_handle.