Fix: disallow installing apps with the same id in different packages 37/31337/2
authorJan Cybulski <j.cybulski@samsung.com>
Wed, 3 Dec 2014 11:18:04 +0000 (12:18 +0100)
committerJan Cybulski <j.cybulski@samsung.com>
Thu, 4 Dec 2014 08:13:37 +0000 (00:13 -0800)
Change-Id: I04fca4edcd265e2853a9ce146e6dcc95d1f92dc9
Signed-off-by: Jan Cybulski <j.cybulski@samsung.com>
src/client/client-security-manager.cpp
src/common/service_impl.cpp

index 1e03d36..34f4576 100644 (file)
@@ -200,6 +200,8 @@ int security_manager_app_install(const app_inst_req *p_req)
                 return SECURITY_MANAGER_SUCCESS;
             case SECURITY_MANAGER_API_ERROR_AUTHENTICATION_FAILED:
                 return SECURITY_MANAGER_ERROR_AUTHENTICATION_FAILED;
+            case SECURITY_MANAGER_API_ERROR_INPUT_PARAM:
+                return SECURITY_MANAGER_ERROR_INPUT_PARAM;
             default:
                 return SECURITY_MANAGER_ERROR_UNKNOWN;
         }
index fe7982d..718868d 100644 (file)
@@ -168,6 +168,14 @@ int appInstall(const app_inst_req &req, uid_t uid)
                  << ", uidstr " << uidstr << ", generated smack label: " << smackLabel);
 
         PrivilegeDb::getInstance().BeginTransaction();
+
+        std::string pkg;
+        bool ret = PrivilegeDb::getInstance().GetAppPkgId(req.appId, pkg);
+        if (ret == true && pkg != req.pkgId) {
+            LogError("Application already installed with different package id");
+            PrivilegeDb::getInstance().RollbackTransaction();
+            return SECURITY_MANAGER_API_ERROR_INPUT_PARAM;
+        }
         PrivilegeDb::getInstance().GetPkgPrivileges(req.pkgId, uid, oldPkgPrivileges);
         PrivilegeDb::getInstance().AddApplication(req.appId, req.pkgId, uid, pkgIdIsNew);
         PrivilegeDb::getInstance().UpdateAppPrivileges(req.appId, uid, req.privileges);