const char kExternalStoragePrivilege[] =
"http://tizen.org/privilege/externalstorage.appdata";
const char kSystemShareGroupName[] = "system_share";
-
+const char kSubssesionDir[] = "subsessions";
// the input path should be root directory of package.
// for example: "../apps_rw/pkgid" or "../.shared/pkgid"
bool SetPackageDirectoryOwnerAndPermissions(const bf::path& path, uid_t uid) {
if (CreateExternalUserDirectories(user, pkgid, storage_apps_path.string()))
return false;
+ for (auto& lw_user : GetLightUserList(user)) {
+ bf::path storage_apps_lw_path = storage_apps_path
+ / kSubssesionDir / lw_user / "apps";
+ if (!bf::exists(storage_apps_lw_path)) {
+ bs::error_code error;
+ bf::create_directories(storage_apps_lw_path, error);
+ if (error) {
+ LOG(ERROR) << "Failed to create directory: "
+ << storage_apps_path.c_str();
+ return false;
+ }
+ }
+
+ if (CreateExternalUserDirectories(user, pkgid,
+ storage_apps_lw_path.string()))
+ return false;
+ }
+
return true;
}
}
bf::path storage_apps_path = bf::path(storage_path) / "apps";
- return DeleteDirectories(
- GetDirectoryPathForStorage(user, storage_apps_path.string()), pkgid);
+ if (!DeleteDirectories(
+ GetDirectoryPathForStorage(user, storage_apps_path.string()), pkgid))
+ return false;
+
+ for (auto& lw_user : GetLightUserList(user)) {
+ bf::path storage_apps_lw_path =
+ storage_apps_path / kSubssesionDir / lw_user / "apps";
+ if (!DeleteDirectories(
+ GetDirectoryPathForStorage(user, storage_apps_lw_path.string()),
+ pkgid))
+ return false;
+ }
+
+ return true;
}
bool PerformExternalDirectoryCreationForAllUsers(const std::string& pkgid) {
UserList list = ci::GetUserList();
for (auto l : list) {
uid_t uid = std::get<0>(l);
- bf::path apps_rw = std::get<2>(l) / "apps_rw";
+ bf::path owner_apps_rw = std::get<2>(l) / "apps_rw";
+ std::vector<bf::path> apps_rw_paths;
+ apps_rw_paths.push_back(std::move(owner_apps_rw));
+
+ for (auto& lw_user : GetLightUserList(uid))
+ apps_rw_paths.push_back(std::get<2>(l)
+ / kSubssesionDir / lw_user / "apps_rw");
+
LOG(DEBUG) << "Creating directories for user: " << uid;
- if (!::CreateStorageDirectories(apps_rw, pkgid, trusted, shareddata,
- additional_dirs)) {
- LOG(ERROR) << "Failed to create storage directory for user: " << uid;
- return false;
- }
+ for (auto& apps_rw : apps_rw_paths) {
+ if (!::CreateStorageDirectories(apps_rw, pkgid, trusted, shareddata,
+ additional_dirs)) {
+ LOG(ERROR) << "Failed to create storage directory for user: " << uid;
+ return false;
+ }
- if (!::SetPackageDirectoryOwnerAndPermissions(apps_rw / pkgid, uid))
- return false;
+ if (!::SetPackageDirectoryOwnerAndPermissions(apps_rw / pkgid, uid))
+ return false;
- if (shareddata) {
- std::vector<std::string> shared_dirs(kSharedDataEntries);
- for (auto entry : shared_dirs) {
- bf::path shared_dst = apps_rw / entry / pkgid;
- if (!::SetPackageDirectoryOwnerAndPermissions(shared_dst, uid))
- return false;
+ if (shareddata) {
+ std::vector<std::string> shared_dirs(kSharedDataEntries);
+ for (auto entry : shared_dirs) {
+ bf::path shared_dst = apps_rw / entry / pkgid;
+ if (!::SetPackageDirectoryOwnerAndPermissions(shared_dst, uid))
+ return false;
+ }
}
- }
- if (!RegisterSecurityContextForPath(pkgid, apps_rw / pkgid, uid,
- false, &error_message)) {
- LOG(ERROR) << "Failed to register security context for path: "
- << apps_rw / pkgid << ", error_message: " << error_message;
- return false;
+ if (!RegisterSecurityContextForPath(pkgid, apps_rw / pkgid, uid, false,
+ &error_message)) {
+ LOG(ERROR) << "Failed to register security context for path: "
+ << apps_rw / pkgid << ", error_message: " << error_message;
+ return false;
+ }
}
}
UserList list = ci::GetUserList();
for (auto l : list) {
uid_t uid = std::get<0>(l);
- bf::path apps_rw = std::get<2>(l) / "apps_rw";
+ bf::path owner_apps_rw = std::get<2>(l) / "apps_rw";
+ std::vector<bf::path> apps_rw_paths;
+ apps_rw_paths.push_back(std::move(owner_apps_rw));
+
+ for (auto& lw_user : GetLightUserList(uid))
+ apps_rw_paths.push_back(std::get<2>(l) / kSubssesionDir / lw_user /
+ "apps_rw");
+
LOG(DEBUG) << "Deleting directories for user: " << uid;
- if (!ci::RemoveAll(apps_rw / pkgid)) {
- LOG(ERROR) << "Failed to delete storage directory for user: " << uid;
- return false;
+ for (auto& apps_rw : apps_rw_paths) {
+ if (!ci::RemoveAll(apps_rw / pkgid)) {
+ LOG(ERROR) << "Failed to delete storage directory for user: " << uid;
+ return false;
+ }
}
+ }
- if (!ci::DeletePerUserSharedDataDir(pkgid)) {
- LOG(ERROR) << "Failed to delete per user shared data dir";
- return false;
- }
+ if (!ci::DeletePerUserSharedDataDir(pkgid)) {
+ LOG(ERROR) << "Failed to delete per user shared data dir";
+ return false;
}
return true;
if (!DeleteDirectories(apps_rw, pkgid)) {
return false;
}
+
+ for (auto& lw_user : GetLightUserList(uid)) {
+ bf::path apps_rw_lw(std::get<2>(l) / kSubssesionDir / lw_user / "apps_rw");
+ if (!DeleteDirectories(apps_rw_lw, pkgid))
+ return false;
+ }
}
+
return true;
}
return false;
}
- bool result = true;
UserList list = ci::GetUserList();
for (auto l : list) {
uid_t uid = std::get<0>(l);
ci::PkgQueryInterface pkg_query(pkgid, uid);
if (pkg_query.IsPackageInstalled())
continue;
- bf::path apps_rw(std::get<2>(l) / "apps_rw");
- bf::path dst_dir = apps_rw / pkgid;
- if (!bf::exists(dst_dir)) {
- LOG(WARNING) << "dst_dir not exists";
- continue;
+
+ bf::path owner_apps_rw = std::get<2>(l) / "apps_rw";
+ std::vector<bf::path> apps_rw_paths;
+ apps_rw_paths.push_back(std::move(owner_apps_rw));
+
+ for (auto& lw_user : GetLightUserList(uid))
+ apps_rw_paths.push_back(std::get<2>(l) / kSubssesionDir / lw_user /
+ "apps_rw");
+
+ for (auto& apps_rw : apps_rw_paths) {
+ bf::path dst_dir = apps_rw / pkgid;
+ if (!bf::exists(dst_dir)) {
+ LOG(WARNING) << "dst_dir not exists";
+ continue;
+ }
+
+ if (!CreateSymlinkFiles(src_dir, dst_dir))
+ return false;
}
- result = CreateSymlinkFiles(src_dir, dst_dir);
}
- return result;
+
+ return true;
}
bool CreateGlobalAppSymlinksForUser(const std::string& pkgid, uid_t uid) {
return true;
}
- bool result = true;
UserList list = ci::GetUserList();
for (auto l : list) {
uid_t uid = std::get<0>(l);
LOG(DEBUG) << "Deleting symlinks for uid: " << uid;
+
// check installed user private app.
ci::PkgQueryInterface pkg_query(pkgid, uid);
if (pkg_query.IsPackageInstalled())
continue;
- bf::path apps_rw(std::get<2>(l) / "apps_rw");
- bf::path dst_dir = apps_rw / pkgid;
- if (!bf::exists(dst_dir)) {
- LOG(WARNING) << "dst_dir not exists";
- continue;
+
+ bf::path owner_apps_rw = std::get<2>(l) / "apps_rw";
+ std::vector<bf::path> apps_rw_paths;
+ apps_rw_paths.push_back(std::move(owner_apps_rw));
+ for (auto& lw_user : GetLightUserList(uid))
+ apps_rw_paths.push_back(std::get<2>(l) / kSubssesionDir / lw_user /
+ "apps_rw");
+
+ for (auto& apps_rw : apps_rw_paths) {
+ bf::path dst_dir = apps_rw / pkgid;
+ if (!bf::exists(dst_dir)) {
+ LOG(WARNING) << "dst_dir not exists";
+ continue;
+ }
+
+ if (!DeleteSymlinkFiles(src_dir, dst_dir))
+ return false;
}
- result = DeleteSymlinkFiles(src_dir, dst_dir);
}
- return result;
+
+ return true;
}
bool DeleteGlobalAppSymlinksForUser(const std::string& pkgid, uid_t uid) {
uid_t uid = std::get<0>(l);
LOG(DEBUG) << "Adding shareddata directory for uid: " << uid;
- bf::path apps_rw = ci::GetRootAppPath(false, uid);
- if (!CreateSharedDataDirectories(apps_rw, pkgid))
- return false;
+ bf::path owner_apps_rw = ci::GetRootAppPath(false, uid);
+ std::vector<bf::path> apps_rw_paths;
+ apps_rw_paths.push_back(std::move(owner_apps_rw));
+ for (auto& lw_user : GetLightUserList(uid))
+ apps_rw_paths.push_back(std::get<2>(l) / kSubssesionDir / lw_user /
+ "apps_rw");
- std::vector<std::string> shared_dirs(kSharedDataEntries);
- for (auto entry : shared_dirs) {
- bf::path shared_dst = apps_rw / entry / pkgid;
- if (!::SetPackageDirectoryOwnerAndPermissions(shared_dst, uid))
+ for (auto& apps_rw : apps_rw_paths) {
+ if (!CreateSharedDataDirectories(apps_rw, pkgid))
return false;
- }
- if (!ci::RegisterSecurityContextForPath(pkgid, apps_rw / pkgid, uid,
- false, &error_message)) {
- LOG(ERROR) << "Failed to register security context for path: "
- << apps_rw / pkgid << ", error_message: " << error_message;
- return false;
+ std::vector<std::string> shared_dirs(kSharedDataEntries);
+ for (auto entry : shared_dirs) {
+ bf::path shared_dst = apps_rw / entry / pkgid;
+ if (!::SetPackageDirectoryOwnerAndPermissions(shared_dst, uid))
+ return false;
+ }
+
+ if (!ci::RegisterSecurityContextForPath(pkgid, apps_rw / pkgid, uid,
+ false, &error_message)) {
+ LOG(ERROR) << "Failed to register security context for path: "
+ << apps_rw / pkgid << ", error_message: " << error_message;
+ return false;
+ }
}
}
ci::UserList list = ci::GetUserList();
for (auto l : list) {
uid_t uid = std::get<0>(l);
- bf::path apps_rw = ci::GetRootAppPath(false, uid);
- if (!DeleteSharedDataDirectories(apps_rw, pkgid))
- return false;
- }
+ bf::path owner_apps_rw = ci::GetRootAppPath(false, uid);
+ std::vector<bf::path> apps_rw_paths;
+ apps_rw_paths.push_back(std::move(owner_apps_rw));
+ for (auto& lw_user : GetLightUserList(uid))
+ apps_rw_paths.push_back(std::get<2>(l) / kSubssesionDir / lw_user /
+ "apps_rw");
+
+ for (auto& apps_rw : apps_rw_paths) {
+ if (!DeleteSharedDataDirectories(apps_rw, pkgid))
+ return false;
+ }
+ }
return true;
}
ci::UserList list = ci::GetUserList();
for (auto l : list) {
uid_t uid = std::get<0>(l);
- if (!BackupSharedDataDir(pkgid, uid))
- return false;
+ bf::path owner_apps_rw = ci::GetRootAppPath(false, uid);
+ std::vector<bf::path> apps_rw_paths;
+ apps_rw_paths.push_back(std::move(owner_apps_rw));
+ for (auto& lw_user : GetLightUserList(uid))
+ apps_rw_paths.push_back(std::get<2>(l) / kSubssesionDir / lw_user /
+ "apps_rw");
+
+ for (auto& apps_rw : apps_rw_paths) {
+ if (!BackupSharedDataDirectories(apps_rw, pkgid))
+ return false;
+ }
}
return true;
ci::UserList list = ci::GetUserList();
for (auto l : list) {
uid_t uid = std::get<0>(l);
- if (!RestoreSharedDataDir(pkgid, uid))
- return false;
+ bf::path owner_apps_rw = ci::GetRootAppPath(false, uid);
+ std::vector<bf::path> apps_rw_paths;
+ apps_rw_paths.push_back(std::move(owner_apps_rw));
+ for (auto& lw_user : GetLightUserList(uid))
+ apps_rw_paths.push_back(std::get<2>(l) / kSubssesionDir / lw_user /
+ "apps_rw");
+
+ for (auto& apps_rw : apps_rw_paths) {
+ if (!RestoreSharedDataDirectories(apps_rw, pkgid))
+ return false;
+ }
}
return true;
ci::UserList list = ci::GetUserList();
for (auto l : list) {
uid_t uid = std::get<0>(l);
- if (!RemoveBackupSharedDataDir(pkgid, uid))
- return false;
+ bf::path owner_apps_rw = ci::GetRootAppPath(false, uid);
+ std::vector<bf::path> apps_rw_paths;
+ apps_rw_paths.push_back(std::move(owner_apps_rw));
+ for (auto& lw_user : GetLightUserList(uid))
+ apps_rw_paths.push_back(std::get<2>(l) / kSubssesionDir / lw_user /
+ "apps_rw");
+
+ for (auto& apps_rw : apps_rw_paths) {
+ if (!RemoveBackupSharedDataDirectories(apps_rw, pkgid))
+ return false;
+ }
}
return true;
#include <cassert>
#include <cstring>
#include <string>
+#include <utility>
#include <vector>
#include "common/utils/paths.h"
const char kShared[] = ".shared";
const char kSharedTmp[] = ".shared_tmp";
const char kSystemShareGroupName[] = "system_share";
+const char kSubssesionDir[] = "subsessions";
const uid_t kGlobalUserUid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
const gid_t kGlobalUserGid = tzplatform_getgid(TZ_SYS_GLOBALAPP_USER);
for (auto l : list) {
uid_t lu = std::get<0>(l);
gid_t lg = std::get<1>(l);
- bf::path apps_rw = ci::GetRootAppPath(false, lu);
- bf::path pkg_root = apps_rw / context_->pkgid.get();
- if (!ci::SetPackageDirectoryOwnerAndPermissions(pkg_root, lu))
- return Step::Status::ERROR;
-
- if (!SetSharedDirOwnershipAndPermissions(apps_rw, context_->pkgid.get(),
- lu, lg))
- return Step::Status::ERROR;
+ bf::path owner_apps_rw = ci::GetRootAppPath(false, uid);
+ std::vector<bf::path> apps_rw_paths;
+ apps_rw_paths.push_back(std::move(owner_apps_rw));
+ for (auto& lw_user : GetLightUserList(uid))
+ apps_rw_paths.push_back(std::get<2>(l) / kSubssesionDir / lw_user /
+ "apps_rw");
+
+ for (auto& apps_rw : apps_rw_paths) {
+ bf::path pkg_root = apps_rw / context_->pkgid.get();
+ if (!ci::SetPackageDirectoryOwnerAndPermissions(pkg_root, lu))
+ return Step::Status::ERROR;
+
+ if (!SetSharedDirOwnershipAndPermissions(apps_rw,
+ context_->pkgid.get(), lu, lg))
+ return Step::Status::ERROR;
+ }
}
} else {
- bf::path apps_rw = ci::GetRootAppPath(false, uid);
- if (!SetSharedDirOwnershipAndPermissions(apps_rw, context_->pkgid.get(),
- context_->uid.get(), *gid))
- return Step::Status::ERROR;
+ ci::UserList list = ci::GetUserList();
+ for (auto& l : list) {
+ uid_t lu = std::get<0>(l);
+ if (lu != uid)
+ continue;
+
+ bf::path owner_apps_rw = ci::GetRootAppPath(false, uid);
+ std::vector<bf::path> apps_rw_paths;
+ apps_rw_paths.push_back(std::move(owner_apps_rw));
+ for (auto& lw_user : GetLightUserList(uid))
+ apps_rw_paths.push_back(std::get<2>(l) / kSubssesionDir / lw_user /
+ "apps_rw");
+
+ for (auto& apps_rw : apps_rw_paths) {
+ if (!SetSharedDirOwnershipAndPermissions(apps_rw,
+ context_->pkgid.get(), context_->uid.get(), *gid))
+ return Step::Status::ERROR;
+ }
+ }
}
return ChangeOwnershipIconsAndManifest(gid, uid);
namespace {
const uid_t kGlobalUserUid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
+const char kSubsesionDir[] = "subsessions";
bool SkipRWDirectories(const bf::path& path) {
static const std::vector<std::string> dirs_to_ignore = {
}
Step::Status StepRemoveFiles::process() {
- // Use RootAppPath + Pkgid because of ReadonlyUpdateUninstall
- bf::path pkg_path = context_->GetPkgPath();
-
// We need to unmount external storage before removing package directory
// because mount point is inside
if (context_->external_storage)
}
bool is_error = false;
- if (is_keep_rwdata) {
- bool ret;
- for (bf::directory_iterator itr(pkg_path); itr != bf::directory_iterator();
- ++itr) {
- if (bf::is_directory(itr->status())) {
- if (SkipRWDirectories(itr->path().leaf())) {
- LOG(DEBUG) << "Skipping remove dir:" << itr->path().c_str();
- continue;
+ std::vector<bf::path> root_paths;
+ // Use RootAppPath + Pkgid because of ReadonlyUpdateUninstall
+ root_paths.push_back(context_->root_application_path.get());
+
+ for (auto& lw_user : GetLightUserList(context_->uid.get()))
+ root_paths.push_back(context_->root_application_path.get() / kSubsesionDir /
+ lw_user);
+
+ for (auto& root_path : root_paths) {
+ if (is_keep_rwdata) {
+ bool ret;
+ for (bf::directory_iterator itr(root_path / context_->pkgid.get());
+ itr != bf::directory_iterator(); ++itr) {
+ if (bf::is_directory(itr->status())) {
+ if (SkipRWDirectories(itr->path().leaf())) {
+ LOG(DEBUG) << "Skipping remove dir:" << itr->path().c_str();
+ continue;
+ }
+ ret = RemoveAll(itr->path());
+ } else {
+ ret = Remove(itr->path());
}
- ret = RemoveAll(itr->path());
- } else {
- ret = Remove(itr->path());
+ if (!ret)
+ is_error = true;
}
- if (!ret)
+ } else {
+ if (!RemoveAll(root_path / context_->pkgid.get()) ||
+ !common_installer::DeleteSharedDirectories(root_path,
+ context_->pkgid.get()))
is_error = true;
}
- } else {
- if (!RemoveAll(pkg_path) ||
- !common_installer::DeleteSharedDirectories(
- context_->root_application_path.get(),
- context_->pkgid.get()))
- is_error = true;
- }
- if (is_error)
- return Status::ERROR;
+ if (is_error)
+ return Status::ERROR;
+ }
// Remove package files at extended storage
if (context_->storage.get() == Storage::EXTENDED) {
return Status::APP_DIR_ERROR;
}
+ for (auto& lw_user : GetLightUserList(context_->uid.get())) {
+ if (context_->storage.get() == Storage::EXTENDED) {
+ bf::path extended_path =
+ bf::path(GetExtendedRootAppPath(context_->uid.get())) /
+ kSubsesionDir / lw_user / context_->pkgid.get();
+ if (!RemoveAll(extended_path))
+ return Status::APP_DIR_ERROR;
+ }
+ }
+
// Remove stored signature file
if (!RemoveSignature(context_->pkgid.get(),
context_->is_readonly_package.get()))