+++ /dev/null
-// 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 <glib.h>
-#include <gio/gio.h>
-#include <manifest_parser/utils/logging.h>
-
-#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 DBusRequestForDirectoryOperation(const char* method,
- GVariant* parameter) {
- 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,
- parameter, 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;
-}
-
-bool RequestUserDirectoryOperation(const char* method,
- const std::string& pkgid) {
- GVariant* parameter = g_variant_new("(s)", pkgid.c_str());
- return DBusRequestForDirectoryOperation(method, parameter);
-}
-
-bool RequestUserDirectoryOperationForUser(const char* method,
- const std::string& pkgid, uid_t uid) {
- GVariant* parameter = g_variant_new("(si)", pkgid.c_str(), uid);
- return DBusRequestForDirectoryOperation(method, parameter);
-}
-
-} // 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;
-}
-
-bool RequestCreateLegacyDirectories(const std::string& pkgid) {
- RequestUserDirectoryOperation("CreateLegacyDirs", pkgid);
- return true;
-}
-
-bool RequestDeleteLegacyDirectories(const std::string& pkgid) {
- RequestUserDirectoryOperation("DeleteLegacyDirs", pkgid);
- return true;
-}
-
-bool RequestCreateGlobalAppSymlinks(const std::string& pkgid) {
- bool result =
- RequestUserDirectoryOperation("CreateGlobalAppSymlinks", pkgid);
- if (!result) {
- LOG(INFO) << "Try to create symlinks for global app directly";
- return CreateGlobalAppSymlinksForAllUsers(pkgid);
- }
- return result;
-}
-
-bool RequestCreateGlobalAppSymlinksForUser(const std::string& pkgid,
- uid_t uid) {
- bool result =
- RequestUserDirectoryOperationForUser("CreateGlobalAppSymlinksForUser",
- pkgid, uid);
- if (!result) {
- LOG(INFO) << "Try to create symlinks for global app directly";
- return CreateGlobalAppSymlinksForUser(pkgid, uid);
- }
- return result;
-}
-
-bool RequestDeleteGlobalAppSymlinks(const std::string& pkgid) {
- bool result =
- RequestUserDirectoryOperation("DeleteGlobalAppSymlinks", pkgid);
- if (!result) {
- LOG(INFO) << "Try to delete symlinks for global app directly";
- return DeleteGlobalAppSymlinksForAllUsers(pkgid);
- }
- return result;
-}
-
-bool RequestDeleteGlobalAppSymlinksForUser(const std::string& pkgid,
- uid_t uid) {
- bool result =
- RequestUserDirectoryOperationForUser("DeleteGlobalAppSymlinksForUser",
- pkgid, uid);
- if (!result) {
- LOG(INFO) << "Try to delete symlinks for global app directly";
- return DeleteGlobalAppSymlinksForUser(pkgid, uid);
- }
- return result;
-}
-
-} // namespace common_installer
+++ /dev/null
-// 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 <string>
-
-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);
-
-/**
- * \brief Request to create legacy directories
- *
- * \param pkgid package id
- *
- * \return bool true if succeed, false otherwise
- */
-bool RequestCreateLegacyDirectories(const std::string& pkgid);
-
-/**
- * \brief Request to delete legacy directories
- *
- * \param pkgid package id
- *
- * \return bool true if succeed, false otherwise
- */
-bool RequestDeleteLegacyDirectories(const std::string& pkgid);
-
-/**
- * \brief Request to create symlinks of global app for all users
- *
- * \param pkgid package id
- *
- * \return bool true if succeed, false otherwise
- */
-bool RequestCreateGlobalAppSymlinks(const std::string& pkgid);
-
-/**
- * \brief Request to create symlinks of global app for user
- *
- * \param pkgid package id
- * \param uid user id
- *
- * \return bool true if succeed, false otherwise
- */
-bool RequestCreateGlobalAppSymlinksForUser(const std::string& pkgid, uid_t uid);
-
-/**
- * \brief Request to delete symlinks of global app for all users
- *
- * \param pkgid package id
- *
- * \return bool true if succeed, false otherwise
- */
-bool RequestDeleteGlobalAppSymlinks(const std::string& pkgid);
-
-/**
- * \brief Request to delete symlinks of global app for user
- *
- * \param pkgid package id
- * \param uid user id
- *
- * \return bool true if succeed, false otherwise
- */
-bool RequestDeleteGlobalAppSymlinksForUser(const std::string& pkgid, uid_t uid);
-
-} // namespace common_installer
-
-#endif // COMMON_PKGDIR_TOOL_REQUEST_H_
#include <string>
-#include "common/pkgdir_tool_request.h"
#include "common/shared_dirs.h"
#include "common/pkgmgr_query.h"
QueryIsPackageInstalled(context_->pkgid.get(), kGlobalUserUid)) {
LOG(INFO) << "Creating globalapp symlinks for current user, package: "
<< package_id;
- if (!RequestCreateGlobalAppSymlinksForUser(package_id,
- context_->uid.get())) {
+ if (!CreateGlobalAppSymlinksForUser(package_id, context_->uid.get())) {
LOG(ERROR) << "Failed to create globalapp symlinks";
return Status::GLOBALSYMLINK_ERROR;
}
if (context_->request_mode.get() == RequestMode::GLOBAL) {
LOG(INFO) << "Creating globalapp symlinks for all user, package: "
<< package_id;
- if (!RequestCreateGlobalAppSymlinks(package_id)) {
+ if (!CreateGlobalAppSymlinksForAllUsers(package_id)) {
LOG(ERROR) << "Failed to create globalapp symlinks";
return Status::GLOBALSYMLINK_ERROR;
}
+++ /dev/null
-// 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/step/filesystem/step_create_legacy_directories.h"
-
-#include <string>
-
-#include "common/pkgdir_tool_request.h"
-#include "common/shared_dirs.h"
-
-namespace common_installer {
-namespace filesystem {
-
-common_installer::Step::Status StepCreateLegacyDirectories::process() {
- std::string package_id = context_->pkgid.get();
-
- LOG(INFO) << "Creating legacy directories for package: " << package_id;
- common_installer::RequestCreateLegacyDirectories(package_id);
-
- return Status::OK;
-}
-
-} // namespace filesystem
-} // namespace common_installer
+++ /dev/null
-// 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_STEP_FILESYSTEM_STEP_CREATE_LEGACY_DIRECTORIES_H_
-#define COMMON_STEP_FILESYSTEM_STEP_CREATE_LEGACY_DIRECTORIES_H_
-
-#include <manifest_parser/utils/logging.h>
-
-#include "common/step/step.h"
-
-namespace common_installer {
-namespace filesystem {
-
-/**
- * \brief Installation.
- * Responsible for creating RW directoires under legacy app-root
- * for backward compatibility. (wgt/tpk)
- *
- * * process method implements creation of data and shared directories
- * under /opt/usr/apps.
- *
- * * Other methods are empty.
- */
-class StepCreateLegacyDirectories : public common_installer::Step {
- public:
- using Step::Step;
-
- Status process() override;
- Status clean() override { return Status::OK; }
- Status undo() override { return Status::OK; }
- Status precheck() override { return Status::OK; }
-
- STEP_NAME(CreateLegacyDirectories)
-};
-
-} // namespace filesystem
-} // namespace common_installer
-
-#endif // COMMON_STEP_FILESYSTEM_STEP_CREATE_LEGACY_DIRECTORIES_H_
#include "common/privileges.h"
-#include "common/pkgdir_tool_request.h"
#include "common/shared_dirs.h"
#include "common/utils/glist_range.h"
return Status::APP_DIR_ERROR;
}
- if (!common_installer::RequestCopyUserDirectories(package_id)) {
+ if (!CopyUserDirectories(package_id)) {
LOG(ERROR) << "Failed to create shared dirs for users";
return Status::APP_DIR_ERROR;
}
#include <string>
#include "common/installer_context.h"
-#include "common/pkgdir_tool_request.h"
#include "common/pkgmgr_query.h"
+#include "common/shared_dirs.h"
namespace {
if (context_->request_mode.get() == RequestMode::GLOBAL) {
LOG(INFO) << "Deleting globalapp symlinks for all user, package: "
<< package_id;
- if (!RequestDeleteGlobalAppSymlinks(package_id)) {
+ if (!DeleteGlobalAppSymlinksForAllUsers(package_id)) {
LOG(ERROR) << "Failed to delete globalapp symlinks";
return Status::GLOBALSYMLINK_ERROR;
}
} else {
LOG(INFO) << "Deleting globalapp symlinks for current user, package: "
<< package_id;
- if (!RequestDeleteGlobalAppSymlinksForUser(package_id,
- context_->uid.get())) {
+ if (!DeleteGlobalAppSymlinksForUser(package_id, context_->uid.get())) {
LOG(ERROR) << "Failed to delete globalapp symlinks";
return Status::GLOBALSYMLINK_ERROR;
}
+++ /dev/null
-// Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
-// Use of this source code is governed by a apache 2.0 license that can be
-// found in the LICENSE file.
-
-#include "common/step/filesystem/step_remove_legacy_directories.h"
-
-#include <string>
-
-#include "common/installer_context.h"
-#include "common/pkgdir_tool_request.h"
-
-namespace common_installer {
-namespace filesystem {
-
-Step::Status StepRemoveLegacyDirectories::process() {
- std::string package_id = context_->pkgid.get();
-
- common_installer::RequestDeleteLegacyDirectories(package_id);
-
- return Step::Status::OK;
-}
-
-} // namespace filesystem
-} // namespace common_installer
-
+++ /dev/null
-// 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_STEP_FILESYSTEM_STEP_REMOVE_LEGACY_DIRECTORIES_H_
-#define COMMON_STEP_FILESYSTEM_STEP_REMOVE_LEGACY_DIRECTORIES_H_
-
-#include <manifest_parser/utils/logging.h>
-
-#include "common/step/step.h"
-
-namespace common_installer {
-namespace filesystem {
-
-/**
- * \brief Uninstallation.
- * Responsible for removing RW directoires under legacy app-root
- * (wgt/tpk)
- *
- * * process method implements removal of data and shared directories
- * under /opt/usr/apps.
- *
- * * Other methods are empty.
- *
- */
-
-class StepRemoveLegacyDirectories : public common_installer::Step {
- public:
- using Step::Step;
-
- Status process() override;
- Status clean() override { return Status::OK; }
- Status undo() override { return Status::OK; }
- Status precheck() override { return Status::OK; }
-
- STEP_NAME(RemoveLegacyDirectories)
-};
-
-} // namespace filesystem
-} // namespace common_installer
-
-#endif // COMMON_STEP_FILESYSTEM_STEP_REMOVE_LEGACY_DIRECTORIES_H_
#include <vector>
#include "common/installer_context.h"
-#include "common/pkgdir_tool_request.h"
#include "common/shared_dirs.h"
namespace common_installer {
return Status::APP_DIR_ERROR;
}
- if (!common_installer::RequestDeleteUserDirectories(package_id)) {
+ if (DeleteUserDirectories(package_id)) {
LOG(ERROR) << "Failed to delete shared dirs for users";
return Status::APP_DIR_ERROR;
}
const char kDBusInstropectionXml[] =
"<node>"
" <interface name='org.tizen.pkgdir_tool'>"
- " <method name='CopyUserDirs'>"
- " <arg type='s' name='pkgid' direction='in'/>"
- " <arg type='b' name='result' direction='out'/>"
- " </method>"
- " <method name='DeleteUserDirs'>"
- " <arg type='s' name='pkgid' direction='in'/>"
- " <arg type='b' name='result' direction='out'/>"
- " </method>"
- " <method name='CreateExternalDirs'>"
- " <arg type='s' name='pkgid' direction='in'/>"
- " <arg type='b' name='result' direction='out'/>"
- " </method>"
- " <method name='DeleteExternalDirs'>"
- " <arg type='s' name='pkgid' direction='in'/>"
- " <arg type='b' name='result' direction='out'/>"
- " </method>"
" <method name='CreateExternalDirsForAllPkgs'>"
" <arg type='b' name='result' direction='out'/>"
" </method>"
- " <method name='CreateGlobalAppSymlinks'>"
- " <arg type='s' name='pkgid' direction='in'/>"
- " <arg type='b' name='result' direction='out'/>"
- " </method>"
- " <method name='DeleteGlobalAppSymlinks'>"
- " <arg type='s' name='pkgid' direction='in'/>"
- " <arg type='b' name='result' direction='out'/>"
- " </method>"
- " <method name='CreateGlobalAppSymlinksForUser'>"
- " <arg type='s' name='pkgid' direction='in'/>"
- " <arg type='i' name='uid' direction='in'/>"
- " <arg type='b' name='result' direction='out'/>"
- " </method>"
- " <method name='DeleteGlobalAppSymlinksForUser'>"
- " <arg type='s' name='pkgid' direction='in'/>"
- " <arg type='i' name='uid' direction='in'/>"
- " <arg type='b' name='result' direction='out'/>"
- " </method>"
" </interface>"
"</node>";
const char kDBusServiceName[] = "org.tizen.pkgdir_tool";
bool r = false;
LOG(INFO) << "Incomming method call: " << method_name;
- if (g_strcmp0(method_name, "CopyUserDirs") == 0) {
- g_variant_get(parameters, "(&s)", &val);
- r = ci::CopyUserDirectories(std::string(val));
- } else if (g_strcmp0(method_name, "DeleteUserDirs") == 0) {
- g_variant_get(parameters, "(&s)", &val);
- r = ci::DeleteUserDirectories(std::string(val));
- } else if (g_strcmp0(method_name, "CreateExternalDirs") == 0) {
- g_variant_get(parameters, "(&s)", &val);
- r = ci::PerformExternalDirectoryCreationForAllUsers(std::string(val));
- } else if (g_strcmp0(method_name, "DeleteExternalDirs") == 0) {
- g_variant_get(parameters, "(&s)", &val);
- r = ci::PerformExternalDirectoryDeletionForAllUsers(std::string(val));
- } else if (g_strcmp0(method_name, "CreateExternalDirsForAllPkgs") == 0) {
+ if (g_strcmp0(method_name, "CreateExternalDirsForAllPkgs") == 0) {
r = ci::PerformExternalDirectoryCreationForAllPkgs();
- } else if (g_strcmp0(method_name, "CreateGlobalAppSymlinks") == 0) {
- g_variant_get(parameters, "(&s)", &val);
- r = ci::CreateGlobalAppSymlinksForAllUsers(std::string(val));
- } else if (g_strcmp0(method_name, "DeleteGlobalAppSymlinks") == 0) {
- g_variant_get(parameters, "(&s)", &val);
- r = ci::DeleteGlobalAppSymlinksForAllUsers(std::string(val));
- } else if (g_strcmp0(method_name, "CreateGlobalAppSymlinksForUser") == 0) {
- uid_t uid;
- g_variant_get(parameters, "(&si)", &val, &uid);
- r = ci::CreateGlobalAppSymlinksForUser(std::string(val), uid);
- } else if (g_strcmp0(method_name, "DeleteGlobalAppSymlinksForUser") == 0) {
- uid_t uid;
- g_variant_get(parameters, "(&si)", &val, &uid);
- r = ci::DeleteGlobalAppSymlinksForUser(std::string(val), uid);
} else {
LOG(ERROR) << "Unknown method call: " << method_name;
}