From: Radoslaw Bartosiak Date: Wed, 8 Mar 2017 17:24:59 +0000 (+0100) Subject: Change labelPaths logic for FOTA X-Git-Tag: submit/tizen/20170405.143506~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eef8e3795e8635ea1f5955e5bc12d404bdfec5a5;p=platform%2Fcore%2Fsecurity%2Fsecurity-manager.git Change labelPaths logic for FOTA pkgBasePath is labeled only if there is at least one path argument for labelPaths that points to pkgBasePath. Change-Id: I81763a8a38aa89700e87daf708a5e85c37b6dd20 Signed-off-by: Radoslaw Bartosiak --- diff --git a/src/common/include/service_impl.h b/src/common/include/service_impl.h index 46c9f24..bc75e50 100644 --- a/src/common/include/service_impl.h +++ b/src/common/include/service_impl.h @@ -256,6 +256,8 @@ private: static bool isSubDir(const std::string &parent, const std::string &subdir); + static bool containSubDir(const std::string &parent, const pkg_paths &paths); + static bool getUserPkgDir(const uid_t &uid, const std::string &pkgName, app_install_type installType, diff --git a/src/common/service_impl.cpp b/src/common/service_impl.cpp index 2681700..bec0060 100644 --- a/src/common/service_impl.cpp +++ b/src/common/service_impl.cpp @@ -263,6 +263,16 @@ bool ServiceImpl::isSubDir(const std::string &parent, const std::string &subdir) return (*str2 == '/' || *str1 == *str2); } +bool ServiceImpl::containSubDir(const std::string &parent, const pkg_paths &paths) +{ + + for(auto path : paths) { + if (isSubDir(parent, path.first)) + return true; + } + return false; +} + std::string ServiceImpl::realPath(const std::string &path) { auto real_pathPtr = makeUnique(realpath(path.c_str(), nullptr), free); @@ -417,7 +427,7 @@ int ServiceImpl::labelPaths(const pkg_paths &paths, if (!pathsOK) return SECURITY_MANAGER_ERROR_AUTHENTICATION_FAILED; - if (!paths.empty()) + if (containSubDir(pkgBasePath, paths)) SmackLabels::setupPkgBasePath(pkgBasePath); // register paths