int getLegalPkgBaseDirs(const uid_t &uid,
const std::string &pkgName,
app_install_type installType,
+ std::string &homePath,
std::vector<std::string> &legalPkgBaseDirs,
bool isSharedRO);
int authorId;
m_privilegeDb.GetPkgAuthorId(pkgName, authorId);
+ std::string homePath;
std::vector<std::string> pkgLegalBaseDirs;
- int ret = getLegalPkgBaseDirs(uid, pkgName, installationType, pkgLegalBaseDirs, isSharedRO);
+ int ret = getLegalPkgBaseDirs(uid, pkgName, installationType, homePath,
+ pkgLegalBaseDirs, isSharedRO);
if (ret != SECURITY_MANAGER_SUCCESS) {
LogError("Failed to generate legal directories for application");
return ret;
if (!pathsCheck(paths, pkgLegalBaseDirs))
return SECURITY_MANAGER_ERROR_NOT_PATH_OWNER;
+ if (isSharedRO) {
+ // Label shared_ro base paths for bind mounting
+ std::string sharedPath = homePath + ".shared/" + pkgName;
+ std::string sharedTmpPath = homePath + ".shared_tmp/" + pkgName;
+ if (FS::directoryStatus(sharedPath) == 1 && FS::directoryStatus(sharedTmpPath) == 1) {
+ SmackLabels::setupPkgBasePath(sharedPath);
+ SmackLabels::setupPkgBasePath(sharedTmpPath);
+ }
+ }
// register paths
for (const auto &pkgPath : paths) {
const std::string &path = pkgPath.first;
int getLegalPkgBaseDirs(const uid_t &uid,
const std::string &pkgName,
app_install_type installType,
+ std::string &homePath,
std::vector<std::string> &legalPkgDirs,
bool isSharedRO)
{
bool isSdAvailable = false;
bool isSkelAvailable = false;
enum tzplatform_variable baseId;
- enum tzplatform_variable extendedSdId;
+ enum tzplatform_variable extendedSdId = _TZPLATFORM_VARIABLES_INVALID_;
switch (installType) {
case SM_APP_INSTALL_LOCAL:
legalPkgDirs.clear();
- std::string basePath;
- if (!getPath(tpc, baseId, pkgName, basePath)) {
- LogError("Couldn't generate base path");
+ if (!getPath(tpc, baseId, "", homePath)) {
+ LogError("Couldn't generate home path");
return SECURITY_MANAGER_ERROR_UNKNOWN;
}
+ std::string basePath = homePath + pkgName;
+
LogDebug("Base path is : " << basePath);
legalPkgDirs.push_back(std::move(basePath));