| 320 | |
| 321 | #ifndef VSOMEIP_DISABLE_SECURITY |
| 322 | void configuration_impl::lazy_load_security(const std::string& _client_host) { |
| 323 | |
| 324 | std::string its_folder = policy_manager_->get_policy_extension_path(_client_host); |
| 325 | if (its_folder.empty()) { |
| 326 | return; // nothing to do, host does not exist |
| 327 | } |
| 328 | |
| 329 | if (policy_manager_->is_policy_extension_loaded(_client_host) == policy_manager_impl::policy_loaded_e::POLICY_PATH_FOUND_AND_LOADED) { |
| 330 | return; // nothing to do, host already loaded |
| 331 | } |
| 332 | |
| 333 | std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now(); |
| 334 | |
| 335 | std::set<std::string> its_input{its_folder}; |
| 336 | std::set<std::string> its_failed; |
| 337 | std::vector<configuration_element> its_mandatory_elements; |
| 338 | |
| 339 | // load security configuration files from UID_GID sub folder if existing |
| 340 | std::string its_security_config_folder = policy_manager_->get_security_config_folder(its_folder); |
| 341 | if (!its_security_config_folder.empty()) |
| 342 | its_input.insert(its_security_config_folder); |
| 343 | |
| 344 | read_data(its_input, its_mandatory_elements, its_failed, true, true); |
| 345 | |
| 346 | for (const auto& e : its_mandatory_elements) { |
| 347 | policy_manager_->load(e, true); |
| 348 | } |
| 349 | |
| 350 | for (auto f : its_failed) { |
| 351 | VSOMEIP_WARNING_P << "Reading of configuration file \"" << f << "\" failed. Configuration may be incomplete"; |
| 352 | } |
| 353 | |
| 354 | policy_manager_->set_is_policy_extension_loaded(_client_host, true); |
| 355 | |
| 356 | std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now(); |
| 357 | |
| 358 | #if defined(__linux__) || defined(__QNX__) |
| 359 | uid_t uid = getuid(); |
| 360 | gid_t gid = getgid(); |
| 361 | #else |
| 362 | uid_t uid = 0; |
| 363 | gid_t gid = 0; |
| 364 | #endif |
| 365 | |
| 366 | VSOMEIP_INFO << "vSomeIP Security: Loaded security policies for host: " << _client_host << " at UID/GID: " << uid << "/" << gid |
| 367 | << " in " << std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count() << "ms"; |
| 368 | } |
| 369 | #endif // !VSOMEIP_DISABLE_SECURITY |
| 370 | |
| 371 | bool configuration_impl::check_routing_credentials(client_t _client, const vsomeip_sec_client_t* _sec_client) const { |
no test coverage detected