/*
- * Copyright (c) 2017 - 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2017 - 2020 Samsung Electronics Co., Ltd All Rights Reserved
*
* Contact: Tomasz Swierczek <t.swierczek@samsung.com>
*
int Worker::doWork(const NSMountLogic::EntryVector &entries)
{
int status = 0;
- bool inGlobalNamespace = false;
+ bool inGlobalNamespace = true;
for (auto &entry : entries) {
try {
- // in most cases entry.uid will not change between iterations
- auto storagePrivilegePathMap = MountNS::getPrivilegePathMap(entry.uid);
-
- if (!inGlobalNamespace && MountNS::enterMountNamespace(MountNS::MAIN_MOUNT_NAMESPACE)) {
- inGlobalNamespace = true;
- }
-
- if (!inGlobalNamespace) {
- LogError("Error entering global mount namespace. Environment of application: "
- << entry.smackLabel << " will not be setup correctly.");
- continue;
- }
-
- if (MountNS::enterMountNamespace(MountNS::getUserAppServiceMountPointPath(entry.uid, entry.smackLabel, entry.pid))) {
+ auto appNamespace = MountNS::getUserAppServiceMountPointPath(entry.uid, entry.smackLabel, entry.pid);
+ if (MountNS::enterMountNamespace(appNamespace)) {
inGlobalNamespace = false;
} else {
+ status = -1;
+ LogError("Error entering app mount namespace. Environment of application: "
+ << entry.smackLabel << "for user: " << entry.uid << " will not be setup correctly.");
continue;
}
+ // in most cases entry.uid will not change between iterations
+ auto storagePrivilegePathMap = MountNS::getPrivilegePathMap(entry.uid);
for (auto &privStatus : entry.privilegeStatusVector) {
auto &privName = privStatus.first;
auto &allowed = privStatus.second;
"directory " << privilegePath.dstPath << " doesn't exist");
continue;
}
- if (SECURITY_MANAGER_SUCCESS != applyPrivilegePath(allowed, privilegePath))
+ if (SECURITY_MANAGER_SUCCESS != applyPrivilegePath(allowed, privilegePath)) {
status = -1;
+ LogError("Environment of application: " << entry.smackLabel << "for user: "
+ << entry.uid << " will not be setup correctly.");
+ }
}
}
} catch (...) {
status = -1;
- LogError("Could not set up access to path for application: " << entry.smackLabel);
+ LogError("Environment of application: " << entry.smackLabel << "for user: "
+ << entry.uid << " will not be setup correctly.");
+ }
+
+ if (!inGlobalNamespace && !MountNS::enterMountNamespace(MountNS::MAIN_MOUNT_NAMESPACE)) {
+ status = -1;
+ LogError("Error entering global mount namespace.");
}
}
return status;