diff options
author | JackLivio <jack@livio.io> | 2018-01-16 14:57:06 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-16 14:57:06 -0500 |
commit | 77ff65fe0a710bd01257d4b0ad6cc14913cbb644 (patch) | |
tree | 0e25c5f87ed7da71e8a6f1bc6bc9d70e2821014d | |
parent | 0b19cf498d1c9972d67b85793dc6b029c26378a0 (diff) | |
parent | 64b69a56b7aa1b6ece996a9c8f1332098a1f5e62 (diff) | |
download | sdl_core-77ff65fe0a710bd01257d4b0ad6cc14913cbb644.tar.gz |
Merge pull request #1966 from AKalinich-Luxoft/fix/fix_default_permissions_apply_after_ptu
Fix PTU apply for applications with default permissions
3 files changed, 39 insertions, 6 deletions
diff --git a/src/components/policy/policy_regular/include/policy/policy_helper.h b/src/components/policy/policy_regular/include/policy/policy_helper.h index 996c2917d0..8a60801dd4 100644 --- a/src/components/policy/policy_regular/include/policy/policy_helper.h +++ b/src/components/policy/policy_regular/include/policy/policy_helper.h @@ -114,7 +114,8 @@ struct CheckAppPolicy { const std::vector<FunctionalGroupPermission>& revoked_groups) const; bool IsKnownAppication(const std::string& application_id) const; void NotifySystem(const AppPoliciesValueType& app_policy) const; - void SendPermissionsToApp(const AppPoliciesValueType& app_policy) const; + void SendPermissionsToApp(const std::string& app_id, + const policy_table::Strings& groups) const; bool IsAppRevoked(const AppPoliciesValueType& app_policy) const; bool NicknamesMatch(const AppPoliciesValueType& app_policy) const; /** diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index 98652656c3..12b29e0675 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -83,6 +83,21 @@ struct LanguageFinder { const std::string& language_; }; +struct PolicyTableUpdater { + PolicyTableUpdater(const policy_table::ApplicationParams& default_params) + : default_params_(default_params) {} + + void operator()(policy_table::ApplicationPolicies::value_type& pt_value) { + if (policy::kDefaultId == pt_value.second.get_string()) { + pt_value.second = default_params_; + pt_value.second.set_to_string(policy::kDefaultId); + } + } + + private: + const policy_table::ApplicationParams& default_params_; +}; + CacheManager::CacheManager() : CacheManagerInterface() , pt_(new policy_table::Table) @@ -244,6 +259,11 @@ bool CacheManager::ApplyUpdate(const policy_table::Table& update_pt) { ""); } else { pt_->policy_table.app_policies_section.apps[iter->first] = iter->second; + if (kDefaultId == iter->first) { + std::for_each(pt_->policy_table.app_policies_section.apps.begin(), + pt_->policy_table.app_policies_section.apps.end(), + PolicyTableUpdater(iter->second)); + } } } diff --git a/src/components/policy/policy_regular/src/policy_helper.cc b/src/components/policy/policy_regular/src/policy_helper.cc index b72a041a83..782a65f91a 100644 --- a/src/components/policy/policy_regular/src/policy_helper.cc +++ b/src/components/policy/policy_regular/src/policy_helper.cc @@ -267,9 +267,7 @@ void policy::CheckAppPolicy::NotifySystem( } void CheckAppPolicy::SendPermissionsToApp( - const AppPoliciesValueType& app_policy) const { - const std::string app_id = app_policy.first; - + const std::string& app_id, const policy_table::Strings& groups) const { const std::string device_id = pm_->GetCurrentDeviceId(app_id); if (device_id.empty()) { LOG4CXX_WARN(logger_, @@ -281,7 +279,7 @@ void CheckAppPolicy::SendPermissionsToApp( Permissions notification_data; pm_->PrepareNotificationData(update_->policy_table.functional_groupings, - app_policy.second.groups, + groups, group_permissons, notification_data); @@ -356,6 +354,20 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) { "Permissions for application:" << app_id << " have been changed."); + if (IsPredefinedApp(app_policy)) { + for (const policy_table::ApplicationPolicies::value_type& app : + snapshot_->policy_table.app_policies_section.apps) { + if (app_policy.first == app.second.get_string()) { + if (RESULT_CONSENT_NOT_REQIURED != result) { + SetPendingPermissions(app, result); + NotifySystem(app); + } + SendPermissionsToApp(app.first, app_policy.second.groups); + } + } + return true; + } + if (!IsPredefinedApp(app_policy) && RESULT_CONSENT_NOT_REQIURED != result) { SetPendingPermissions(app_policy, result); NotifySystem(app_policy); @@ -363,7 +375,7 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) { // Don't sent notification for predefined apps (e.g. default, device etc.) if (!IsPredefinedApp(app_policy)) { - SendPermissionsToApp(app_policy); + SendPermissionsToApp(app_policy.first, app_policy.second.groups); } return true; } |