From: Jan Cybulski Date: Wed, 3 Dec 2014 11:18:04 +0000 (+0100) Subject: Fix: disallow installing apps with the same id in different packages X-Git-Tag: accepted/tizen/tv/20150217.004257~43 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fsecurity%2Fsecurity-manager.git;a=commitdiff_plain;h=c4cde288b8198cbc7932bd38e0fa5b219f253c99 Fix: disallow installing apps with the same id in different packages Change-Id: I04fca4edcd265e2853a9ce146e6dcc95d1f92dc9 Signed-off-by: Jan Cybulski --- diff --git a/src/client/client-security-manager.cpp b/src/client/client-security-manager.cpp index 1e03d36..34f4576 100644 --- a/src/client/client-security-manager.cpp +++ b/src/client/client-security-manager.cpp @@ -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; } diff --git a/src/common/service_impl.cpp b/src/common/service_impl.cpp index fe7982d..718868d 100644 --- a/src/common/service_impl.cpp +++ b/src/common/service_impl.cpp @@ -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);