if (!p_req || !path || (path_type < 0) || (path_type >= SECURITY_MANAGER_ENUM_END))
return SECURITY_MANAGER_ERROR_INPUT_PARAM;
- p_req->appPaths.push_back(std::make_pair(path, path_type));
+ p_req->pkgPaths.push_back(std::make_pair(path, path_type));
return SECURITY_MANAGER_SUCCESS;
}
p_req->appName,
p_req->pkgName,
p_req->privileges,
- p_req->appPaths,
+ p_req->pkgPaths,
p_req->uid,
p_req->tizenVersion,
p_req->authorName,
LogDebug("Wrong paths size: " << paths.size());
return false;
}
- req.appPaths.clear();
+ req.pkgPaths.clear();
for (std::vector<std::string>::size_type i = 1; i < paths.size(); i += 2) {
app_install_path_type pathType;
LogDebug("path: " << paths[i - 1]);
} catch (const std::out_of_range &e) {
std::cout << "Invalid path type found." << std::endl;
LogError("Invalid path type found.");
- req.appPaths.clear();
+ req.pkgPaths.clear();
return false;
}
LogDebug("path type: " << pathType << " (" << paths[i] << ")");
- req.appPaths.push_back(std::make_pair(paths[i - 1], pathType));
+ req.pkgPaths.push_back(std::make_pair(paths[i - 1], pathType));
}
- return (!req.appPaths.empty());
+ return (!req.pkgPaths.empty());
}
static void parseInstallOptions(int argc, char *argv[],
#include <dpl/serialization.h>
#include <security-manager-types.h>
+typedef std::vector<std::pair<std::string, int>> pkg_paths;
+
struct app_inst_req {
std::string appName;
std::string pkgName;
std::vector<std::string> privileges;
- std::vector<std::pair<std::string, int>> appPaths;
+ pkg_paths pkgPaths;
uid_t uid;
std::string tizenVersion;
std::string authorName;
std::vector<std::string> paths;
};
+struct path_req {
+ std::string pkgName;
+ uid_t uid;
+ pkg_paths pkgPaths;
+ int installationType = SM_APP_INSTALL_NONE;
+};
+
namespace SecurityManager {
extern char const * const SERVICE_SOCKET;
correctPath.append("/").append(req.pkgName);
LogDebug("correctPath: " << correctPath);
- for (const auto &path : req.appPaths) {
+ for (const auto &path : req.pkgPaths) {
std::unique_ptr<char, std::function<void(void*)>> real_path(
realpath(path.first.c_str(), NULL), free);
if (!real_path.get()) {
}
try {
- if (!req.appPaths.empty())
+ if (!req.pkgPaths.empty())
SmackLabels::setupAppBasePath(req.pkgName, appPath);
// register paths
- for (const auto &appPath : req.appPaths) {
+ for (const auto &appPath : req.pkgPaths) {
const std::string &path = appPath.first;
app_install_path_type pathType = static_cast<app_install_path_type>(appPath.second);
SmackLabels::setupPath(req.pkgName, path, pathType, authorId);
*/
int security_manager_app_uninstall(const app_inst_req *p_req);
+/*
+ * This function is responsible for initialize path_req data structure. It uses
+ * dynamic allocation inside and user responsibility is to call
+ * security_manager_path_req_free() for freeing allocated resources.
+ *
+ * \param[in] pp_req Address of pointer for handle path_req structure
+ * \return API return code or error code
+ */
+int security_manager_path_req_new(path_req **pp_req);
+
+/*
+ * This function is used to free resources allocated by calling
+ * security_manager_path_req_new().
+ * \param[in] p_req Pointer handling allocated path_req structure
+ */
+void security_manager_path_req_free(path_req *p_req);
+
+/*
+ * This function is used to set up package identifier in path_req structure.
+ *
+ * \param[in] p_req Pointer handling path_req structure
+ * \param[in] pkg_id Package identifier
+ * \return API return code or error code
+ */
+int security_manager_path_req_set_pkg_id(path_req *p_req, const char *pkg_id);
+
+/*
+ * This function is used to set up installation type (global, local, preloaded).
+ * If type is not set and if installation is performed by global user, type is set to
+ * 'SM_APP_INSTALL_GLOBAL'. Otherwise installation type is set to 'SM_APP_INSTALL_LOCAL'.
+ *
+ * \param[in] p_req Pointer handling path_req structure
+ * \param[in] type Installation type
+ * \return API return code or error code
+ */
+int security_manager_path_req_set_install_type(path_req *p_req, const enum app_install_type type);
+
+/*
+ * This function is used to add a package path to path_req structure. It can be
+ * called multiple times.
+ *
+ * \param[in] p_req Pointer handling path_req structure
+ * \param[in] path Package path
+ * \param[in] path_type Package path type
+ * \return API return code or error code
+ */
+int security_manager_path_req_add_path(path_req *p_req, const char *path, const int path_type);
+
+/*
+ * This function is used to set up user identifier in path_req structure.
+ * This field simplifies support for online and offline modes.
+ *
+ * \param[in] p_req Pointer handling path_req structure
+ * \param[in] uid User identifier (UID)
+ * \return API return code or error code
+ */
+int security_manager_path_req_set_uid(path_req *p_req, const uid_t uid);
+
+/*
+ * This function is used to register a set of paths for given package using
+ * filled up path_req data structure.
+ *
+ * Required privileges:
+ * - http://tizen.org/privilege/notexist (if uid is not set or set to current user's uid)
+ * - http://tizen.org/privilege/notexist (if uid is set to some other user's uid)
+ *
+ * \param[in] p_req Pointer handling path_req structure
+ *
+ * \return API return code or error code: it would be
+ * - SECURITY_MANAGER_SUCCESS on success,
+ * - SECURITY_MANAGER_ERROR_AUTHENTICATION_FAILED when user does not
+ * have rights to install requested directories,
+ * - SECURITY_MANAGER_ERROR_UNKNOWN on other errors.
+ */
+int security_manager_paths_register(const path_req *p_req);
+
#ifdef __cplusplus
}
#endif
struct private_sharing_req;
typedef struct private_sharing_req private_sharing_req;
+/*! brief data structure responsible for handling informations required to register
+ * a set of paths for given package. */
+struct path_req;
+typedef struct path_req path_req;
+
/*! \brief wildcard to be used in requests to match all possible values of given field.
* Use it, for example when it is desired to list or apply policy change for all
* users or all apps for selected user.
Deserialization::Deserialize(buffer, req.appName);
Deserialization::Deserialize(buffer, req.pkgName);
Deserialization::Deserialize(buffer, req.privileges);
- Deserialization::Deserialize(buffer, req.appPaths);
+ Deserialization::Deserialize(buffer, req.pkgPaths);
Deserialization::Deserialize(buffer, req.uid);
Deserialization::Deserialize(buffer, req.tizenVersion);
Deserialization::Deserialize(buffer, req.authorName);