| 375 | } |
| 376 | |
| 377 | bool policy_manager_impl::remove_security_policy(uid_t _uid, gid_t _gid) { |
| 378 | std::unique_lock its_lock(any_client_policies_mutex_); |
| 379 | bool was_removed(false); |
| 380 | if (!any_client_policies_.empty()) { |
| 381 | std::vector<std::shared_ptr<policy>>::iterator p_it = any_client_policies_.begin(); |
| 382 | while (p_it != any_client_policies_.end()) { |
| 383 | bool is_matching(false); |
| 384 | { |
| 385 | std::scoped_lock its_policy_lock((*p_it)->mutex_); |
| 386 | bool has_uid(false), has_gid(false); |
| 387 | const auto found_uid = (*p_it)->credentials_.find(_uid); |
| 388 | has_uid = (found_uid != (*p_it)->credentials_.end()); |
| 389 | if (has_uid) { |
| 390 | const auto found_gid = found_uid->second.find(_gid); |
| 391 | has_gid = (found_gid != found_uid->second.end()); |
| 392 | } |
| 393 | |
| 394 | // only remove "credentials allow" policies to prevent removal of |
| 395 | // blacklist configured in file |
| 396 | if (has_uid && has_gid && (*p_it)->allow_who_) { |
| 397 | is_matching = true; |
| 398 | } |
| 399 | } |
| 400 | if (is_matching) { |
| 401 | was_removed = true; |
| 402 | p_it = any_client_policies_.erase(p_it); |
| 403 | } else { |
| 404 | ++p_it; |
| 405 | } |
| 406 | |
| 407 | std::unique_lock its_cache_lock(is_client_allowed_cache_mutex_); |
| 408 | is_client_allowed_cache_.erase(std::make_pair(_uid, _gid)); |
| 409 | } |
| 410 | } |
| 411 | return was_removed; |
| 412 | } |
| 413 | |
| 414 | void policy_manager_impl::update_security_policy(uid_t _uid, gid_t _gid, const std::shared_ptr<policy>& _policy) { |
| 415 |
no test coverage detected