skip granting permissions in case of some paths, 15/72415/7 accepted/tizen/common/20160606.141601 accepted/tizen/ivi/20160602.230740 accepted/tizen/mobile/20160602.230721 accepted/tizen/tv/20160602.230703 accepted/tizen/wearable/20160602.230638 submit/tizen/20160602.040935
authorjongmyeongko <jongmyeong.ko@samsung.com>
Wed, 1 Jun 2016 01:41:47 +0000 (10:41 +0900)
committerjongmyeongko <jongmyeong.ko@samsung.com>
Thu, 2 Jun 2016 01:23:24 +0000 (10:23 +0900)
which are related to mount or directories installer create.

this fix mount-install and external-install failure.

Change-Id: I435a6c8d781b2ddd90f83852ab46eb9fd1f35af7
Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
src/tpk/CMakeLists.txt
src/tpk/step/filesystem/step_grant_permission.cc
src/tpk/step/filesystem/step_grant_permission.h
src/tpk/step/filesystem/step_tpk_prepare_package_directory.cc
src/tpk/step/filesystem/step_tpk_prepare_package_directory.h
src/tpk/step/filesystem/step_tpk_update_package_directory.cc
src/tpk/step/rds/step_tpk_rds_modify.h
src/tpk/tpk_mount_path.cc [new file with mode: 0644]
src/tpk/tpk_mount_path.h [new file with mode: 0644]

