From 26b935e181e5a529c66d4d92e3649186e325826c Mon Sep 17 00:00:00 2001 From: Tomasz Iwanek Date: Mon, 13 Jun 2016 17:17:49 +0200 Subject: [PATCH] Handling external appdata directories - fixes scenarios of adding and removing external appdata directories - reworks parameter author_id in shared_dirs to trusted (trusted should be removed probably), - separate API from shared_dirs resposible for requests (IPC) into separate file different functionalities are defined in different headers. Submit together: - https://review.tizen.org/gerrit/74805 - https://review.tizen.org/gerrit/74806 Change-Id: If9a9d664fe8188727f5a92a9a2bf274553bcf810 --- src/common/CMakeLists.txt | 1 + src/common/pkgdir_tool_request.cc | 101 ++++++++++++++ src/common/pkgdir_tool_request.h | 58 ++++++++ src/common/pkgmgr_registration.cc | 8 +- src/common/pkgmgr_registration.h | 2 +- src/common/shared_dirs.cc | 148 ++++++++++----------- src/common/shared_dirs.h | 56 +++----- .../step_create_per_user_storage_directories.cc | 48 +------ .../step_create_per_user_storage_directories.h | 3 - .../step_remove_per_user_storage_directories.cc | 4 +- src/pkgdir_tool/pkgdir_tool.cc | 12 ++ 11 files changed, 273 insertions(+), 168 deletions(-) create mode 100644 src/common/pkgdir_tool_request.cc create mode 100644 src/common/pkgdir_tool_request.h diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index a681e14..503128e 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -6,6 +6,7 @@ SET(SRCS certificate_validation.cc external_storage.cc installer_context.cc + pkgdir_tool_request.cc plugins/plugin_factory.cc plugins/plugin_manager.cc plugins/plugin_list_parser.cc diff --git a/src/common/pkgdir_tool_request.cc b/src/common/pkgdir_tool_request.cc new file mode 100644 index 0000000..c13ced5 --- /dev/null +++ b/src/common/pkgdir_tool_request.cc @@ -0,0 +1,101 @@ +// Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved +// Use of this source code is governed by an apache-2.0 license that can be +// found in the LICENSE file. + +#include "common/pkgdir_tool_request.h" + +#include +#include +#include + +#include "common/shared_dirs.h" + +namespace { + +const char kDBusServiceName[] = "org.tizen.pkgdir_tool"; +const char kDBusObjectPath[] = "/org/tizen/pkgdir_tool"; +const char kDBusInterfaceName[] = "org.tizen.pkgdir_tool"; + +bool RequestUserDirectoryOperation(const char* method, + const std::string& pkgid) { + GError* err = nullptr; + GDBusConnection* con = g_bus_get_sync(G_BUS_TYPE_SYSTEM, nullptr, &err); + if (!con || err) { + LOG(WARNING) << "Failed to get dbus connection: " << err->message; + g_error_free(err); + return false; + } + GDBusProxy* proxy = g_dbus_proxy_new_sync(con, G_DBUS_PROXY_FLAGS_NONE, + nullptr, kDBusServiceName, kDBusObjectPath, kDBusInterfaceName, nullptr, + &err); + if (!proxy) { + std::string err_msg; + if (err) { + err_msg = std::string(err->message); + g_error_free(err); + } + LOG(ERROR) << "Failed to get dbus proxy: " << err_msg; + g_object_unref(con); + return false; + } + GVariant* r = g_dbus_proxy_call_sync(proxy, method, + g_variant_new("(s)", pkgid.c_str()), G_DBUS_CALL_FLAGS_NONE, -1, nullptr, + &err); + if (!r) { + std::string err_msg; + if (err) { + err_msg = std::string(err->message); + g_error_free(err); + } + LOG(ERROR) << "Failed to request: " << err_msg; + g_object_unref(proxy); + g_object_unref(con); + return false; + } + bool result; + g_variant_get(r, "(b)", &result); + + g_variant_unref(r); + g_object_unref(proxy); + g_object_unref(con); + + return result; +} + +} // namespace + +namespace common_installer { + +bool RequestCopyUserDirectories(const std::string& pkgid) { + if (!RequestUserDirectoryOperation("CopyUserDirs", pkgid)) { + LOG(INFO) << "Try to copy user directories directly"; + return CopyUserDirectories(pkgid); + } + return true; +} + +bool RequestDeleteUserDirectories(const std::string& pkgid) { + if (!RequestUserDirectoryOperation("DeleteUserDirs", pkgid)) { + LOG(INFO) << "Try to delete user directories directly"; + return DeleteUserDirectories(pkgid); + } + return true; +} + +bool RequestCreateExternalDirectories(const std::string& pkgid) { + if (!RequestUserDirectoryOperation("CreateExternalDirs", pkgid)) { + LOG(INFO) << "Try to create external directories directly"; + return PerformExternalDirectoryCreationForAllUsers(pkgid); + } + return true; +} + +bool RequestDeleteExternalDirectories(const std::string& pkgid) { + if (!RequestUserDirectoryOperation("DeleteExternalDirs", pkgid)) { + LOG(INFO) << "Try to remove external directories directly"; + return PerformExternalDirectoryDeletionForAllUsers(pkgid); + } + return true; +} + +} // namespace common_installer diff --git a/src/common/pkgdir_tool_request.h b/src/common/pkgdir_tool_request.h new file mode 100644 index 0000000..d8fcefc --- /dev/null +++ b/src/common/pkgdir_tool_request.h @@ -0,0 +1,58 @@ +// Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved +// Use of this source code is governed by an apache-2.0 license that can be +// found in the LICENSE file. + +#ifndef COMMON_PKGDIR_TOOL_REQUEST_H_ +#define COMMON_PKGDIR_TOOL_REQUEST_H_ + +#include + +namespace common_installer { + +/** + * \brief Request to copy per-user directories + * + * \param pkgid package id + * + * If IPC fails, fall back to direct function call (for offline) + * + * \return bool true if succeed, false otherwise + */ +bool RequestCopyUserDirectories(const std::string& pkgid); + +/** + * \brief Request to delete per-user directories + * + * \param pkgid package id + * + * If IPC fails, fall back to direct function call (for offline) + * + * \return bool true if succeed, false otherwise + */ +bool RequestDeleteUserDirectories(const std::string& pkgid); + +/** + * \brief Request to create external directories + * + * \param pkgid package id + * + * If IPC fails, fall back to direct function call (for offline) + * + * \return bool true if succeed, false otherwise + */ +bool RequestCreateExternalDirectories(const std::string& pkgid); + +/** + * \brief Request to delete external directories + * + * \param pkgid package id + * + * If IPC fails, fall back to direct function call (for offline) + * + * \return bool true if succeed, false otherwise + */ +bool RequestDeleteExternalDirectories(const std::string& pkgid); + +} // namespace common_installer + +#endif // COMMON_PKGDIR_TOOL_REQUEST_H_ diff --git a/src/common/pkgmgr_registration.cc b/src/common/pkgmgr_registration.cc index bacd18d..fa97e24 100644 --- a/src/common/pkgmgr_registration.cc +++ b/src/common/pkgmgr_registration.cc @@ -379,8 +379,10 @@ bool IsPackageInstalled(const std::string& pkg_id, RequestMode request_mode) { pkgmgrinfo_pkginfo_h handle; int ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkg_id.c_str(), getuid(), &handle); - if (ret != PMINFO_R_OK) + if (ret != PMINFO_R_OK) { + LOG(ERROR) << "Failed to call pkgmgrinfo_pkginfo_get_usr_pkginfo"; return false; + } bool is_global = false; if (pkgmgrinfo_pkginfo_is_for_all_users(handle, &is_global) != PMINFO_R_OK) { LOG(ERROR) << "pkgmgrinfo_pkginfo_is_for_all_users failed"; @@ -399,8 +401,10 @@ bool IsPackageInstalled(const std::string& pkg_id, RequestMode request_mode) { bool IsPackageInstalled(const std::string& pkg_id, uid_t uid) { pkgmgrinfo_pkginfo_h handle; int ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkg_id.c_str(), uid, &handle); - if (ret != PMINFO_R_OK) + if (ret != PMINFO_R_OK) { + LOG(ERROR) << "Failed to call pkgmgrinfo_pkginfo_get_usr_pkginfo"; return false; + } bool is_global = false; if (pkgmgrinfo_pkginfo_is_for_all_users(handle, &is_global) != PMINFO_R_OK) { diff --git a/src/common/pkgmgr_registration.h b/src/common/pkgmgr_registration.h index 7e6b58c..2f9d9fb 100644 --- a/src/common/pkgmgr_registration.h +++ b/src/common/pkgmgr_registration.h @@ -154,7 +154,7 @@ bool IsPackageInstalled(const std::string& pkg_id, RequestMode request_mode); /** * \brief Adapter interface for external PkgMgr module used for checking - * if given package is installed/registered + * if given package is installed/registered per given uid only * * \param pkg_id package id * \param uid user id diff --git a/src/common/shared_dirs.cc b/src/common/shared_dirs.cc index 40f3676..8bca253 100644 --- a/src/common/shared_dirs.cc +++ b/src/common/shared_dirs.cc @@ -63,9 +63,6 @@ const char kTrustedDir[] = "shared/trusted"; const char kSkelAppDir[] = "/etc/skel/apps_rw"; const char kPackagePattern[] = R"(^[0-9a-zA-Z_-]+(\.?[0-9a-zA-Z_-]+)*$)"; const char kExternalStorageDirPrefix[] = "SDCardA1"; -const char kDBusServiceName[] = "org.tizen.pkgdir_tool"; -const char kDBusObjectPath[] = "/org/tizen/pkgdir_tool"; -const char kDBusInterfaceName[] = "org.tizen.pkgdir_tool"; const int32_t kPWBufSize = sysconf(_SC_GETPW_R_SIZE_MAX); const int32_t kGRBufSize = sysconf(_SC_GETGR_R_SIZE_MAX); @@ -177,7 +174,7 @@ bool SetPackageDirectoryOwnerAndPermissions(const bf::path& subpath, uid_t uid, } bool CreateDirectories(const bf::path& app_dir, const std::string& pkgid, - const std::string& author_id, + bool trusted, uid_t uid, gid_t gid, const bool set_permissions) { bf::path base_dir = app_dir / pkgid; if (bf::exists(base_dir)) { @@ -187,7 +184,7 @@ bool CreateDirectories(const bf::path& app_dir, const std::string& pkgid, bs::error_code error; std::vector dirs(kEntries); - if (!author_id.empty()) + if (trusted) dirs.push_back(kTrustedDir); for (auto& entry : dirs) { bf::path subpath = base_dir / entry; @@ -228,7 +225,7 @@ bf::path GetDirectoryPathForStorage(uid_t user, std::string apps_prefix) { } bool CreateUserDirectories(uid_t user, const std::string& pkgid, - const std::string& author_id, + bool trusted, const std::string& apps_prefix, const bool set_permissions) { struct passwd pwd; struct passwd *pwd_result; @@ -256,7 +253,7 @@ bool CreateUserDirectories(uid_t user, const std::string& pkgid, return false; } - if (!CreateDirectories(apps_rw, pkgid, author_id, + if (!CreateDirectories(apps_rw, pkgid, trusted, pwd.pw_uid, pwd.pw_gid, set_permissions)) { return false; } @@ -274,52 +271,6 @@ bool DeleteDirectories(const bf::path& app_dir, const std::string& pkgid) { return true; } -bool RequestUserDirectoryOperation(const char* method, - const std::string& pkgid) { - GError* err = nullptr; - GDBusConnection* con = g_bus_get_sync(G_BUS_TYPE_SYSTEM, nullptr, &err); - if (!con || err) { - LOG(WARNING) << "Failed to get dbus connection: " << err->message; - g_error_free(err); - return false; - } - GDBusProxy* proxy = g_dbus_proxy_new_sync(con, G_DBUS_PROXY_FLAGS_NONE, - nullptr, kDBusServiceName, kDBusObjectPath, kDBusInterfaceName, nullptr, - &err); - if (!proxy) { - std::string err_msg; - if (err) { - err_msg = std::string(err->message); - g_error_free(err); - } - LOG(ERROR) << "Failed to get dbus proxy: " << err_msg; - g_object_unref(con); - return false; - } - GVariant* r = g_dbus_proxy_call_sync(proxy, method, - g_variant_new("(s)", pkgid.c_str()), G_DBUS_CALL_FLAGS_NONE, -1, nullptr, - &err); - if (!r) { - std::string err_msg; - if (err) { - err_msg = std::string(err->message); - g_error_free(err); - } - LOG(ERROR) << "Failed to request: " << err_msg; - g_object_unref(proxy); - g_object_unref(con); - return false; - } - bool result; - g_variant_get(r, "(b)", &result); - - g_variant_unref(r); - g_object_unref(proxy); - g_object_unref(con); - - return result; -} - user_list GetUserList() { GumUserService* service = gum_user_service_create_sync((getuid() == 0) ? TRUE : FALSE); @@ -365,18 +316,23 @@ std::string GetDirectoryPathForExternalStorage() { bool PerformInternalDirectoryCreationForUser(uid_t user, const std::string& pkgid, - const std::string& author_id) { + bool trusted) { const char* internal_storage_prefix = tzplatform_getenv(TZ_SYS_HOME); const bool set_permissions = true; - if (!CreateUserDirectories(user, pkgid, author_id, + if (!CreateUserDirectories(user, pkgid, trusted, internal_storage_prefix, set_permissions)) return false; return true; } bool PerformExternalDirectoryCreationForUser(uid_t user, - const std::string& pkgid, - const std::string& author_id) { + const std::string& pkgid) { + // TODO(t.iwanek): trusted in this context means that we have signature + // this argument is not longer needed as all package must be signed + // so that trusted directory may be labeled correctly by security-manager in + // all cases. This parameter and its propagation should be removed. + bool trusted = true; + const char* storage_path = tzplatform_mkpath(TZ_SYS_MEDIA, kExternalStorageDirPrefix); const bool set_permissions = false; @@ -396,38 +352,68 @@ bool PerformExternalDirectoryCreationForUser(uid_t user, } } - if (CreateUserDirectories(user, pkgid, author_id, + if (CreateUserDirectories(user, pkgid, trusted, storage_apps_path.c_str(), set_permissions)) { } return true; } +bool PerformExternalDirectoryDeletionForUser(uid_t user, + const std::string& pkgid) { + const char* storage_path = tzplatform_mkpath(TZ_SYS_MEDIA, + kExternalStorageDirPrefix); + if (!bf::exists(storage_path)) { + LOG(WARNING) << "External storage (SD Card) is not mounted."; + return false; + } + + bf::path storage_apps_path = bf::path(storage_path) / "apps"; + return DeleteDirectories( + GetDirectoryPathForStorage(user, storage_apps_path.string()), pkgid); +} + bool PerformInternalDirectoryCreationForAllUsers(const std::string& pkgid, - const std::string& author_id) { + bool trusted) { user_list list = GetUserList(); for (auto l : list) { if (!PerformInternalDirectoryCreationForUser(std::get<0>(l), pkgid, - author_id)) + trusted)) LOG(ERROR) << "Could not create internal storage directories for user: " << std::get<0>(l); } return true; } -bool PerformExternalDirectoryCreationForAllUsers(const std::string& pkgid, - const std::string& author_id) { +bool PerformExternalDirectoryCreationForAllUsers(const std::string& pkgid) { user_list list = GetUserList(); for (auto l : list) { if (!PerformExternalDirectoryCreationForUser(std::get<0>(l), - pkgid, - author_id)) + pkgid)) LOG(WARNING) << "Could not create external storage directories for user: " << std::get<0>(l); } return true; } +bool PerformExternalDirectoryDeletionForAllUsers(const std::string& pkgid) { + user_list list = GetUserList(); + for (auto l : list) { + uid_t uid = std::get<0>(l); + LOG(DEBUG) << "Deleting directories for user: " << uid; + if (IsPackageInstalled(pkgid, uid)) { + LOG(DEBUG) << "Package: " << pkgid << " for uid: " << uid + << " still exists. Skipping"; + continue; + } + + if (!PerformExternalDirectoryDeletionForUser(uid, pkgid)) + LOG(WARNING) << "Could not delete external storage directories for user: " + << uid; + } + return true; +} + bool CreateSkelDirectories(const std::string& pkgid) { bf::path path = bf::path(kSkelAppDir) / pkgid; LOG(DEBUG) << "Creating directories in: " << path; @@ -483,6 +469,24 @@ bool DeleteUserDirectories(const std::string& pkgid) { return true; } +bool DeleteUserExternalDirectories(const std::string& pkgid) { + user_list list = GetUserList(); + for (auto l : list) { + if (ci::IsPackageInstalled(pkgid, std::get<0>(l))) { + LOG(INFO) << pkgid << " is installed for user " << std::get<0>(l); + continue; + } + + LOG(DEBUG) << "Deleting external directories of " << pkgid + << ", for uid: " << std::get<0>(l); + bf::path apps_rw(std::get<2>(l) / "apps_rw"); + if (!DeleteDirectories(apps_rw, pkgid)) { + return false; + } + } + return true; +} + bool CopyUserDirectories(const std::string& pkgid) { user_list list = GetUserList(); @@ -506,22 +510,6 @@ bool CopyUserDirectories(const std::string& pkgid) { return true; } -bool RequestCopyUserDirectories(const std::string& pkgid) { - if (!RequestUserDirectoryOperation("CopyUserDirs", pkgid)) { - LOG(INFO) << "Try to copy user directories directly"; - return CopyUserDirectories(pkgid); - } - return true; -} - -bool RequestDeleteUserDirectories(const std::string& pkgid) { - if (!RequestUserDirectoryOperation("DeleteUserDirs", pkgid)) { - LOG(INFO) << "Try to delete user directories directly"; - return DeleteUserDirectories(pkgid); - } - return true; -} - ci::PkgList CreatePkgInformationList(uid_t uid, const std::vector& pkgs) { return pkgs.empty() ? diff --git a/src/common/shared_dirs.h b/src/common/shared_dirs.h index b93a4f7..c992944 100644 --- a/src/common/shared_dirs.h +++ b/src/common/shared_dirs.h @@ -6,6 +6,7 @@ #define COMMON_SHARED_DIRS_H_ #include +#include #include #include @@ -29,65 +30,68 @@ using PkgList = std::vector; * \brief Performs a creation of directories for specific user in internal storage * * \param pkgid id of package - * \param author_id id of author + * \param trusted is package trusted * \param create_skel_directories flag * * \return true if succeed, false otherwise - * */ bool PerformInternalDirectoryCreationForUser(uid_t uid, const std::string& pkgid, - const std::string& author_id); + bool trusted); /** * \brief Performs a creation of directories for specific user in external storage * * \param pkgid id of package - * \param author_id id of author * \param create_skel_directories flag * * \return true if succeed, false otherwise * */ bool PerformExternalDirectoryCreationForUser(uid_t uid, - const std::string& pkgid, - const std::string& author_id); + const std::string& pkgid); + +/** + * \brief Performs a removal of directories for specific user in external storage + * \param user id of user + * \param pkgid id of package + * + * \return true if succeed, false otherwise + */ +bool PerformExternalDirectoryDeletionForUser(uid_t user, + const std::string& pkgid); /** * \brief Performs a creation of directories in internal storage * * \param pkgid id of package - * \param author_id id of author + * \param trusted is package trusted * \param create_skel_directories flag * * \return true if succeed, false otherwise * */ bool PerformInternalDirectoryCreationForAllUsers(const std::string& pkgid, - const std::string& author_id); + bool trusted); /** * \brief Performs a creation of directories in external storage (eg. SD card) * * \param pkgid id of package - * \param author_id id of author * \param create_skel_directories flag * * \return true if succeed, false otherwise * */ -bool PerformExternalDirectoryCreationForAllUsers(const std::string& pkgid, - const std::string& author_id); +bool PerformExternalDirectoryCreationForAllUsers(const std::string& pkgid); /** - * \brief Performs deletion of directories - * - * \param pkg_path package path + * \brief Performs a removal of directories in external storage (eg. SD card) + * \param pkgid id of package * * \return true if succeed, false otherwise - * */ -bool PerformDirectoryDeletionForAllUsers(const std::string& pkgid); +bool PerformExternalDirectoryDeletionForAllUsers(const std::string& pkgid); /** * \brief Helper function fetching information about packages @@ -143,26 +147,6 @@ bool DeleteUserDirectories(const std::string& pkgid); bool CopyUserDirectories(const std::string& pkgid); /** - * \brief Request to copy per-user directories - * - * \param pkgid package id - * - * \return bool true if succeed, false otherwise - * - */ -bool RequestCopyUserDirectories(const std::string& pkgid); - -/** - * \brief Request to delete per-user directories - * - * \param pkgid package id - * - * \return bool true if succeed, false otherwise - * - */ -bool RequestDeleteUserDirectories(const std::string& pkgid); - -/** * \brief Returns path prefix for internal storage, typically '/home' * * \return path prefix diff --git a/src/common/step/filesystem/step_create_per_user_storage_directories.cc b/src/common/step/filesystem/step_create_per_user_storage_directories.cc index 4963cbd..707aec7 100644 --- a/src/common/step/filesystem/step_create_per_user_storage_directories.cc +++ b/src/common/step/filesystem/step_create_per_user_storage_directories.cc @@ -8,6 +8,7 @@ #include "common/step/filesystem/step_create_per_user_storage_directories.h" #include "common/privileges.h" +#include "common/pkgdir_tool_request.h" #include "common/shared_dirs.h" #include "common/utils/glist_range.h" @@ -15,8 +16,8 @@ namespace common_installer { namespace filesystem { common_installer::Step::Status StepCreatePerUserStorageDirectories::process() { - if (!CreateExternalStorageDir()) return Step::Status::APP_DIR_ERROR; - if (GLOBAL_USER != context_->uid.get()) return Step::Status::OK; + if (context_->request_mode.get() != RequestMode::GLOBAL) + return Step::Status::OK; std::string package_id = context_->pkgid.get(); LOG(INFO) << "Creating per-user directories for package: " << package_id; @@ -34,48 +35,5 @@ common_installer::Step::Status StepCreatePerUserStorageDirectories::process() { return Status::OK; } -bool StepCreatePerUserStorageDirectories::CreateExternalStorageDir() { - auto manifest = context_->manifest_data.get(); - bool has_external_storage_priv = false; - for (const char* priv : GListRange(manifest->privileges)) { - if (strcmp(priv, common::privileges::kPrivForExternalAppData) == 0) { - has_external_storage_priv = true; - LOG(DEBUG) << "External storage privilege has been found."; - break; - } - } - if (!has_external_storage_priv) { - LOG(DEBUG) << "External storage privilege not found, skipping."; - return true; - } - std::vector pkg_ids = { context_->pkgid.get() }; - auto pkg_list = CreatePkgInformationList(context_->uid.get(), pkg_ids); - - if (pkg_list.empty()) { - LOG(ERROR) << "Could not create pkg information list."; - return false; - } - - PkgInfo pkg = *pkg_list.begin(); - - switch (context_->request_mode.get()) { - case RequestMode::GLOBAL: { - LOG(DEBUG) << "Creating external directories for all users"; - PerformExternalDirectoryCreationForAllUsers(pkg.pkg_id, - pkg.author_id); - } - break; - case RequestMode::USER: { - LOG(DEBUG) << "Creating external directories for user: " - << context_->uid.get(); - PerformExternalDirectoryCreationForUser(context_->uid.get(), - pkg.pkg_id, - pkg.author_id); - } - break; - } - return true; -} - } // namespace filesystem } // namespace common_installer diff --git a/src/common/step/filesystem/step_create_per_user_storage_directories.h b/src/common/step/filesystem/step_create_per_user_storage_directories.h index 4d2a9fc..e136af2 100644 --- a/src/common/step/filesystem/step_create_per_user_storage_directories.h +++ b/src/common/step/filesystem/step_create_per_user_storage_directories.h @@ -32,9 +32,6 @@ class StepCreatePerUserStorageDirectories : public common_installer::Step { Status precheck() override { return Status::OK; } STEP_NAME(CreatePerUserStorageDirectories) - - private: - bool CreateExternalStorageDir(); }; } // namespace filesystem diff --git a/src/common/step/filesystem/step_remove_per_user_storage_directories.cc b/src/common/step/filesystem/step_remove_per_user_storage_directories.cc index c42594a..057120a 100644 --- a/src/common/step/filesystem/step_remove_per_user_storage_directories.cc +++ b/src/common/step/filesystem/step_remove_per_user_storage_directories.cc @@ -8,13 +8,15 @@ #include #include "common/installer_context.h" +#include "common/pkgdir_tool_request.h" #include "common/shared_dirs.h" namespace common_installer { namespace filesystem { Step::Status StepRemovePerUserStorageDirectories::process() { - if (GLOBAL_USER != context_->uid.get()) return Step::Status::OK; + if (context_->request_mode.get() != RequestMode::GLOBAL) + return Step::Status::OK; std::string package_id = context_->pkgid.get(); diff --git a/src/pkgdir_tool/pkgdir_tool.cc b/src/pkgdir_tool/pkgdir_tool.cc index 9375842..2bbc17f 100644 --- a/src/pkgdir_tool/pkgdir_tool.cc +++ b/src/pkgdir_tool/pkgdir_tool.cc @@ -25,6 +25,14 @@ const char kDBusInstropectionXml[] = " " " " " " + " " + " " + " " + " " + " " + " " + " " + " " " " ""; const char kDBusServiceName[] = "org.tizen.pkgdir_tool"; @@ -130,6 +138,10 @@ void PkgdirToolService::HandleMethodCall(GDBusConnection* connection, r = ci::CopyUserDirectories(std::string(val)); } else if (g_strcmp0(method_name, "DeleteUserDirs") == 0) { r = ci::DeleteUserDirectories(std::string(val)); + } else if (g_strcmp0(method_name, "CreateExternalDirs") == 0) { + r = ci::PerformExternalDirectoryCreationForAllUsers(std::string(val)); + } else if (g_strcmp0(method_name, "DeleteExternalDirs") == 0) { + r = ci::PerformExternalDirectoryDeletionForAllUsers(std::string(val)); } else { LOG(ERROR) << "Unknown method call: " << method_name; } -- 2.7.4