#include "mount-namespace.h"
static const char *EMPTY = "";
+static const std::string SMACK_SYSTEM = "System";
+static std::string SMACK_SYSTEM_PRIVILEGED = "System::Privileged";
/**
* Mapping of lib_retcode error codes to theirs strings equivalents
return SECURITY_MANAGER_SUCCESS;
});
}
+
+SECURITY_MANAGER_API
+int security_manager_set_identity(
+ process_type type,
+ const char *app_id = nullptr)
+{
+ security_manager_pre_check();
+ switch (type) {
+ case (process_type::SYSTEM):
+ if (smack_set_label_for_self(SMACK_SYSTEM.c_str()) != 0) {
+ LogError("Failed to set smack label" << SMACK_SYSTEM << "for current process");
+ return SECURITY_MANAGER_ERROR_UNKNOWN;
+ }
+ return SECURITY_MANAGER_SUCCESS;
+ case (process_type::SYSTEM_PRIVILEGED):
+ if (smack_set_label_for_self(SMACK_SYSTEM_PRIVILEGED.c_str()) != 0) {
+ LogError("Failed to set smack label" << SMACK_SYSTEM_PRIVILEGED << "for current process");
+ return SECURITY_MANAGER_ERROR_UNKNOWN;
+ }
+ return SECURITY_MANAGER_SUCCESS;
+ case (process_type::APP):
+ return security_manager_set_process_label_from_appid(app_id);
+ }
+
+ return SECURITY_MANAGER_SUCCESS;
+}
uid_t uid,
char **license);
+/**
+ * Set credential of calling thread to one of system-roles or an application based on app name.
+ *
+ * When process identifier is incorrect or not related to any package, this function will
+ * return SECURITY_MANAGER_ERROR_NO_SUCH_OBJECT.
+ *
+ * \param[in] type Type of process
+ * \param[in] app_id Application id of the application
+ * \return API return code or error code
+ */
+int security_manager_set_identity(process_type type,
+ const char *app_id);
+
#ifdef __cplusplus
}
#endif
};
typedef enum app_defined_privilege_type app_defined_privilege_type;
+/**
+ * This enum defines the process type.
+ */
+ enum process_type {
+ SYSTEM = 0,
+ SYSTEM_PRIVILEGED,
+ APP,
+ };
+typedef enum process_type process_type;
+
/*! \brief data structure responsible for handling informations
* required to install / uninstall application */
struct app_inst_req;