+++ /dev/null
-// 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
-
#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>
#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"
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>();
}
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>();
}
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>();
}
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>();
}
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>();
}
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>();
}
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>();
}
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>();
}
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>();
}