Revert "Fix checking privilege level for hybrid apps" 60/90560/4
authorTomasz Iwanek <t.iwanek@samsung.com>
Fri, 30 Sep 2016 08:48:38 +0000 (10:48 +0200)
committerjongmyeong ko <jongmyeong.ko@samsung.com>
Thu, 3 Nov 2016 13:44:37 +0000 (06:44 -0700)
Following commit will reimplement this bug fix.

This reverts commit 3002913a84371529abcb09bc7f51857bd3a3899a.

Change-Id: I6334d50351fe49daedf543322738b102de2444f5

src/hybrid/CMakeLists.txt
src/hybrid/hybrid_installer.cc
src/hybrid/step/configuration/step_merge_tpk_config.cc
src/hybrid/step/configuration/step_merge_tpk_config.h
src/hybrid/step/configuration/step_merge_tpk_privileges.cc [deleted file]
src/hybrid/step/configuration/step_merge_tpk_privileges.h [deleted file]
src/hybrid/step/security/step_hybrid_check_signature.cc [deleted file]
src/hybrid/step/security/step_hybrid_check_signature.h [deleted file]

index bc950d51ea5711f61ded541980347ba8124e93f6..ccc7f4ae5c6aab07fcdbf25bd392ec511db78902 100644 (file)
@@ -1,9 +1,7 @@
 SET(SRCS
   step/configuration/step_merge_tpk_config.cc
-  step/configuration/step_merge_tpk_privileges.cc
   step/configuration/step_stash_tpk_config.cc
   step/encryption/step_encrypt_resources.cc
-  step/security/step_hybrid_check_signature.cc
   hybrid_installer.cc
 )
 ADD_LIBRARY(${TARGET_LIBNAME_HYBRID} STATIC ${SRCS})
index e98f992273dbcf76e5f4ad4e13752688f40de5a8..1a0e76f3a510ee79dbdb824153fdaa4adc9d26c1 100644 (file)
@@ -57,6 +57,7 @@
 #include <common/step/pkgmgr/step_update_app.h>
 #include <common/step/pkgmgr/step_update_pkg_disable_info.h>
 #include <common/step/recovery/step_open_recovery_file.h>
+#include <common/step/security/step_check_signature.h>
 #include <common/step/security/step_privilege_compatibility.h>
 #include <common/step/security/step_recover_security.h>
 #include <common/step/security/step_register_security.h>
 
 #include "hybrid/hybrid_backend_data.h"
 #include "hybrid/step/configuration/step_merge_tpk_config.h"
-#include "hybrid/step/configuration/step_merge_tpk_privileges.h"
 #include "hybrid/step/configuration/step_stash_tpk_config.h"
 #include "hybrid/step/encryption/step_encrypt_resources.h"
-#include "hybrid/step/security/step_hybrid_check_signature.h"
 #include "wgt/step/configuration/step_parse.h"
 #include "wgt/step/encryption/step_remove_encryption_data.h"
 #include "wgt/step/filesystem/step_copy_preview_icons.h"
@@ -111,8 +110,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<ci::configuration::StepParsePreload>();
       AddStep<ci::pkgmgr::StepCheckRestriction>();
       AddStep<ci::configuration::StepCheckTizenVersion>();
-      AddStep<hybrid::security::StepHybridCheckSignature>();
-      AddStep<hybrid::configuration::StepMergeTpkPrivileges>();
+      AddStep<ci::security::StepCheckSignature>();
       AddStep<ci::security::StepPrivilegeCompatibility>();
       AddStep<wgt::security::StepCheckSettingsLevel>();
       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
@@ -153,8 +151,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<hybrid::configuration::StepMergeTpkConfig>();
       AddStep<ci::configuration::StepParsePreload>();
       AddStep<ci::configuration::StepCheckTizenVersion>();
-      AddStep<hybrid::security::StepHybridCheckSignature>();
-      AddStep<hybrid::configuration::StepMergeTpkPrivileges>();
+      AddStep<ci::security::StepCheckSignature>();
       AddStep<ci::security::StepPrivilegeCompatibility>();
       AddStep<wgt::security::StepCheckSettingsLevel>();
       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
@@ -234,8 +231,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
           wgt::configuration::StepParse::ConfigLocation::RESOURCE_WGT, true);
       AddStep<hybrid::configuration::StepMergeTpkConfig>();
       AddStep<ci::configuration::StepCheckTizenVersion>();
