From 288ef1465c33ed345e0323e6040b4ddee3bbeaaa Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Mon, 3 Jul 2017 16:58:48 +0900 Subject: [PATCH] Add new steps for trust anchor - Add StepRegisterTrustAnchor to install requests - Add StepUnregisterTrustAnchor to uninstall requests - Add StepUpdateTrustAnchor to update requests Related changes: [tpk-manifest-handlers] : https://review.tizen.org/gerrit/136315 [app-installers] : https://review.tizen.org/gerrit/136316 [pkgmgr-info] : https://review.tizen.org/gerrit/136317 [wgt-manifest-handlers] : https://review.tizen.org/gerrit/136866 [tpk-backend] : https://review.tizen.org/gerrit/137370 Change-Id: I3ff3dd724d444a7036746377b7c43da2788df2ac Signed-off-by: Junghyun Yeon --- src/wgt/step/configuration/step_parse.cc | 27 +++++++++++++++++++++++++++ src/wgt/step/configuration/step_parse.h | 1 + src/wgt/step/pkgmgr/step_generate_xml.cc | 17 ++++++++++++++++- src/wgt/step/pkgmgr/step_generate_xml.h | 1 + src/wgt/wgt_backend_data.h | 2 ++ src/wgt/wgt_installer.cc | 17 +++++++++++++++++ 6 files changed, 64 insertions(+), 1 deletion(-) diff --git a/src/wgt/step/configuration/step_parse.cc b/src/wgt/step/configuration/step_parse.cc index f1825e2..47605b4 100644 --- a/src/wgt/step/configuration/step_parse.cc +++ b/src/wgt/step/configuration/step_parse.cc @@ -508,6 +508,31 @@ bool StepParse::FillBackgroundCategoryInfo(manifest_x* manifest) { return true; } +bool StepParse::FillTrustAnchorInfo(manifest_x* manifest) { + auto trust_anchor_info = parser_->GetManifestData( + app_keys::kTizenTrustAnchorKey); + + if (!trust_anchor_info) + return true; + + std::shared_ptr trust_anchor = + std::static_pointer_cast + (trust_anchor_info); + + if (!trust_anchor) + return true; + + std::string certs_dir = trust_anchor->get_certs_dir(); + if (!certs_dir.empty()) + manifest->pkg_certs_dir = strdup(certs_dir.c_str()); + + std::string use_system_certs = trust_anchor->get_use_system_certs(); + if (!use_system_certs.empty()) + manifest->use_system_certs = strdup(use_system_certs.c_str()); + + return true; +} + bool StepParse::FillAppControl(manifest_x* manifest) { auto app_info_list = GetManifestDataForKey( @@ -717,6 +742,8 @@ bool StepParse::FillManifestX(manifest_x* manifest) { return false; if (!FillBackgroundCategoryInfo(manifest)) return false; + if (!FillTrustAnchorInfo(manifest)) + return false; // Fill data for other applications if (!FillAdditionalApplications(manifest)) diff --git a/src/wgt/step/configuration/step_parse.h b/src/wgt/step/configuration/step_parse.h index 10e5f9e..e875f77 100644 --- a/src/wgt/step/configuration/step_parse.h +++ b/src/wgt/step/configuration/step_parse.h @@ -74,6 +74,7 @@ class StepParse : public common_installer::Step { bool FillBackgroundCategoryInfo(manifest_x* manifest); bool FillAdditionalApplications(manifest_x* manifest); bool FillManifestX(manifest_x* manifest); + bool FillTrustAnchorInfo(manifest_x* manifest); std::unique_ptr parser_; ConfigLocation config_location_; diff --git a/src/wgt/step/pkgmgr/step_generate_xml.cc b/src/wgt/step/pkgmgr/step_generate_xml.cc index e7e8235..6743f2a 100644 --- a/src/wgt/step/pkgmgr/step_generate_xml.cc +++ b/src/wgt/step/pkgmgr/step_generate_xml.cc @@ -391,7 +391,7 @@ common_installer::Step::Status StepGenerateXml::GenerateManifestElement( GenerateIme(writer); GenerateProfiles(writer); GenerateShortcuts(writer); - + GenerateTrustAnchor(writer); xmlTextWriterEndElement(writer); return Status::OK; } @@ -675,5 +675,20 @@ void StepGenerateXml::GenerateShortcuts(xmlTextWriterPtr writer) { } } +void StepGenerateXml::GenerateTrustAnchor(xmlTextWriterPtr writer) { + if (!context_->manifest_data.get()->pkg_certs_dir || + !context_->manifest_data.get()->use_system_certs) + return; + + xmlTextWriterStartElement(writer, BAD_CAST "trust-anchor"); + xmlTextWriterWriteAttribute(writer, BAD_CAST "pkg-certs-dir", + BAD_CAST context_->manifest_data.get()->pkg_certs_dir); + + xmlTextWriterWriteAttribute(writer, BAD_CAST "use-system-certs", + BAD_CAST context_->manifest_data.get()->use_system_certs); + + xmlTextWriterEndElement(writer); +} + } // namespace pkgmgr } // namespace wgt diff --git a/src/wgt/step/pkgmgr/step_generate_xml.h b/src/wgt/step/pkgmgr/step_generate_xml.h index 5bb7f89..f9a893f 100644 --- a/src/wgt/step/pkgmgr/step_generate_xml.h +++ b/src/wgt/step/pkgmgr/step_generate_xml.h @@ -49,6 +49,7 @@ class StepGenerateXml : public common_installer::Step { void GenerateIme(xmlTextWriterPtr writer); void GenerateProfiles(xmlTextWriterPtr writer); void GenerateShortcuts(xmlTextWriterPtr writer); + void GenerateTrustAnchor(xmlTextWriterPtr writer); STEP_NAME(GenerateXML) }; diff --git a/src/wgt/wgt_backend_data.h b/src/wgt/wgt_backend_data.h index c36cbad..cd7651a 100644 --- a/src/wgt/wgt_backend_data.h +++ b/src/wgt/wgt_backend_data.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -32,6 +33,7 @@ class WgtBackendData : public common_installer::BackendData { Property appwidgets; Property content; Property service_list; + Property trust_anchor; }; } // namespace wgt diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index 20c741b..bc4edde 100755 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -76,6 +76,9 @@ #include #include #include +#include +#include +#include #include @@ -227,6 +230,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep( ci::Plugin::ActionType::Install); @@ -273,6 +277,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep( ci::Plugin::ActionType::Upgrade); @@ -301,6 +306,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); @@ -324,6 +330,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); @@ -371,6 +378,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep( ci::Plugin::ActionType::Upgrade); @@ -429,6 +437,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep( ci::Plugin::ActionType::Install); @@ -472,6 +481,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep( ci::Plugin::ActionType::Upgrade); @@ -498,6 +508,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep(ci::Plugin::ActionType::Install); AddStep( @@ -528,6 +539,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep( ci::Plugin::ActionType::Upgrade); @@ -570,6 +582,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep(ci::Plugin::ActionType::Upgrade); AddStep(); @@ -598,6 +611,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(ci::Plugin::ActionType::Upgrade); @@ -614,6 +628,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep(ci::Plugin::ActionType::Install); AddStep( @@ -636,6 +651,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep( ci::Plugin::ActionType::Upgrade); @@ -657,6 +673,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); } -- 2.7.4