diff options
author | AKalinich-Luxoft <AKalinich@luxoft.com> | 2017-12-11 10:32:31 +0200 |
---|---|---|
committer | AKalinich-Luxoft <AKalinich@luxoft.com> | 2017-12-12 13:55:10 +0200 |
commit | 64b69a56b7aa1b6ece996a9c8f1332098a1f5e62 (patch) | |
tree | 2127116c3168bb8e52172eb6419774e2155c39aa | |
parent | 9e95f67178c575ca5a537f9ef3a69653219b073d (diff) | |
download | sdl_core-64b69a56b7aa1b6ece996a9c8f1332098a1f5e62.tar.gz |
Fix PTU apply for applications with default permissions
There was a problem in PROPRIETARY flow that SDL does not
update permissions for applications with default policies
after PTU if application functional group was updated
indirectly (through updating of "default" section).
Also SDL does not send OnPermissionChange notification in
described above case.
This fix adds extra check if "default" functional group
was updated and there are registered applications with
default policies group and also updates them. Similar
check was added for sending OnPermissionChange notification.
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; } |