New socket command will be accessible only for processes with 'User' label.
Change-Id: If07a28e7382a14dcce3a33c905e489b0422203d9
GROUPS_FOR_UID,
LABEL_FOR_PROCESS,
SHM_APP_NAME,
+ PATHS_GET_SENSITIVE,
NOOP = 0x90,
};
int shmAppName(const Credentials &creds,
const std::string &shmName,
const std::string &appName);
+
+ /*
+ * Retrieve a list of sensitive directories for given package
+ *
+ * @param[in] creds credentials of the requesting process
+ * @param[in] pkgName package identifier
+ * @param[out] paths vector of paths to sensitive directories
+ *
+ * @return API return code, as defined in protocols.h
+ */
+ int getSensitiveDirs(const Credentials &creds,
+ const std::string &pkgName,
+ std::vector<std::string> &paths);
private:
bool authenticate(const Credentials &creds, const std::string &privilege);
return SECURITY_MANAGER_SUCCESS;
}
+int ServiceImpl::getSensitiveDirs(const Credentials &creds,
+ const std::string &pkgName,
+ std::vector<std::string> &paths)
+{
+ try {
+ // TODO: Ask cynara for permission (User label -> read sensitive paths)
+ if (creds.label != "User") {
+ LogError("Request from uid=" << creds.uid << ", Smack=" << creds.label <<
+ " for list of sensitive directories denied");
+ return SECURITY_MANAGER_ERROR_AUTHENTICATION_FAILED;
+ }
+
+ ScopedTransaction trans(m_priviligeDb);
+
+ if(!m_priviligeDb.PkgNameExists(pkgName)) {
+ LogError("Package " << pkgName << " does not exist");
+ return SECURITY_MANAGER_ERROR_INPUT_PARAM;
+ }
+
+ m_priviligeDb.GetSensitiveDirs(pkgName, creds.uid, paths);
+
+ return SECURITY_MANAGER_SUCCESS;
+ } catch (const PrivilegeDb::Exception::Base &e) {
+ LogError("Error while querying db for sensitive directories: " << e.DumpToString());
+ return SECURITY_MANAGER_ERROR_SERVER_ERROR;
+ } catch (const std::bad_alloc &e) {
+ LogError("Memory allocation failed: " << e.what());
+ return SECURITY_MANAGER_ERROR_MEMORY;
+ } catch (const std::exception &e) {
+ LogError("Some exception thrown: " << e.what());
+ return SECURITY_MANAGER_ERROR_UNKNOWN;
+ } catch (...) {
+ LogError("Unknown exception thrown");
+ return SECURITY_MANAGER_ERROR_UNKNOWN;
+ }
+}
+
} /* namespace SecurityManager */
* @param creds credentials of the requesting process
*/
void processShmAppName(MessageBuffer &recv, MessageBuffer &send, const Credentials &creds);
+
+ /**
+ * Process get sensitive dirs request
+ *
+ * @param recv Raw received data buffer
+ * @param send Raw data buffer to be sent
+ * @param creds credentials of the requesting process
+ */
+ void processGetSensitiveDirs(MessageBuffer &recv, MessageBuffer &send, const Credentials &creds);
};
} // namespace SecurityManager
case SecurityModuleCall::SHM_APP_NAME:
processShmAppName(buffer, send, creds);
break;
+ case SecurityModuleCall::PATHS_GET_SENSITIVE:
+ processGetSensitiveDirs(buffer, send, creds);
+ break;
default:
LogError("Invalid call: " << call_type_int);
Throw(ServiceException::InvalidAction);
Serialization::Serialize(send, ret);
}
+void Service::processGetSensitiveDirs(MessageBuffer &recv, MessageBuffer &send, const Credentials &creds)
+{
+ std::string appName;
+ Deserialization::Deserialize(recv, appName);
+ std::vector<std::string> paths;
+ int ret = serviceImpl.getSensitiveDirs(creds, appName, paths);
+ Serialization::Serialize(send, ret);
+ if (ret == SECURITY_MANAGER_SUCCESS)
+ Serialization::Serialize(send, paths);
+}
+
} // namespace SecurityManager