return true;
}
-int ServiceImpl::labelPaths(const pkg_paths &paths,
- const std::string &pkgName,
- app_install_type installationType,
- const uid_t &uid,
- bool isSharedRO)
+int ServiceImpl::labelPaths(path_req& req, bool isSharedRO)
{
try {
if (!smack_simple_check()) {
LogWarning("Running in no-smack mode, not labeling any paths");
- if (!m_privilegeDb.PkgNameExists(pkgName)) {
- LogError("No such package: " << pkgName);
+ if (!m_privilegeDb.PkgNameExists(req.pkgName)) {
+ LogError("No such package: " << req.pkgName);
return SECURITY_MANAGER_ERROR_INPUT_PARAM;
}
return SECURITY_MANAGER_SUCCESS;
}
std::string authorHash;
- m_privilegeDb.GetPkgAuthorHash(pkgName, authorHash);
+ m_privilegeDb.GetPkgAuthorHash(req.pkgName, authorHash);
std::string homePath, skelDir;
std::vector<std::string> pkgLegalBaseDirs;
- int ret = getLegalPkgBaseDirs(uid, pkgName, installationType, homePath,
+ int ret = getLegalPkgBaseDirs(req.uid, req.pkgName, static_cast<app_install_type>(req.installationType), homePath,
skelDir, pkgLegalBaseDirs, isSharedRO, m_offline);
if (ret != SECURITY_MANAGER_SUCCESS) {
LogError("Failed to generate legal directories for application");
LogWarning("Determinig if paths are legal");
// check if paths are inside of legal directories
- if (!pathsCheck(paths, pkgLegalBaseDirs))
+ if (!pathsCheck(req.pkgPaths, pkgLegalBaseDirs))
return SECURITY_MANAGER_ERROR_NOT_PATH_OWNER;
if (smack_simple_check() && isSharedRO) {
LogWarning("Labeling shared_ro paths");
// Label shared_ro base paths for bind mounting
- labelSharedPaths(homePath, pkgName);
+ labelSharedPaths(homePath, req.pkgName);
// If there are corresponding paths in skel, label them too
if (!skelDir.empty())
- labelSharedPaths(skelDir, pkgName);
+ labelSharedPaths(skelDir, req.pkgName);
}
// register paths
LogWarning("Labeling other paths");
- for (const auto &pkgPath : paths) {
+ for (const auto &pkgPath : req.pkgPaths) {
const std::string &path = pkgPath.first;
app_install_path_type pathType = static_cast<app_install_path_type>(pkgPath.second);
- SmackLabels::setupPath(pkgName, path, pathType, authorHash);
+ SmackLabels::setupPath(req.pkgName, path, pathType, authorHash);
}
LogWarning("Labeling base paths");
for (const auto &basePath : pkgLegalBaseDirs) {
- if (containSubDir(basePath, paths)) {
+ if (containSubDir(basePath, req.pkgPaths)) {
SmackLabels::setupPkgBasePath(basePath);
}
}
// label paths
LogWarning("Configuring package paths");
- ret = labelPaths(req.pkgPaths,
- req.pkgName,
- static_cast<app_install_type>(req.installationType),
- req.uid,
- isAppSharedRO);
+ ret = labelPaths(req, isAppSharedRO);
if (ret != SECURITY_MANAGER_SUCCESS)
return ret;
// label paths
LogWarning("Configuring package paths");
- ret = labelPaths(req.pkgPaths,
- req.pkgName,
- static_cast<app_install_type>(req.installationType),
- req.uid,
- isAppSharedRO);
+ ret = labelPaths(req, isAppSharedRO);
if (ret != SECURITY_MANAGER_SUCCESS)
return ret;
return SECURITY_MANAGER_ERROR_SERVER_ERROR;
}
- return labelPaths(req.pkgPaths,
- req.pkgName,
- static_cast<app_install_type>(req.installationType),
- req.uid,
- isRequestSharedRO);
+ return labelPaths(req, isRequestSharedRO);
}
int ServiceImpl::shmAppName(const Credentials &creds, const std::string &shmName, const std::string &appName)