/**
* Process checking application's privilege access based on app_name
*
+ * @param[in] creds credentials of the caller
* @param[in] appName application identifier
* @param[in] privilege privilege name
* @param[in] uid user identifier
*
* @return API return code, as defined in protocols.h
*/
- int appHasPrivilege(std::string appName, std::string privilege, uid_t uid, bool &result);
+ int appHasPrivilege(const Credentials &creds, const std::string appName, const std::string privilege, uid_t uid, bool &result);
/**
* Process applying private path sharing between applications.
}
int ServiceImpl::appHasPrivilege(
- std::string appName,
- std::string privilege,
+ const Credentials &creds,
+ const std::string appName,
+ const std::string privilege,
uid_t uid,
bool &result)
{
try {
std::string appProcessLabel = getAppProcessLabel(appName);
+ if ((appProcessLabel != creds.label || creds.uid != uid)
+ && !authenticate(creds, PRIVILEGE_POLICY_USER)
+ && !authenticate(creds, PRIVILEGE_PERMISSION_CHECK)) {
+ LogError("Not enough privilege to access other process policies");
+ return SECURITY_MANAGER_ERROR_ACCESS_DENIED;
+ }
std::string uidStr = std::to_string(uid);
result = m_cynara.check(appProcessLabel, privilege, uidStr, "");
LogDebug("result = " << result);
* - 0: access denied
* - 1: access granted
*
+ * Required privileges:
+ * for checking policy for the caller application process:
+ * - none
+ * for checking policy for other application process:
+ * - http://tizen.org/privilege/notexist or http://tizen.org/privilege/permission.check
+ *
* \param[in] app_id Application identifier
* \param[in] privilege Privilege name
* \param[in] uid User identifier
*
* @param recv Raw received data buffer
* @param send Raw data buffer to be sent
+ * @param creds credentials of the requesting process
*/
- void processAppHasPrivilege(MessageBuffer &recv, MessageBuffer &send);
+ void processAppHasPrivilege(MessageBuffer &recv, MessageBuffer &send, const Credentials &creds);
/**
* Process applying private path sharing between applications.
break;
case SecurityModuleCall::APP_HAS_PRIVILEGE:
LogDebug("call_type: SecurityModuleCall::APP_HAS_PRIVILEGE");
- processAppHasPrivilege(buffer, send);
+ processAppHasPrivilege(buffer, send, creds);
break;
case SecurityModuleCall::APP_APPLY_PRIVATE_SHARING:
LogDebug("call_type: SecurityModuleCall::APP_APPLY_PRIVATE_SHARING");
}
}
-void Service::processAppHasPrivilege(MessageBuffer &recv, MessageBuffer &send)
+void Service::processAppHasPrivilege(MessageBuffer &recv, MessageBuffer &send, const Credentials &creds)
{
std::string appName;
std::string privilege;
Deserialization::Deserialize(recv, uid);
bool result;
- int ret = serviceImpl.appHasPrivilege(appName, privilege, uid, result);
+ int ret = serviceImpl.appHasPrivilege(creds, appName, privilege, uid, result);
Serialization::Serialize(send, ret);
if (ret == SECURITY_MANAGER_SUCCESS)