From: jongmyeongko Date: Thu, 8 Dec 2016 06:29:24 +0000 (+0900) Subject: move the behavior of StepGrantPermission step to StepChangeOwnershipAndPermission X-Git-Tag: accepted/tizen/3.0/common/20161212.060241^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F61%2F103361%2F3;p=platform%2Fcore%2Fappfw%2Ftpk-backend.git move the behavior of StepGrantPermission step to StepChangeOwnershipAndPermission Submit with : https://review.tizen.org/gerrit/#/c/103359/ https://review.tizen.org/gerrit/#/c/103512/ Change-Id: Ideb73e83f2f4c92bd5a33e06242f9c73a873eb62 Signed-off-by: jongmyeongko --- diff --git a/src/tpk/step/filesystem/step_grant_permission.cc b/src/tpk/step/filesystem/step_grant_permission.cc deleted file mode 100644 index 580bf6b..0000000 --- a/src/tpk/step/filesystem/step_grant_permission.cc +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright (c) 2015 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 "tpk/step/filesystem/step_grant_permission.h" - -#include -#include -#include -#include - -#include - -#include "tpk/tpk_mount_path.h" - -namespace bf = boost::filesystem; -namespace bs = boost::system; -namespace ci = common_installer; - -namespace { - -bool GrantPermission755(const bf::path& path) { - auto permission = bf::perms::owner_all | - bf::perms::group_read | bf::perms::group_exe | - bf::perms::others_read | bf::perms::others_exe; - if (!ci::SetDirPermissions(path, permission)) { - LOG(ERROR) << "Grant permission error" << " path: " << path - << " permission: " << permission; - return false; - } - return true; -} - -bool GrantPermission644(const bf::path& path) { - auto permission = bf::perms::owner_read | bf::perms::owner_write | - bf::perms::group_read | bf::perms::others_read; - if (!ci::SetDirPermissions(path, permission)) { - LOG(ERROR) << "Grant permission error" << " path: " << path - << " permission: " << permission; - return false; - } - return true; -} - -} // namespace - -namespace tpk { -namespace filesystem { - -ci::Step::Status StepTpkGrantPermission::precheck() { - if (context_->pkgid.get().empty()) { - LOG(ERROR) << "Pkgid is not set"; - return Status::INVALID_VALUE; - } - return Status::OK; -} - -ci::Step::Status StepTpkGrantPermission::process() { - Status status = Status::OK; - context_->pkg_path.set( - context_->root_application_path.get() / context_->pkgid.get()); - - bf::path app_root = context_->pkg_path.get(); - if (bf::is_directory(app_root)) { - if (!GrantPermission755(app_root)) - return Status::GRANT_PERMISSION_ERROR; - } - for (auto& entry : - boost::make_iterator_range(bf::directory_iterator(app_root), {})) { - auto path = entry.path(); - - // skip path, which is related to mount or directory installer creates - if (bf::is_directory(path) && - (path.filename() == ".mmc" || path.filename() == ".pkg" || - path.filename() == "tep")) - continue; - - // if mount-install, apply to extracted directories only - if (context_->request_type.get() == ci::RequestType::MountInstall || - context_->request_type.get() == ci::RequestType::MountUpdate) { - bool skip = true; - for (auto& entry : tpk::GetExtractEntries()) { - if (bf::is_directory(path) && path.filename() == entry) { - skip = false; - break; - } - } - if (skip) - continue; - } - - if (bf::is_directory(path) && path.filename() == "bin") { - if (!GrantPermission755(path)) - return Status::GRANT_PERMISSION_ERROR; - for (auto& entry : - boost::make_iterator_range(bf::directory_iterator(path), {})) { - auto path = entry.path(); - if (bf::is_regular_file(path)) { - if (!GrantPermission755(path)) - return Status::GRANT_PERMISSION_ERROR; - } - } - continue; - } - - if (bf::is_directory(path) && path.filename() == "lib") { - if (!GrantPermission755(path)) - return Status::GRANT_PERMISSION_ERROR; - for (auto& entry : - boost::make_iterator_range(bf::directory_iterator(path), {})) { - auto path = entry.path(); - if (bf::is_regular_file(path)) { - if (!GrantPermission644(path)) - return Status::GRANT_PERMISSION_ERROR; - } - } - continue; - } - - if (bf::is_directory(path)) { - if (!GrantPermission755(path)) - return Status::GRANT_PERMISSION_ERROR; - continue; - } - - if (bf::is_regular_file(path)) { - if (!GrantPermission644(path)) - return Status::GRANT_PERMISSION_ERROR; - continue; - } - } - - return status; -} - -} // namespace filesystem -} // namespace tpk - diff --git a/src/tpk/step/filesystem/step_grant_permission.h b/src/tpk/step/filesystem/step_grant_permission.h deleted file mode 100644 index c387437..0000000 --- a/src/tpk/step/filesystem/step_grant_permission.h +++ /dev/null @@ -1,36 +0,0 @@ -// 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 TPK_STEP_FILESYSTEM_STEP_GRANT_PERMISSION_H_ -#define TPK_STEP_FILESYSTEM_STEP_GRANT_PERMISSION_H_ - -#include - -#include - -#include "common/installer_context.h" -#include "common/step/step.h" - -namespace tpk { -namespace filesystem { - -/** - * \brief Step responsible for granting permissions to /bin, /lib - */ -class StepTpkGrantPermission : public common_installer::Step { - public: - using Step::Step; - - Status process() override; - Status undo() override { return Status::OK; } - Status clean() override { return Status::OK; } - Status precheck() override; - - STEP_NAME(GrantPermission) -}; - -} // namespace filesystem -} // namespace tpk - -#endif // TPK_STEP_FILESYSTEM_STEP_GRANT_PERMISSION_H_ diff --git a/src/tpk/tpk_installer.cc b/src/tpk/tpk_installer.cc index ceeda76..148504c 100644 --- a/src/tpk/tpk_installer.cc +++ b/src/tpk/tpk_installer.cc @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include @@ -77,7 +77,6 @@ #include "tpk/step/filesystem/step_create_external_storage_directories.h" #include "tpk/step/filesystem/step_create_symbolic_link.h" #include "tpk/step/filesystem/step_check_pkg_directory_path.h" -#include "tpk/step/filesystem/step_grant_permission.h" #include "tpk/step/filesystem/step_remove_external_storage_directories.h" #include "tpk/step/filesystem/step_tpk_patch_icons.h" #include "tpk/step/filesystem/step_tpk_prepare_package_directory.h" @@ -199,12 +198,11 @@ void TpkInstaller::InstallSteps() { AddStep(); AddStep(); AddStep(); - AddStep(); AddStep(); AddStep( ci::Plugin::ActionType::Install); AddStep(); - AddStep(); + AddStep(); AddStep(); } @@ -240,11 +238,10 @@ void TpkInstaller::UpdateSteps() { AddStep(); AddStep(); AddStep(); - AddStep(); AddStep(); AddStep(); AddStep(ci::Plugin::ActionType::Upgrade); - AddStep(); + AddStep(); AddStep(); } @@ -305,11 +302,10 @@ void TpkInstaller::ReinstallSteps() { AddStep(); AddStep(); AddStep(); - AddStep(); AddStep(); AddStep(); AddStep(ci::Plugin::ActionType::Upgrade); - AddStep(); + AddStep(); AddStep(); } @@ -350,7 +346,7 @@ void TpkInstaller::DeltaSteps() { AddStep(); AddStep(); AddStep(ci::Plugin::ActionType::Upgrade); - AddStep(); + AddStep(); AddStep(); } @@ -413,11 +409,10 @@ void TpkInstaller::MountInstallSteps() { AddStep(); AddStep(); AddStep(); - AddStep(); AddStep( ci::Plugin::ActionType::Install); AddStep(); - AddStep(); + AddStep(); AddStep(); } @@ -454,9 +449,8 @@ void TpkInstaller::MountUpdateSteps() { AddStep(); AddStep(); AddStep(); - AddStep(); AddStep(ci::Plugin::ActionType::Upgrade); - AddStep(); + AddStep(); AddStep(); } @@ -482,10 +476,9 @@ void TpkInstaller::ManifestDirectInstallSteps() { AddStep(); AddStep(); AddStep(); - AddStep(); AddStep(ci::Plugin::ActionType::Install); AddStep(); - AddStep(); + AddStep(); AddStep(); } @@ -510,9 +503,8 @@ void TpkInstaller::ManifestDirectUpdateSteps() { AddStep(); AddStep(); AddStep(); - AddStep(); AddStep(ci::Plugin::ActionType::Upgrade); - AddStep(); + AddStep(); AddStep(); } @@ -596,10 +588,9 @@ void TpkInstaller::ReadonlyUpdateInstallSteps() { AddStep(); AddStep(); AddStep(); - AddStep(); AddStep(); AddStep(ci::Plugin::ActionType::Upgrade); - AddStep(); + AddStep(); AddStep(); }