move the behavior of StepGrantPermission step to StepChangeOwnershipAndPermission 61/103361/3 accepted/tizen/3.0/common/20161212.060241 accepted/tizen/3.0/ivi/20161212.022737 accepted/tizen/3.0/mobile/20161212.022418 accepted/tizen/3.0/tv/20161212.022632 accepted/tizen/3.0/wearable/20161212.022706 submit/tizen_3.0/20161209.072525
authorjongmyeongko <jongmyeong.ko@samsung.com>
Thu, 8 Dec 2016 06:29:24 +0000 (15:29 +0900)
committerjongmyeongko <jongmyeong.ko@samsung.com>
Thu, 8 Dec 2016 13:00:20 +0000 (22:00 +0900)
Submit with :
https://review.tizen.org/gerrit/#/c/103359/
https://review.tizen.org/gerrit/#/c/103512/

Change-Id: Ideb73e83f2f4c92bd5a33e06242f9c73a873eb62
Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
src/tpk/step/filesystem/step_grant_permission.cc [deleted file]
src/tpk/step/filesystem/step_grant_permission.h [deleted file]
src/tpk/tpk_installer.cc

diff --git a/src/tpk/step/filesystem/step_grant_permission.cc b/src/tpk/step/filesystem/step_grant_permission.cc
deleted file mode 100644 (file)
index 580bf6b..0000000
+++ /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 <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-#include <boost/range/iterator_range.hpp>
-#include <boost/system/error_code.hpp>
-
-#include <common/utils/file_util.h>
-
-#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 (file)
index c387437..0000000
+++ /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 <manifest_parser/utils/logging.h>
-
-#include <string>
-
-#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_
index ceeda76..148504c 100644 (file)
@@ -15,7 +15,7 @@
 #include <common/step/configuration/step_switch_readonly_mode.h>
 #include <common/step/filesystem/step_acquire_external_storage.h>
 #include <common/step/filesystem/step_optional_acquire_external_storage.h>
-#include <common/step/filesystem/step_change_owner.h>
+#include <common/step/filesystem/step_change_ownership_and_permission.h>
 #include <common/step/filesystem/step_clear_data.h>
 #include <common/step/filesystem/step_copy.h>
 #include <common/step/filesystem/step_copy_storage_directories.h>
@@ -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<ci::security::StepRegisterSecurity>();
   AddStep<tpk::pkgmgr::StepConvertXml>();
   AddStep<tpk::pkgmgr::StepManifestAdjustment>();
-  AddStep<tpk::filesystem::StepTpkGrantPermission>();
   AddStep<ci::pkgmgr::StepRegisterApplication>();
   AddStep<ci::pkgmgr::StepRunParserPlugin>(
       ci::Plugin::ActionType::Install);
   AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>();
-  AddStep<ci::filesystem::StepChangeOwner>();
+  AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
   AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
 }
 
@@ -240,11 +238,10 @@ void TpkInstaller::UpdateSteps() {
   AddStep<ci::filesystem::StepCreateIcons>();
   AddStep<ci::security::StepUpdateSecurity>();
   AddStep<tpk::pkgmgr::StepConvertXml>();
-  AddStep<tpk::filesystem::StepTpkGrantPermission>();
   AddStep<tpk::pkgmgr::StepManifestAdjustment>();
   AddStep<ci::pkgmgr::StepUpdateApplication>();
   AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
-  AddStep<ci::filesystem::StepChangeOwner>();
+  AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
   AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
 }
 
@@ -305,11 +302,10 @@ void TpkInstaller::ReinstallSteps() {
   AddStep<tpk::filesystem::StepUpdateExternalStorageDirectories>();
   AddStep<ci::security::StepUpdateSecurity>();
   AddStep<tpk::pkgmgr::StepConvertXml>();
-  AddStep<tpk::filesystem::StepTpkGrantPermission>();
   AddStep<tpk::pkgmgr::StepManifestAdjustment>();
   AddStep<ci::pkgmgr::StepUpdateApplication>();
   AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
-  AddStep<ci::filesystem::StepChangeOwner>();
+  AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
   AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
 }
 
@@ -350,7 +346,7 @@ void TpkInstaller::DeltaSteps() {
   AddStep<tpk::pkgmgr::StepConvertXml>();
   AddStep<ci::pkgmgr::StepUpdateApplication>();
   AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
-  AddStep<ci::filesystem::StepChangeOwner>();
+  AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
   AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
 }
 
@@ -413,11 +409,10 @@ void TpkInstaller::MountInstallSteps() {
   AddStep<tpk::pkgmgr::StepConvertXml>();
   AddStep<tpk::pkgmgr::StepManifestAdjustment>();
   AddStep<ci::pkgmgr::StepRegisterApplication>();
-  AddStep<tpk::filesystem::StepTpkGrantPermission>();
   AddStep<ci::pkgmgr::StepRunParserPlugin>(
       ci::Plugin::ActionType::Install);
   AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>();
-  AddStep<ci::filesystem::StepChangeOwner>();
+  AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
   AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
 }
 
@@ -454,9 +449,8 @@ void TpkInstaller::MountUpdateSteps() {
   AddStep<tpk::pkgmgr::StepConvertXml>();
   AddStep<tpk::pkgmgr::StepManifestAdjustment>();
   AddStep<ci::pkgmgr::StepUpdateApplication>();
-  AddStep<tpk::filesystem::StepTpkGrantPermission>();
   AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
-  AddStep<ci::filesystem::StepChangeOwner>();
+  AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
   AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
 }
 
@@ -482,10 +476,9 @@ void TpkInstaller::ManifestDirectInstallSteps() {
   AddStep<ci::security::StepRollbackInstallationSecurity>();
   AddStep<ci::security::StepRegisterSecurity>();
   AddStep<ci::pkgmgr::StepRegisterApplication>();
-  AddStep<tpk::filesystem::StepTpkGrantPermission>();
   AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Install);
   AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>();
-  AddStep<ci::filesystem::StepChangeOwner>();
+  AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
   AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
 }
 
@@ -510,9 +503,8 @@ void TpkInstaller::ManifestDirectUpdateSteps() {
   AddStep<ci::security::StepRollbackInstallationSecurity>();
   AddStep<ci::security::StepRegisterSecurity>();
   AddStep<ci::pkgmgr::StepUpdateApplication>();
-  AddStep<tpk::filesystem::StepTpkGrantPermission>();
   AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
-  AddStep<ci::filesystem::StepChangeOwner>();
+  AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
   AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
 }
 
@@ -596,10 +588,9 @@ void TpkInstaller::ReadonlyUpdateInstallSteps() {
   AddStep<ci::security::StepUpdateSecurity>();
   AddStep<tpk::pkgmgr::StepConvertXml>();
   AddStep<tpk::pkgmgr::StepManifestAdjustment>();
-  AddStep<tpk::filesystem::StepTpkGrantPermission>();
   AddStep<ci::pkgmgr::StepUpdateApplication>();
   AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
-  AddStep<ci::filesystem::StepChangeOwner>();
+  AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
   AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
 }