-      AddStep<hybrid::security::StepHybridCheckSignature>();
-      AddStep<hybrid::configuration::StepMergeTpkPrivileges>();
+      AddStep<ci::security::StepCheckSignature>();
       AddStep<ci::security::StepPrivilegeCompatibility>();
       AddStep<wgt::security::StepCheckSettingsLevel>();
       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
@@ -305,8 +301,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<ci::configuration::StepParsePreload>();
       AddStep<ci::pkgmgr::StepCheckRestriction>();
       AddStep<ci::configuration::StepCheckTizenVersion>();
-      AddStep<hybrid::security::StepHybridCheckSignature>();
-      AddStep<hybrid::configuration::StepMergeTpkPrivileges>();
+      AddStep<ci::security::StepCheckSignature>();
       AddStep<ci::security::StepPrivilegeCompatibility>();
       AddStep<wgt::security::StepCheckSettingsLevel>();
       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
@@ -347,8 +342,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<hybrid::configuration::StepMergeTpkConfig>();
       AddStep<ci::configuration::StepParsePreload>();
       AddStep<ci::configuration::StepCheckTizenVersion>();
-      AddStep<hybrid::security::StepHybridCheckSignature>();
-      AddStep<hybrid::configuration::StepMergeTpkPrivileges>();
+      AddStep<ci::security::StepCheckSignature>();
       AddStep<ci::security::StepPrivilegeCompatibility>();
       AddStep<wgt::security::StepCheckSettingsLevel>();
       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
@@ -393,8 +387,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<hybrid::configuration::StepMergeTpkConfig>();
       AddStep<ci::configuration::StepParsePreload>();
       AddStep<ci::configuration::StepCheckTizenVersion>();
-      AddStep<hybrid::security::StepHybridCheckSignature>();
-      AddStep<hybrid::configuration::StepMergeTpkPrivileges>();
+      AddStep<ci::security::StepCheckSignature>();
       AddStep<ci::security::StepPrivilegeCompatibility>();
       AddStep<wgt::security::StepCheckSettingsLevel>();
       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
@@ -421,8 +414,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<hybrid::configuration::StepMergeTpkConfig>();
       AddStep<ci::configuration::StepParsePreload>();
       AddStep<ci::configuration::StepCheckTizenVersion>();
-      AddStep<hybrid::security::StepHybridCheckSignature>();
-      AddStep<hybrid::configuration::StepMergeTpkPrivileges>();
+      AddStep<ci::security::StepCheckSignature>();
       AddStep<ci::security::StepPrivilegeCompatibility>();
       AddStep<wgt::security::StepCheckSettingsLevel>();
       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
index 15d59c35e1a38ac7b6b45723e5920964ed18df38..913ad9845cf25bb2e794849d37021c3357eef0c6 100644 (file)
@@ -21,6 +21,10 @@ common_installer::Step::Status StepMergeTpkConfig::process() {
       g_list_concat(wgt_data->application, tpk_data->application);
   tpk_data->application = nullptr;
 
+  wgt_data->privileges =
+      g_list_concat(wgt_data->privileges, tpk_data->privileges);
+  tpk_data->privileges = nullptr;
+
   return Status::OK;
 }
 
