From 611a37a343d01d9144431423e4448fc573937982 Mon Sep 17 00:00:00 2001 From: Sebastian Grabowski Date: Mon, 27 Oct 2014 11:55:33 +0100 Subject: [PATCH] Added security_manager_app_inst_req_set_uid function Added uid field to app_inst_req structure. Change-Id: Ida0204549bb4818bcd401b5d62c7e13f7dbc04b2 Signed-off-by: Sebastian Grabowski --- src/client/client-security-manager.cpp | 15 ++++++++++++++- src/common/include/protocols.h | 2 ++ src/include/security-manager.h | 11 +++++++++++ src/server/service/service.cpp | 4 ++++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/client/client-security-manager.cpp b/src/client/client-security-manager.cpp index 51130b6..14fbcbf 100644 --- a/src/client/client-security-manager.cpp +++ b/src/client/client-security-manager.cpp @@ -60,7 +60,7 @@ int security_manager_app_inst_req_new(app_inst_req **pp_req) } catch (std::bad_alloc& ex) { return SECURITY_MANAGER_ERROR_MEMORY; } - + (*pp_req)->uid = 0; return SECURITY_MANAGER_SUCCESS; } @@ -72,6 +72,18 @@ void security_manager_app_inst_req_free(app_inst_req *p_req) } SECURITY_MANAGER_API +int security_manager_app_inst_req_set_uid(app_inst_req *p_req, + const uid_t uid) +{ + if (!p_req) + return SECURITY_MANAGER_ERROR_INPUT_PARAM; + + p_req->uid = uid; + + return SECURITY_MANAGER_SUCCESS; +} + +SECURITY_MANAGER_API int security_manager_app_inst_req_set_app_id(app_inst_req *p_req, const char *app_id) { if (!p_req || !app_id) @@ -134,6 +146,7 @@ int security_manager_app_install(const app_inst_req *p_req) Serialization::Serialize(send, p_req->pkgId); Serialization::Serialize(send, p_req->privileges); Serialization::Serialize(send, p_req->appPaths); + Serialization::Serialize(send, p_req->uid); //send buffer to server int retval = sendToServer(SERVICE_SOCKET, send.Pop(), recv); diff --git a/src/common/include/protocols.h b/src/common/include/protocols.h index 91fbe32..d9c092f 100644 --- a/src/common/include/protocols.h +++ b/src/common/include/protocols.h @@ -25,6 +25,7 @@ #ifndef _SECURITY_MANAGER_PROTOCOLS_ #define _SECURITY_MANAGER_PROTOCOLS_ +#include #include #include @@ -105,6 +106,7 @@ struct app_inst_req { std::string pkgId; std::vector privileges; std::vector> appPaths; + uid_t uid; }; namespace SecurityManager { diff --git a/src/include/security-manager.h b/src/include/security-manager.h index 9c54d46..c06b2fb 100644 --- a/src/include/security-manager.h +++ b/src/include/security-manager.h @@ -116,6 +116,17 @@ int security_manager_app_inst_req_add_privilege(app_inst_req *p_req, const char int security_manager_app_inst_req_add_path(app_inst_req *p_req, const char *path, const int path_type); /* + * This function is used to set up user identifier in app_inst_req structure. + * This field simplifies support for online and offline modes. + * + * \param[in] Pointer handling app_inst_req structure + * \param[in] User identifier (UID) + * \return API return code or error code + */ +int security_manager_app_inst_req_set_uid(app_inst_req *p_req, + const uid_t uid); + +/* * This function is used to install application based on * using filled up app_inst_req data structure * diff --git a/src/server/service/service.cpp b/src/server/service/service.cpp index ec19017..32623c0 100644 --- a/src/server/service/service.cpp +++ b/src/server/service/service.cpp @@ -274,7 +274,11 @@ bool Service::processAppInstall(MessageBuffer &buffer, MessageBuffer &send, uid_ Deserialization::Deserialize(buffer, req.pkgId); Deserialization::Deserialize(buffer, req.privileges); Deserialization::Deserialize(buffer, req.appPaths); + Deserialization::Deserialize(buffer, req.uid); + std::string uidstr; + if ((!uid) && (req.uid)) + uid = req.uid; checkGlobalUser(uid, uidstr); if(!installRequestAuthCheck(req, uid)) { -- 2.7.4