index ae8bd82b714245912e5a238f8a1895aad33a06d4..d97ee3fdeb695f6f6748a929229ae707935813a7 100644 (file)
@@ -1,4 +1,5 @@
 SET(SRCS
+  tpk_mount_path.cc
   step/configuration/step_parse_preload.cc
   step/filesystem/step_check_pkg_directory_path.cc
   step/filesystem/step_create_symbolic_link.cc
index d19477ff652859d81cb493a12048f18f7f157e19..56fddb88ee3dbcbb1ccf8a402a6e03d1841e136e 100644 (file)
@@ -11,6 +11,8 @@
 
 #include <common/utils/file_util.h>
 
+#include "tpk/tpk_mount_path.h"
+
 namespace bf = boost::filesystem;
 namespace bs = boost::system;
 namespace ci = common_installer;
@@ -36,6 +38,26 @@ ci::Step::Status StepTpkGrantPermission::process() {
       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") {
       auto permission = bf::perms::owner_all |
           bf::perms::group_read | bf::perms::group_exe |
index 2dac33977957df47b27ab92f8b7c4f33cda4ab97..b6776cd3dc530d26ddf5af03b9b378141eb5a230 100644 (file)
@@ -2,9 +2,8 @@
 // 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_
+#ifndef TPK_STEP_FILESYSTEM_STEP_GRANT_PERMISSION_H_
+#define TPK_STEP_FILESYSTEM_STEP_GRANT_PERMISSION_H_
 
 #include <manifest_parser/utils/logging.h>
 
@@ -34,4 +33,4 @@ class StepTpkGrantPermission : public common_installer::Step {
 }  // namespace filesystem
 }  // namespace tpk
 
-#endif  // TPK_STEP_FILESYSTEM_TPK_GRANT_PERMISSION_H_
+#endif  // TPK_STEP_FILESYSTEM_STEP_GRANT_PERMISSION_H_
index b0e1a762bf414ae5fff92da5f411fa833c17ef01..83dd70024dff383a8647ae49d4c9dffce968387b 100644 (file)
 #include <common/backup_paths.h>
 #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 {
-
-const std::vector<std::string> kExtractEntries = {
-  "bin",
-  "lib",
-  "shared/res"
-};
-
-const std::vector<std::string> kSymlinkEntries = {
-  "res",
-  "tizen-manifest.xml",
-  "author-signature.xml",
-  "signature1.xml",
-  "signature2.xml"
-};
-
-}  // namespace
-
 namespace tpk {
 namespace filesystem {
 
@@ -80,7 +64,7 @@ ci::Step::Status StepTpkPreparePackageDirectory::PrepareLink(
 
 ci::Step::Status StepTpkPreparePackageDirectory::ExtractEntries() {
   LOG(DEBUG) << "Extracting entries from zip package...";
-  for (auto& entry : GetExtractEntries()) {
+  for (auto& entry : tpk::GetExtractEntries()) {
     LOG(DEBUG) << "Extracting: " << entry;
     auto status = PrepareDirectory(entry);
     if (status != Status::OK)
@@ -92,7 +76,7 @@ ci::Step::Status StepTpkPreparePackageDirectory::ExtractEntries() {
 ci::Step::Status StepTpkPreparePackageDirectory::PrepareLinks() {
   bf::path mount_point = ci::GetMountLocation(context_->pkg_path.get());
   LOG(DEBUG) << "Creating symlinks to zip package...";
-  for (auto& link_entry : kSymlinkEntries) {
+  for (auto& link_entry : tpk::GetSymlinkEntries()) {
     LOG(DEBUG) << "Symlink: " << link_entry;
     auto status = PrepareLink(link_entry, mount_point);
     if (status != Status::OK)
@@ -116,10 +100,5 @@ ci::Step::Status StepTpkPreparePackageDirectory::precheck() {
   return Status::OK;
 }
 
-const std::vector<std::string>&
-StepTpkPreparePackageDirectory::GetExtractEntries() const {
-  return kExtractEntries;
-}
-
 }  // namespace filesystem
 }  // namespace tpk
index 059feb1b61039592103d2621c74ee53983ff8e6a..3437666e4a38e105da947fc4c535a7bf95d041fb 100644 (file)
@@ -53,7 +53,6 @@ class StepTpkPreparePackageDirectory : public common_installer::Step {
   Status ExtractEntries();
   Status PrepareLink(const std::string& entry,
                      const boost::filesystem::path& mount_point);
-  const std::vector<std::string>& GetExtractEntries() const;
 
   SCOPE_LOG_TAG(TpkPreparePackageDirectory)
 };
index 835e1cd4d3639d64e0fb86ef4604a6fca3842f90..d2f34b52d87d1d3f3b014619d7c3fd45254783a3 100644 (file)
@@ -12,6 +12,8 @@
 
 #include <vector>
 
+#include "tpk/tpk_mount_path.h"
+
 namespace bf = boost::filesystem;
 namespace bs = boost::system;
 namespace ci = common_installer;
@@ -66,7 +68,7 @@ ci::Step::Status StepTpkUpdatePackageDirectory::RestoreDirectory(
 ci::Step::Status StepTpkUpdatePackageDirectory::BackupEntries() {
   bf::path backup_path =
       ci::GetBackupPathForPackagePath(context_->pkg_path.get());
-  for (auto& entry : GetExtractEntries()) {
+  for (auto& entry : tpk::GetExtractEntries()) {
     auto status = BackupDirectory(entry, backup_path);
     if (status != Status::OK)
       return status;
@@ -102,7 +104,7 @@ ci::Step::Status StepTpkUpdatePackageDirectory::undo() {
   bf::path backup_path =
       ci::GetBackupPathForPackagePath(context_->pkg_path.get());
 
-  for (auto& entry : GetExtractEntries()) {
+  for (auto& entry : tpk::GetExtractEntries()) {
     auto status = RestoreDirectory(entry, backup_path);
     if (status != Status::OK)
       return status;
index 387779c98a8a8f13aeabb1e50923830685bdf022..9d8b5a2ba0f4ae92e36bb5af723938f9d16fc359 100644 (file)
@@ -31,4 +31,4 @@ class StepTpkRDSModify : public common_installer::rds::StepRDSModify {
 }  // namespace rds
 }  // namespace tpk
 
-#endif // TPK_STEP_RDS_STEP_TPK_RDS_MODIFY_H_
+#endif  // TPK_STEP_RDS_STEP_TPK_RDS_MODIFY_H_
diff --git a/src/tpk/tpk_mount_path.cc b/src/tpk/tpk_mount_path.cc
new file mode 100644 (file)
index 0000000..947dd5e
--- /dev/null
@@ -0,0 +1,38 @@
+// 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 "tpk/tpk_mount_path.h"
+
+#include <unistd.h>
+#include <sys/types.h>
+
+namespace {
+
+const std::vector<std::string> kExtractEntries = {
+  "bin",
+  "lib",
+  "shared/res"
+};
+
+const std::vector<std::string> kSymlinkEntries = {
+  "res",
+  "tizen-manifest.xml",
+  "author-signature.xml",
+  "signature1.xml",
+  "signature2.xml"
+};
+
+}  // namespace
+
+namespace tpk {
+
+const std::vector<std::string>& GetExtractEntries() {
+  return kExtractEntries;
+}
+
+const std::vector<std::string>& GetSymlinkEntries() {
+  return kSymlinkEntries;
+}
+
+}  // namespace tpk
diff --git a/src/tpk/tpk_mount_path.h b/src/tpk/tpk_mount_path.h
new file mode 100644 (file)
index 0000000..aceada8
--- /dev/null
@@ -0,0 +1,18 @@
+// 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_TPK_MOUNT_PATH_H_
+#define TPK_TPK_MOUNT_PATH_H_
+
+#include <string>
+#include <vector>
+
+namespace tpk {
+
+const std::vector<std::string>& GetExtractEntries();
+const std::vector<std::string>& GetSymlinkEntries();
+
+}  // namespace tpk
+
+#endif  // TPK_TPK_MOUNT_PATH_H_