From 80d349ac68dcbb7a9c1fa736e019d85e25642363 Mon Sep 17 00:00:00 2001 From: Youmin Ha Date: Mon, 16 Feb 2015 21:52:17 +0900 Subject: [PATCH] Fix bugs in common steps * Fixed generating xml routine, that each privilege have its value as a data, not a 'name' attribute. * Changed the iteration routine, from the first item of the privilege list. * Excluded routine removing xml file, from the 'undo' phase of the step_record. Change-Id: Ied4ff4a48ab0a62f93fbb4fac40faa00952eaefe Signed-Off-By: Youmin Ha --- src/common/security_registration.cc | 16 ++++++++++++---- src/common/step/step_generate_xml.cc | 17 ++++++++--------- src/common/step/step_record.cc | 2 -- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/common/security_registration.cc b/src/common/security_registration.cc index 1a4db3d..da7a568 100644 --- a/src/common/security_registration.cc +++ b/src/common/security_registration.cc @@ -8,6 +8,12 @@ #include "utils/logging.h" +/* NOTE: For *_x list types in pkgmgr-info, like privileges_x or privilege_x, + * this macro moves the current node to the head of the list. + * This LISTHEAD() macro is defined in pkgmgr_parser.h in pkgmgr-info package. + */ +#define PKGMGR_LIST_MOVE_NODE_TO_HEAD(list, node) LISTHEAD(list, node) + namespace bf = boost::filesystem; namespace { @@ -41,10 +47,12 @@ bool PrepareRequest(const std::string& app_id, const std::string& pkg_id, } if (manifest) { - for (privileges_x* privileges = manifest->privileges; - privileges != nullptr; privileges = privileges->next) { - for (privilege_x* priv = privileges->privilege; - priv != nullptr; priv = priv->next) { + privileges_x *privileges; + PKGMGR_LIST_MOVE_NODE_TO_HEAD(manifest->privileges, privileges); + for (;privileges != nullptr; privileges = privileges->next) { + privilege_x* priv; + PKGMGR_LIST_MOVE_NODE_TO_HEAD(privileges->privilege, priv); + for (;priv != nullptr; priv = priv->next) { security_manager_app_inst_req_add_privilege(req, priv->text); } } diff --git a/src/common/step/step_generate_xml.cc b/src/common/step/step_generate_xml.cc index 4498ab0..3f16ece 100644 --- a/src/common/step/step_generate_xml.cc +++ b/src/common/step/step_generate_xml.cc @@ -202,13 +202,15 @@ Step::Status StepGenerateXml::process() { } // add privilege element - for (privileges_x* pvlg = context_->manifest_data()->privileges; - pvlg != nullptr; pvlg = pvlg->next) { + privileges_x *pvlg; + LISTHEAD(context_->manifest_data()->privileges, pvlg); + for (;pvlg != nullptr; pvlg = pvlg->next) { xmlTextWriterStartElement(writer, BAD_CAST "privileges"); - for (privilege_x* pv = pvlg->privilege; pv != nullptr; pv = pv->next) { - xmlTextWriterStartElement(writer, BAD_CAST "privilege"); - xmlTextWriterWriteAttribute(writer, BAD_CAST "name", BAD_CAST pv->text); - xmlTextWriterEndElement(writer); + privilege_x *pv; + LISTHEAD(pvlg->privilege, pv); + for (; pv != nullptr; pv = pv->next) { + xmlTextWriterWriteFormatElement(writer, BAD_CAST "privilege", + "%s", BAD_CAST pv->text); } xmlTextWriterEndElement(writer); } @@ -233,9 +235,6 @@ Step::Status StepGenerateXml::clean() { } Step::Status StepGenerateXml::undo() { - if (fs::exists(context_->xml_path())) - fs::remove_all(context_->xml_path()); - if (fs::exists(icon_path_)) fs::remove_all(icon_path_); diff --git a/src/common/step/step_record.cc b/src/common/step/step_record.cc index 6656455..1252a6b 100644 --- a/src/common/step/step_record.cc +++ b/src/common/step/step_record.cc @@ -58,8 +58,6 @@ Step::Status StepRecord::clean() { Step::Status StepRecord::undo() { std::string cmd; - if (fs::exists(context_->xml_path())) - fs::remove_all(context_->xml_path()); context_->uid() != tzplatform_getuid(TZ_SYS_GLOBALAPP_USER) ? cmd = std::string(kAilInitUser) + ";" + kPkgInitUser : -- 2.7.4