Added security_manager_app_inst_req_set_uid function 14/29414/8
authorSebastian Grabowski <s.grabowski@samsung.com>
Mon, 27 Oct 2014 10:55:33 +0000 (11:55 +0100)
committerSebastian Grabowski <s.grabowski@samsung.com>
Wed, 19 Nov 2014 13:18:52 +0000 (14:18 +0100)
Added uid field to app_inst_req structure.

Change-Id: Ida0204549bb4818bcd401b5d62c7e13f7dbc04b2
Signed-off-by: Sebastian Grabowski <s.grabowski@samsung.com>
src/client/client-security-manager.cpp
src/common/include/protocols.h
src/include/security-manager.h
src/server/service/service.cpp

index 51130b6..14fbcbf 100644 (file)
@@ -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);
index 91fbe32..d9c092f 100644 (file)
@@ -25,6 +25,7 @@
 #ifndef _SECURITY_MANAGER_PROTOCOLS_
 #define _SECURITY_MANAGER_PROTOCOLS_
 
+#include <sys/types.h>
 #include <vector>
 #include <string>
 
@@ -105,6 +106,7 @@ struct app_inst_req {
     std::string pkgId;
     std::vector<std::string> privileges;
     std::vector<std::pair<std::string, int>> appPaths;
+    uid_t uid;
 };
 
 namespace SecurityManager {
index 9c54d46..c06b2fb 100644 (file)
@@ -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
  *
index ec19017..32623c0 100644 (file)
@@ -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)) {