Do not allow move operation for internal-only packages 91/76991/7
authorSangyoon Jang <s89.jang@samsung.com>
Tue, 28 Jun 2016 07:56:54 +0000 (16:56 +0900)
committerSangyoon Jang <s89.jang@samsung.com>
Tue, 2 Aug 2016 07:43:55 +0000 (00:43 -0700)
Change-Id: I46b82272c6831f362c67f0b6eb3b55cc1850cc5d
Signed-off-by: Sangyoon Jang <s89.jang@samsung.com>
src/common/step/filesystem/step_move_installed_storage.cc
src/common/step/filesystem/step_move_installed_storage.h

index b85dfa5..512dae8 100644 (file)
@@ -9,6 +9,7 @@
 #include <tzplatform_config.h>
 
 #include <string>
+#include <cstring>
 
 #include "common/paths.h"
 #include "common/external_storage.h"
 namespace bf = boost::filesystem;
 namespace bs = boost::system;
 
+namespace {
+
+const char kInternalOnly[] = "internal-only";
+
+}  // namespace
+
 namespace common_installer {
 namespace filesystem {
 
@@ -61,6 +68,18 @@ Step::Status StepMoveInstalledStorage::clean() {
   return Status::OK;
 }
 
+Step::Status StepMoveInstalledStorage::precheck() {
+  if (context_->manifest_data.get()->installlocation == nullptr) {
+    LOG(ERROR) << "Cannot get installlocation value";
+    return Status::INVALID_VALUE;
+  }
+  if (!strcmp(context_->manifest_data.get()->installlocation, kInternalOnly)) {
+    LOG(ERROR) << "This package is interanl-only";
+    return Status::OPERATION_NOT_ALLOWED;
+  }
+  return Status::OK;
+}
+
 void StepMoveInstalledStorage::SetTepPaths() {
   old_location_ = context_->manifest_data.get()->tep_name;
   if (context_->is_move_to_external.get()) {
index a064976..4ea0a34 100644 (file)
@@ -19,7 +19,7 @@ class StepMoveInstalledStorage : public Step {
 
   Status clean() override;
   Status undo() override;
-  Status precheck() override { return Status::OK; }
+  Status precheck() override;
 
  private:
   void SetTepPaths();