MCPcopy Create free account
hub / github.com/COVESA/vsomeip / update_security_policy

Method update_security_policy

implementation/security/src/policy_manager_impl.cpp:414–460  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

412}
413
414void policy_manager_impl::update_security_policy(uid_t _uid, gid_t _gid, const std::shared_ptr<policy>& _policy) {
415
416 std::unique_lock its_lock(any_client_policies_mutex_);
417 std::shared_ptr<policy> its_matching_policy;
418 for (auto p : any_client_policies_) {
419 std::scoped_lock its_guard(p->mutex_);
420 if (p->credentials_.size() == 1) {
421 const auto its_uids = *(p->credentials_.begin());
422 if (its_uids.first.lower() == _uid && its_uids.first.upper() == _uid) {
423 if (its_uids.second.size() == 1) {
424 const auto its_gids = *(its_uids.second.begin());
425 if (its_gids.lower() == _gid && its_gids.upper() == _gid) {
426 if (p->allow_who_ == _policy->allow_who_) {
427 its_matching_policy = p;
428 break;
429 }
430 }
431 }
432 }
433 }
434 }
435
436 if (its_matching_policy) {
437 std::scoped_lock its_guard{its_matching_policy->mutex_};
438 for (const auto& r : _policy->requests_) {
439 service_t its_lower, its_upper;
440 get_bounds(r.first, its_lower, its_upper);
441 for (auto s = its_lower; s <= its_upper; s++) {
442 boost::icl::discrete_interval<service_t> its_service(s, s, boost::icl::interval_bounds::closed());
443 its_matching_policy->requests_ += std::make_pair(its_service, r.second);
444 }
445 }
446 for (const auto& o : _policy->offers_) {
447 service_t its_lower, its_upper;
448 get_bounds(o.first, its_lower, its_upper);
449 for (auto s = its_lower; s <= its_upper; s++) {
450 boost::icl::discrete_interval<service_t> its_service(s, s, boost::icl::interval_bounds::closed());
451 its_matching_policy->offers_ += std::make_pair(its_service, o.second);
452 }
453 }
454 } else {
455 any_client_policies_.push_back(_policy);
456 }
457
458 std::unique_lock its_cache_lock(is_client_allowed_cache_mutex_);
459 is_client_allowed_cache_.erase(std::make_pair(_uid, _gid));
460}
461
462void policy_manager_impl::add_security_credentials(uid_t _uid, gid_t _gid, const std::shared_ptr<policy>& _policy, client_t _client) {
463

Callers 3

TESTFunction · 0.80
on_messageMethod · 0.80

Calls 3

get_boundsFunction · 0.85
beginMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected