step/configuration/step_parse_preload.cc
step/filesystem/step_check_pkg_directory_path.cc
step/filesystem/step_create_symbolic_link.cc
+ step/filesystem/step_grant_permission.cc
step/filesystem/step_tpk_patch_icons.cc
step/filesystem/step_tpk_prepare_package_directory.cc
step/filesystem/step_tpk_update_package_directory.cc
--- /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>
+
+namespace bf = boost::filesystem;
+namespace bs = boost::system;
+namespace ci = common_installer;
+
+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();
+ for (auto& entry :
+ boost::make_iterator_range(bf::directory_iterator(app_root), {})) {
+ auto path = entry.path();
+
+ if (bf::is_directory(path) && path.filename() == "bin") {
+ for (auto& entry :
+ boost::make_iterator_range(bf::directory_iterator(path), {})) {
+ if (bf::is_regular_file(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) << "Grand permission error" << " path: " << path
+ << " permission: " << permission;
+ return Status::ERROR; /* temp error, TODO */
+ }
+ }
+ }
+ continue;
+ }
+
+ if (bf::is_directory(path) && path.filename() == "lib") {
+ for (auto& entry :
+ boost::make_iterator_range(bf::directory_iterator(path), {})) {
+ if (bf::is_regular_file(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) << "Grand permission error" << " path: " << path
+ << " permission: " << permission;
+ return Status::ERROR;
+ }
+ }
+ }
+ continue;
+ }
+
+ if (bf::is_directory(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) << "Grand permission error" << " path: " << path
+ << " permission: " << permission;
+ return Status::ERROR;
+ }
+ continue;
+ }
+
+ if (bf::is_regular_file(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) << "Grand permission error" << " path: " << path
+ << " permission: " << permission;
+ return Status::ERROR;
+ }
+ continue;
+ }
+ }
+
+ return status;
+}
+
+} // namespace filesystem
+} // namespace tpk
+
--- /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 TPK_STEP_FILESYSTEM_TPK_GRANT_PERMISSION_H_
+#define TPK_STEP_FILESYSTEM_TPK_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;
+
+ SCOPE_LOG_TAG(GrantPermission)
+};
+
+} // namespace filesystem
+} // namespace tpk
+
+#endif // TPK_STEP_FILESYSTEM_TPK_GRANT_PERMISSION_H_
#include "tpk/step/configuration/step_parse_preload.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_tpk_patch_icons.h"
#include "tpk/step/filesystem/step_tpk_prepare_package_directory.h"
#include "tpk/step/filesystem/step_tpk_update_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::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::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<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<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::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::security::StepRollbackInstallationSecurity>();
AddStep<ci::security::StepRegisterSecurity>();
AddStep<ci::pkgmgr::StepUpdateApplication>();
+ AddStep<tpk::filesystem::StepTpkGrantPermission>();
AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
}