From: Zofia Abramowska Date: Thu, 7 Apr 2016 10:57:01 +0000 (+0200) Subject: Return error when private sharing doesn't exist X-Git-Tag: accepted/tizen/common/20160627.191623~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F69%2F65169%2F5;p=platform%2Fcore%2Fsecurity%2Fsecurity-manager.git Return error when private sharing doesn't exist Change-Id: Ib2f79da356c9b6830afe0654e79f70b627842ec4 --- diff --git a/src/common/service_impl.cpp b/src/common/service_impl.cpp index a14491f..65b7bf9 100644 --- a/src/common/service_impl.cpp +++ b/src/common/service_impl.cpp @@ -140,6 +140,13 @@ bool isTizen2XVersion(const std::string &version) return false; } +bool sharingExists(const std::string &targetAppName, const std::string &path) +{ + int targetPathCount; + PrivilegeDb::getInstance().GetTargetPathSharingCount(targetAppName, path, targetPathCount); + return targetPathCount != 0; +} + class ScopedTransaction { public: ScopedTransaction() : m_isCommited(false) { @@ -1297,6 +1304,11 @@ int ServiceImpl::dropPrivatePathSharing( } for(const auto &path : paths) { + if (!sharingExists(targetAppName, path)) { + LogError("Sharing doesn't exist: owner=" << ownerAppName + << ", target=" << targetAppName << ", path=" << path); + return SECURITY_MANAGER_ERROR_INPUT_PARAM; + } std::string pathLabel = SmackLabels::getSmackLabelFromPath(path); if (pathLabel != SmackLabels::generatePkgLabel(ownerPkgName)) { std::string generatedPathLabel = SmackLabels::generateSharedPrivateLabel(ownerPkgName, path);