From 843c5318b4c6bc3e87cd12eac79d436e02ef0946 Mon Sep 17 00:00:00 2001 From: Zofia Abramowska Date: Fri, 13 Jan 2017 14:47:39 +0100 Subject: [PATCH] Unify method names in CynaraAdmin to pascal case Change-Id: I42dbad2e0e0f54140036e2c5e8e53b9acd425d4b --- src/common/cynara.cpp | 64 ++++++++++++++++++++++----------------------- src/common/include/cynara.h | 30 ++++++++++----------- src/common/service_impl.cpp | 36 ++++++++++++------------- 3 files changed, 65 insertions(+), 65 deletions(-) diff --git a/src/common/cynara.cpp b/src/common/cynara.cpp index ad714f5..06b7fb2 100644 --- a/src/common/cynara.cpp +++ b/src/common/cynara.cpp @@ -285,7 +285,7 @@ CynaraAdmin::~CynaraAdmin() cynara_admin_finish(m_cynaraAdmin); } -void CynaraAdmin::SetPolicies(const std::vector &policies) +void CynaraAdmin::setPolicies(const std::vector &policies) { if (policies.empty()) { LogDebug("no policies to set in Cynara."); @@ -313,7 +313,7 @@ void CynaraAdmin::SetPolicies(const std::vector &policies) "Error while updating Cynara policy."); } -void CynaraAdmin::UpdateAppPolicy( +void CynaraAdmin::updateAppPolicy( const std::string &label, bool global, uid_t uid, @@ -328,7 +328,7 @@ void CynaraAdmin::UpdateAppPolicy( cynaraUser = std::to_string(static_cast(uid)); // 1st, performing operation on MANIFESTS bucket - CalculatePolicies(label, cynaraUser, privileges, Buckets.at(Bucket::MANIFESTS), + calculatePolicies(label, cynaraUser, privileges, Buckets.at(Bucket::MANIFESTS), static_cast(CynaraAdminPolicy::Operation::Allow), policies); @@ -348,7 +348,7 @@ void CynaraAdmin::UpdateAppPolicy( std::vector users; if (cynaraUser == CYNARA_ADMIN_WILDCARD) { // perform bucket setting for all users in the system, app is installed for everyone - ListUsers(users); + listUsers(users); } else { // local single user installation, do it only for that particular user users.push_back(uid); @@ -364,22 +364,22 @@ void CynaraAdmin::UpdateAppPolicy( if (priv.hasAttribute(PrivilegeInfo::PrivilegeAttr::BLACKLIST)) blacklistPrivileges.push_back(p); } - CalculatePolicies(label, std::to_string(id), privacyPrivileges, + calculatePolicies(label, std::to_string(id), privacyPrivileges, Buckets.at(Bucket::PRIVACY_MANAGER), askUserPolicy, policies); - CalculatePolicies(label, std::to_string(id), blacklistPrivileges, + calculatePolicies(label, std::to_string(id), blacklistPrivileges, Buckets.at(Bucket::ADMIN), static_cast(CynaraAdminPolicy::Operation::Deny), policies); } - SetPolicies(policies); + setPolicies(policies); } -void CynaraAdmin::GetAppPolicy(const std::string &label, const std::string &user, +void CynaraAdmin::getAppPolicy(const std::string &label, const std::string &user, std::vector &privileges) { std::vector policies; - ListPolicies( + listPolicies( CynaraAdmin::Buckets.at(Bucket::MANIFESTS), label, user, CYNARA_ADMIN_ANY, policies); @@ -390,7 +390,7 @@ void CynaraAdmin::GetAppPolicy(const std::string &label, const std::string &user } } -void CynaraAdmin::UserInit(uid_t uid, security_manager_user_type userType) +void CynaraAdmin::userInit(uid_t uid, security_manager_user_type userType) { Bucket bucket; std::vector policies; @@ -425,7 +425,7 @@ void CynaraAdmin::UserInit(uid_t uid, security_manager_user_type userType) Buckets.at(Bucket::MAIN))); std::vector appPolicies; - ListPolicies(CynaraAdmin::Buckets.at(Bucket::MANIFESTS), + listPolicies(CynaraAdmin::Buckets.at(Bucket::MANIFESTS), CYNARA_ADMIN_ANY, CYNARA_ADMIN_WILDCARD, CYNARA_ADMIN_ANY, appPolicies); @@ -467,13 +467,13 @@ void CynaraAdmin::UserInit(uid_t uid, security_manager_user_type userType) } - SetPolicies(policies); + setPolicies(policies); } -void CynaraAdmin::ListUsers(std::vector &listOfUsers) +void CynaraAdmin::listUsers(std::vector &listOfUsers) { std::vector tmpListOfUsers; - ListPolicies( + listPolicies( CynaraAdmin::Buckets.at(Bucket::MAIN), CYNARA_ADMIN_WILDCARD, CYNARA_ADMIN_ANY, @@ -494,20 +494,20 @@ void CynaraAdmin::ListUsers(std::vector &listOfUsers) LogDebug("Found users: " << listOfUsers.size()); }; -void CynaraAdmin::UserRemove(uid_t uid) +void CynaraAdmin::userRemove(uid_t uid) { std::vector policies; std::string user = std::to_string(static_cast(uid)); - EmptyBucket(Buckets.at(Bucket::PRIVACY_MANAGER),true, + emptyBucket(Buckets.at(Bucket::PRIVACY_MANAGER),true, CYNARA_ADMIN_ANY, user, CYNARA_ADMIN_ANY); } -security_manager_user_type CynaraAdmin::GetUserType(uid_t uid) +security_manager_user_type CynaraAdmin::getUserType(uid_t uid) { std::string uidStr = std::to_string(uid); std::vector tmpListOfUsers; - ListPolicies( + listPolicies( CynaraAdmin::Buckets.at(Bucket::MAIN), CYNARA_ADMIN_WILDCARD, uidStr, @@ -536,7 +536,7 @@ security_manager_user_type CynaraAdmin::GetUserType(uid_t uid) return SM_USER_TYPE_NONE; }; -void CynaraAdmin::ListPolicies( +void CynaraAdmin::listPolicies( const std::string &bucket, const std::string &label, const std::string &user, @@ -560,7 +560,7 @@ void CynaraAdmin::ListPolicies( } -void CynaraAdmin::EmptyBucket(const std::string &bucketName, bool recursive, const std::string &client, +void CynaraAdmin::emptyBucket(const std::string &bucketName, bool recursive, const std::string &client, const std::string &user, const std::string &privilege) { checkCynaraError( @@ -570,7 +570,7 @@ void CynaraAdmin::EmptyBucket(const std::string &bucketName, bool recursive, con client + ", " + user + ", " + privilege); } -void CynaraAdmin::FetchCynaraPolicyDescriptions(bool forceRefresh) +void CynaraAdmin::fetchCynaraPolicyDescriptions(bool forceRefresh) { struct cynara_admin_policy_descr **descriptions = nullptr; @@ -610,7 +610,7 @@ void CynaraAdmin::FetchCynaraPolicyDescriptions(bool forceRefresh) } -void CynaraAdmin::CalculatePolicies(const std::string &label, const std::string &user, +void CynaraAdmin::calculatePolicies(const std::string &label, const std::string &user, const std::vector &privileges, const std::string &bucket, int policyToSet, std::vector &policies) @@ -618,7 +618,7 @@ void CynaraAdmin::CalculatePolicies(const std::string &label, const std::string std::vector oldPolicies; std::unordered_set privilegesSet(privileges.begin(), privileges.end()); - ListPolicies(bucket, label, user, CYNARA_ADMIN_ANY, oldPolicies); + listPolicies(bucket, label, user, CYNARA_ADMIN_ANY, oldPolicies); // Compare previous policies with set of new requested privileges for (auto &policy : oldPolicies) { if (privilegesSet.erase(policy.privilege)) { @@ -642,9 +642,9 @@ void CynaraAdmin::CalculatePolicies(const std::string &label, const std::string } } -void CynaraAdmin::ListPoliciesDescriptions(std::vector &policiesDescriptions) +void CynaraAdmin::listPoliciesDescriptions(std::vector &policiesDescriptions) { - FetchCynaraPolicyDescriptions(false); + fetchCynaraPolicyDescriptions(false); for (const auto &it : s_typeToDescription) policiesDescriptions.push_back(it.second); @@ -652,19 +652,19 @@ void CynaraAdmin::ListPoliciesDescriptions(std::vector &policiesDes std::string CynaraAdmin::convertToPolicyDescription(const int policyType, bool forceRefresh) { - FetchCynaraPolicyDescriptions(forceRefresh); + fetchCynaraPolicyDescriptions(forceRefresh); return s_typeToDescription.at(policyType); } int CynaraAdmin::convertToPolicyType(const std::string &policy, bool forceRefresh) { - FetchCynaraPolicyDescriptions(forceRefresh); + fetchCynaraPolicyDescriptions(forceRefresh); return s_descriptionToType.at(policy); } -void CynaraAdmin::Check(const std::string &label, const std::string &user, const std::string &privilege, +void CynaraAdmin::check(const std::string &label, const std::string &user, const std::string &privilege, const std::string &bucket, int &result, std::string &resultExtra, const bool recursive) { char *resultExtraCstr = nullptr; @@ -683,24 +683,24 @@ void CynaraAdmin::Check(const std::string &label, const std::string &user, const } } -int CynaraAdmin::GetPrivilegeManagerCurrLevel(const std::string &label, const std::string &user, +int CynaraAdmin::getPrivilegeManagerCurrLevel(const std::string &label, const std::string &user, const std::string &privilege) { int result; std::string resultExtra; - Check(label, user, privilege, Buckets.at(Bucket::PRIVACY_MANAGER), result, resultExtra, true); + check(label, user, privilege, Buckets.at(Bucket::PRIVACY_MANAGER), result, resultExtra, true); return result; } -int CynaraAdmin::GetPrivilegeManagerMaxLevel(const std::string &label, const std::string &user, +int CynaraAdmin::getPrivilegeManagerMaxLevel(const std::string &label, const std::string &user, const std::string &privilege) { int result; std::string resultExtra; - Check(label, user, privilege, Buckets.at(Bucket::MAIN), result, resultExtra, true); + check(label, user, privilege, Buckets.at(Bucket::MAIN), result, resultExtra, true); return result; } diff --git a/src/common/include/cynara.h b/src/common/include/cynara.h index f2643fd..ec2b4eb 100644 --- a/src/common/include/cynara.h +++ b/src/common/include/cynara.h @@ -120,7 +120,7 @@ public: * * @param policies vector of CynaraAdminPolicy objects to send to Cynara */ - void SetPolicies(const std::vector &policies); + void setPolicies(const std::vector &policies); /** * Update Cynara policies for the application and the user. @@ -133,7 +133,7 @@ public: * @param uid user identifier * @param privileges currently enabled privileges */ - void UpdateAppPolicy(const std::string &label, bool global, uid_t uid, + void updateAppPolicy(const std::string &label, bool global, uid_t uid, const std::vector &privileges); /** @@ -144,7 +144,7 @@ public: * @param[in] user user identifier * @param[out] privileges currently enabled privileges */ - void GetAppPolicy(const std::string &label, const std::string &user, + void getAppPolicy(const std::string &label, const std::string &user, std::vector &privileges); /** @@ -156,21 +156,21 @@ public: * @param uid new user uid * @param userType type as enumerated in security-manager.h */ - void UserInit(uid_t uid, security_manager_user_type userType); + void userInit(uid_t uid, security_manager_user_type userType); /** * List all users registered in Cynara * * @param listOfUsers empty vector for list of users */ - void ListUsers(std::vector &listOfUsers); + void listUsers(std::vector &listOfUsers); /** * Removes all entries for a user from cynara database * * @param uid removed user uid */ - void UserRemove(uid_t uid); + void userRemove(uid_t uid); /** * Returns user type of given uid @@ -180,7 +180,7 @@ public: * @return security_manager_user_type for given uid or SM_USER_TYPE_NONE if user not found * */ - security_manager_user_type GetUserType(uid_t uid); + security_manager_user_type getUserType(uid_t uid); /** * List Cynara policies that match selected criteria in given bucket. @@ -192,7 +192,7 @@ public: * @param policies empty vector for results of policies filtering. * */ - void ListPolicies(const std::string &bucketName, + void listPolicies(const std::string &bucketName, const std::string &label, const std::string &user, const std::string &privilege, @@ -206,7 +206,7 @@ public: * * @param policiesDescriptions empty vector for policies descriptions. */ - void ListPoliciesDescriptions(std::vector &policiesDescriptions); + void listPoliciesDescriptions(std::vector &policiesDescriptions); /** * Function translates internal Cynara policy type integer to string @@ -250,7 +250,7 @@ public: * @param recursive flag to indicate if check should be done recursively in * all buckets linked with bucket provided */ - void Check(const std::string &label, + void check(const std::string &label, const std::string &user, const std::string &privilege, const std::string &bucket, @@ -268,7 +268,7 @@ public: * @param privilege privilege identifier * @return current policy value */ - int GetPrivilegeManagerCurrLevel(const std::string &label, const std::string &user, + int getPrivilegeManagerCurrLevel(const std::string &label, const std::string &user, const std::string &privilege); /** @@ -282,7 +282,7 @@ public: * @param privilege privilege identifier * @return maximum policy value for PRIVACY_MANAGER bucket */ - int GetPrivilegeManagerMaxLevel(const std::string &label, const std::string &user, + int getPrivilegeManagerMaxLevel(const std::string &label, const std::string &user, const std::string &privilege); private: @@ -295,7 +295,7 @@ private: * @param user user name * @param privilege privilege name */ - void EmptyBucket(const std::string &bucketName, bool recursive, + void emptyBucket(const std::string &bucketName, bool recursive, const std::string &client, const std::string &user, const std::string &privilege); /** @@ -303,7 +303,7 @@ private: * * @param forceRefresh true if you want to reinitialize mappings */ - void FetchCynaraPolicyDescriptions(bool forceRefresh = false); + void fetchCynaraPolicyDescriptions(bool forceRefresh = false); /** * Calculate actual Cynara policy based on appilcation data & previous policy @@ -315,7 +315,7 @@ private: * @param policyToSet policy effect to be set * @param policies current policy (input/output parameter) */ - void CalculatePolicies(const std::string &label, const std::string &user, + void calculatePolicies(const std::string &label, const std::string &user, const std::vector &privileges, const std::string &bucket, int policyToSet, std::vector &policies); diff --git a/src/common/service_impl.cpp b/src/common/service_impl.cpp index bc66995..2681700 100644 --- a/src/common/service_impl.cpp +++ b/src/common/service_impl.cpp @@ -525,7 +525,7 @@ int ServiceImpl::appInstall(const Credentials &creds, app_inst_req &&req) bool global = req.installationType == SM_APP_INSTALL_GLOBAL || req.installationType == SM_APP_INSTALL_PRELOADED; - m_cynaraAdmin.UpdateAppPolicy(appLabel, global, req.uid, req.privileges); + m_cynaraAdmin.updateAppPolicy(appLabel, global, req.uid, req.privileges); if (hasSharedRO) m_priviligeDb.SetSharedROPackage(req.pkgName); @@ -694,7 +694,7 @@ int ServiceImpl::appUninstall(const Credentials &creds, app_inst_req &&req) bool global = req.installationType == SM_APP_INSTALL_GLOBAL || req.installationType == SM_APP_INSTALL_PRELOADED; - m_cynaraAdmin.UpdateAppPolicy(processLabel, global, req.uid, std::vector()); + m_cynaraAdmin.updateAppPolicy(processLabel, global, req.uid, std::vector()); trans.commit(); LogDebug("Application uninstallation commited to database"); @@ -801,8 +801,8 @@ int ServiceImpl::getAppGroups(const Credentials &creds, const std::string &appNa std::vector privileges; std::string uidStr = std::to_string(creds.uid); - m_cynaraAdmin.GetAppPolicy(appProcessLabel, uidStr, privileges); - m_cynaraAdmin.GetAppPolicy(appProcessLabel, CYNARA_ADMIN_WILDCARD, privileges); + m_cynaraAdmin.getAppPolicy(appProcessLabel, uidStr, privileges); + m_cynaraAdmin.getAppPolicy(appProcessLabel, CYNARA_ADMIN_WILDCARD, privileges); vectorRemoveDuplicates(privileges); @@ -848,7 +848,7 @@ int ServiceImpl::userAdd(const Credentials &creds, uid_t uidAdded, int userType) return SECURITY_MANAGER_ERROR_AUTHENTICATION_FAILED; } try { - m_cynaraAdmin.UserInit(uidAdded, static_cast(userType)); + m_cynaraAdmin.userInit(uidAdded, static_cast(userType)); PermissibleSet::initializeUserPermissibleFile(uidAdded); } catch (CynaraException::InvalidParam &e) { return SECURITY_MANAGER_ERROR_INPUT_PARAM; @@ -913,7 +913,7 @@ int ServiceImpl::userDelete(const Credentials &creds, uid_t uidDeleted) } } - m_cynaraAdmin.UserRemove(uidDeleted); + m_cynaraAdmin.userRemove(uidDeleted); return ret; } @@ -938,7 +938,7 @@ int ServiceImpl::policyUpdate(const Credentials &creds, const std::vector listOfPrivileges; - m_cynaraAdmin.GetAppPolicy(appProcessLabel, userStr, listOfPrivileges); - m_cynaraAdmin.GetAppPolicy(appProcessLabel, CYNARA_ADMIN_WILDCARD, listOfPrivileges); + m_cynaraAdmin.getAppPolicy(appProcessLabel, userStr, listOfPrivileges); + m_cynaraAdmin.getAppPolicy(appProcessLabel, CYNARA_ADMIN_WILDCARD, listOfPrivileges); if (filter.privilege.compare(SECURITY_MANAGER_ANY)) { LogDebug("Limitting Cynara query to privilege: " << filter.privilege); @@ -1171,11 +1171,11 @@ int ServiceImpl::getPolicy(const Credentials &creds, const policy_entry &filter, pe.privilege = privilege; pe.currentLevel = m_cynaraAdmin.convertToPolicyDescription( - m_cynaraAdmin.GetPrivilegeManagerCurrLevel( + m_cynaraAdmin.getPrivilegeManagerCurrLevel( appProcessLabel, userStr, privilege)); pe.maxLevel = m_cynaraAdmin.convertToPolicyDescription( - m_cynaraAdmin.GetPrivilegeManagerMaxLevel( + m_cynaraAdmin.getPrivilegeManagerMaxLevel( appProcessLabel, userStr, privilege)); LogDebug( @@ -1213,7 +1213,7 @@ int ServiceImpl::policyGetDesc(std::vector &levels) int ret = SECURITY_MANAGER_SUCCESS; try { - m_cynaraAdmin.ListPoliciesDescriptions(levels); + m_cynaraAdmin.listPoliciesDescriptions(levels); } catch (const CynaraException::OutOfMemory &e) { LogError("Error - out of memory while querying Cynara for policy descriptions list: " << e.DumpToString()); return SECURITY_MANAGER_ERROR_MEMORY; @@ -1250,7 +1250,7 @@ int ServiceImpl::policyGroupsForUid(uid_t uid, std::vector &groups) int ret = SECURITY_MANAGER_SUCCESS; try { - auto userType = m_cynaraAdmin.GetUserType(uid); + auto userType = m_cynaraAdmin.getUserType(uid); if (userType == SM_USER_TYPE_NONE) { return SECURITY_MANAGER_ERROR_NO_SUCH_OBJECT; @@ -1283,7 +1283,7 @@ int ServiceImpl::policyGroupsForUid(uid_t uid, std::vector &groups) m_priviligeDb.GetGroupsRelatedPrivileges(group2privVector); for (const auto &g2p : group2privVector) { - m_cynaraAdmin.Check(CYNARA_ADMIN_ANY, uidStr, g2p.second, + m_cynaraAdmin.check(CYNARA_ADMIN_ANY, uidStr, g2p.second, bucket, result, resultExtra, true); if (result == CYNARA_ADMIN_ALLOW) groups.push_back(g2p.first); -- 2.7.4