index 623eba560fd2c1f7157b0c10535fb1afb67caa14..2171d59a96a0c992980877f1d1df306eeb7fe4bc 100644 (file)
@@ -15,9 +15,6 @@ namespace configuration {
  * \brief MergeTpkConfig
  *        Merges information from tpk manifest into information from widget
  *        configuration for hybrid package.
- *
- * Expection is the information about native privileges. These are merged in
- * \see StepMergeTpkPrivileges
  */
 class StepMergeTpkConfig : public common_installer::Step {
  public:
diff --git a/src/hybrid/step/configuration/step_merge_tpk_privileges.cc b/src/hybrid/step/configuration/step_merge_tpk_privileges.cc
deleted file mode 100644 (file)
index ef763d6..0000000
+++ /dev/null
@@ -1,27 +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.
-
-#include "hybrid/step/configuration/step_merge_tpk_privileges.h"
-
-#include "hybrid/hybrid_backend_data.h"
-
-namespace ci = common_installer;
-
-namespace hybrid {
-namespace configuration {
-
-ci::Step::Status StepMergeTpkPrivileges::process() {
-  // merge privilege list for insertion into database
-  HybridBackendData* data =
-      static_cast<HybridBackendData*>(context_->backend_data.get());
-  manifest_x* tpk_data = data->tpk_manifest_data.get();
-  manifest_x* wgt_data = context_->manifest_data.get();
-  wgt_data->privileges =
-      g_list_concat(wgt_data->privileges, tpk_data->privileges);
-  tpk_data->privileges = nullptr;
-  return Status::OK;
-}
-
-}  // namespace configuration
-}  // namespace hybrid
diff --git a/src/hybrid/step/configuration/step_merge_tpk_privileges.h b/src/hybrid/step/configuration/step_merge_tpk_privileges.h
deleted file mode 100644 (file)
index 0afe851..0000000
+++ /dev/null
@@ -1,34 +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 HYBRID_STEP_CONFIGURATION_STEP_MERGE_TPK_PRIVILEGES_H_
-#define HYBRID_STEP_CONFIGURATION_STEP_MERGE_TPK_PRIVILEGES_H_
-
-#include <common/step/step.h>
-#include <manifest_parser/utils/logging.h>
-
-namespace hybrid {
-namespace configuration {
-
-/**
- * @brief The StepMergeTpkPrivileges class
- *        Merges native privileges into web applicaiton privileges when
- *        installing hybrid app.
- */
-class StepMergeTpkPrivileges : 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 { return Status::OK; }
-
-  STEP_NAME(MergeTpkPrivileges)
-};
-
-}  // namespace configuration
-}  // namespace hybrid
-
-#endif  // HYBRID_STEP_CONFIGURATION_STEP_MERGE_TPK_PRIVILEGES_H_
diff --git a/src/hybrid/step/security/step_hybrid_check_signature.cc b/src/hybrid/step/security/step_hybrid_check_signature.cc
deleted file mode 100644 (file)
index b71717f..0000000
+++ /dev/null
@@ -1,51 +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.
-
-#include "hybrid/step/security/step_hybrid_check_signature.h"
-
-#include <common/certificate_validation.h>
-
-#include <string>
-
-#include "hybrid/hybrid_backend_data.h"
-
-namespace ci = common_installer;
-
-namespace {
-
-const char kNativePackageType[] = "tpk";
-
-}  // namespace
-
-namespace hybrid {
-namespace security {
-
-ci::Step::Status StepHybridCheckSignature::CheckPrivilegeLevel(
-    ci::PrivilegeLevel level) {
-  auto status = StepCheckSignature::CheckPrivilegeLevel(level);
-  if (status != Status::OK)
-    return status;
-
-  HybridBackendData* data =
-      static_cast<HybridBackendData*>(context_->backend_data.get());
-  manifest_x* tpk_data = data->tpk_manifest_data.get();
-  if (tpk_data->privileges) {
-    std::string error_message;
-    if (!context_->is_preload_request.get()) {
-      if (!ci::ValidatePrivilegeLevel(level, kNativePackageType,
-          tpk_data->api_version, tpk_data->privileges, &error_message)) {
-        if (!error_message.empty()) {
-          LOG(ERROR) << "error_message: " << error_message;
-          on_error(Status::SIGNATURE_ERROR, error_message);
-        }
-        return Status::SIGNATURE_ERROR;
-      }
-    }
-  }
-
-  return Status::OK;
-}
-
-}  // namespace security
-}  // namespace hybrid
diff --git a/src/hybrid/step/security/step_hybrid_check_signature.h b/src/hybrid/step/security/step_hybrid_check_signature.h
deleted file mode 100644 (file)
index d867700..0000000
+++ /dev/null
@@ -1,27 +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 HYBRID_STEP_SECURITY_STEP_HYBRID_CHECK_SIGNATURE_H_
-#define HYBRID_STEP_SECURITY_STEP_HYBRID_CHECK_SIGNATURE_H_
-
-#include <common/step/security/step_check_signature.h>
-#include <common/step/step.h>
-
-namespace hybrid {
-namespace security {
-
-class StepHybridCheckSignature
-    : public common_installer::security::StepCheckSignature {
- public:
-  using StepCheckSignature::StepCheckSignature;
-
-  Status CheckPrivilegeLevel(common_installer::PrivilegeLevel level) override;
-
-  STEP_NAME(HybridCheckSignature)
-};
-
-}  // namespace security
-}  // namespace hybrid
-
-#endif  // HYBRID_STEP_SECURITY_STEP_HYBRID_CHECK_SIGNATURE_H_