Fix privilege handling on hybrid installation 21/107221/2
authorSangyoon Jang <s89.jang@samsung.com>
Tue, 27 Dec 2016 07:26:24 +0000 (16:26 +0900)
committerSangyoon Jang <s89.jang@samsung.com>
Tue, 27 Dec 2016 07:38:25 +0000 (16:38 +0900)
To handle privileges properly, it should merge privileges first before
StepPrivilegeCompatibility.

Change-Id: I5e40ebb3374939652d89e258a23051b91cb1781a
Signed-off-by: Sangyoon Jang <s89.jang@samsung.com>
src/hybrid/hybrid_installer.cc
src/hybrid/step/configuration/step_merge_tpk_config.cc
src/hybrid/step/configuration/step_merge_tpk_privileges.cc [new file with mode: 0644]
src/hybrid/step/configuration/step_merge_tpk_privileges.h [new file with mode: 0644]
src/hybrid/step/pkgmgr/step_generate_xml.cc

index e537659..0eebf85 100644 (file)
@@ -77,6 +77,7 @@
 
 #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/pkgmgr/step_generate_xml.h"
@@ -116,6 +117,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<ci::pkgmgr::StepCheckRestriction>();
       AddStep<ci::configuration::StepCheckTizenVersion>();
       AddStep<ci::security::StepCheckSignature>();
+      AddStep<hybrid::configuration::StepMergeTpkPrivileges>();
       AddStep<ci::security::StepPrivilegeCompatibility>(
           ci::security::StepPrivilegeCompatibility::InternalPrivType::BOTH);
       AddStep<wgt::security::StepCheckSettingsLevel>();
@@ -160,6 +162,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<ci::configuration::StepParsePreload>();
       AddStep<ci::configuration::StepCheckTizenVersion>();
       AddStep<ci::security::StepCheckSignature>();
+      AddStep<hybrid::configuration::StepMergeTpkPrivileges>();
       AddStep<ci::security::StepPrivilegeCompatibility>(
           ci::security::StepPrivilegeCompatibility::InternalPrivType::BOTH);
       AddStep<wgt::security::StepCheckSettingsLevel>();
@@ -243,6 +246,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<ci::configuration::StepParsePreload>();
       AddStep<ci::configuration::StepCheckTizenVersion>();
       AddStep<ci::security::StepCheckSignature>();
+      AddStep<hybrid::configuration::StepMergeTpkPrivileges>();
       AddStep<ci::security::StepPrivilegeCompatibility>(
           ci::security::StepPrivilegeCompatibility::InternalPrivType::BOTH);
       AddStep<wgt::security::StepCheckSettingsLevel>();
@@ -309,6 +313,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<ci::pkgmgr::StepCheckRestriction>();
       AddStep<ci::configuration::StepCheckTizenVersion>();
       AddStep<ci::security::StepCheckSignature>();
+      AddStep<hybrid::configuration::StepMergeTpkPrivileges>();
       AddStep<ci::security::StepPrivilegeCompatibility>(
           ci::security::StepPrivilegeCompatibility::InternalPrivType::BOTH);
       AddStep<wgt::security::StepCheckSettingsLevel>();
@@ -353,6 +358,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<ci::configuration::StepParsePreload>();
       AddStep<ci::configuration::StepCheckTizenVersion>();
       AddStep<ci::security::StepCheckSignature>();
+      AddStep<hybrid::configuration::StepMergeTpkPrivileges>();
       AddStep<ci::security::StepPrivilegeCompatibility>(
           ci::security::StepPrivilegeCompatibility::InternalPrivType::BOTH);
       AddStep<wgt::security::StepCheckSettingsLevel>();
@@ -400,6 +406,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<ci::configuration::StepParsePreload>();
       AddStep<ci::configuration::StepCheckTizenVersion>();
       AddStep<ci::security::StepCheckSignature>();
+      AddStep<hybrid::configuration::StepMergeTpkPrivileges>();
       AddStep<ci::security::StepPrivilegeCompatibility>(
           ci::security::StepPrivilegeCompatibility::InternalPrivType::BOTH);
       AddStep<wgt::security::StepCheckSettingsLevel>();
@@ -429,6 +436,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<ci::configuration::StepParsePreload>();
       AddStep<ci::configuration::StepCheckTizenVersion>();
       AddStep<ci::security::StepCheckSignature>();
+      AddStep<hybrid::configuration::StepMergeTpkPrivileges>();
       AddStep<ci::security::StepPrivilegeCompatibility>(
           ci::security::StepPrivilegeCompatibility::InternalPrivType::BOTH);
       AddStep<wgt::security::StepCheckSettingsLevel>();
index 913ad98..15d59c3 100644 (file)
@@ -21,10 +21,6 @@ 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;
 }
 
diff --git a/src/hybrid/step/configuration/step_merge_tpk_privileges.cc b/src/hybrid/step/configuration/step_merge_tpk_privileges.cc
new file mode 100644 (file)
index 0000000..48f13f5
--- /dev/null
@@ -0,0 +1,28 @@
+// 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 <pkgmgrinfo_basic.h>
+
+#include "hybrid/hybrid_backend_data.h"
+
+namespace hybrid {
+namespace configuration {
+
+common_installer::Step::Status StepMergeTpkPrivileges::process() {
+  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
new file mode 100644 (file)
index 0000000..98651fc
--- /dev/null
@@ -0,0 +1,29 @@
+// 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 {
+
+class StepMergeTpkPrivileges : public common_installer::Step {
+ public:
+  using Step::Step;
+
+  Status process() override;
+  Status clean() override { return Status::OK; }
+  Status undo() 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_
index ccb8f16..8ab0826 100644 (file)
@@ -31,10 +31,10 @@ const std::vector<std::string> kBlackListNodes = {
   {"author"},
   {"description"},
   {"profile"},
+  {"privileges"},
 };
 const std::vector<std::string> kNeedMergeNodes = {
   {"manifest"},
-  {"privileges"},
 };
 const std::vector<std::pair<std::string, std::string>> kApplicationNodeNames = {
   {"ui-application", "uiapp"},