From da54fd639e7284dd641e5a67579ca2836ade0591 Mon Sep 17 00:00:00 2001
From: Piotr Ganicz
Date: Wed, 22 Jun 2016 09:51:31 +0200
Subject: [PATCH 01/16] Fix for update-period
Change-Id: Ic8adec0d7bd7aa14a3b5e054aaed67d5cb1d849c
---
src/wgt/step/pkgmgr/step_generate_xml.cc | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/wgt/step/pkgmgr/step_generate_xml.cc b/src/wgt/step/pkgmgr/step_generate_xml.cc
index 1148642..1173a85 100644
--- a/src/wgt/step/pkgmgr/step_generate_xml.cc
+++ b/src/wgt/step/pkgmgr/step_generate_xml.cc
@@ -108,7 +108,11 @@ bool WriteWidgetApplicationAttributesAndElements(
xmlTextWriterWriteAttribute(writer, BAD_CAST "main",
BAD_CAST (appwidget->primary ? "true" : "false")); // NOLINT
- xmlTextWriterWriteAttribute(writer, BAD_CAST "update-period", BAD_CAST "0");
+ if (!appwidget->update_period.empty()) {
+ xmlTextWriterWriteAttribute(writer, BAD_CAST "update-period", BAD_CAST
+ std::to_string(static_cast(
+ appwidget->update_period.front())).c_str());
+ }
for (auto& size : appwidget->content_size) {
xmlTextWriterStartElement(writer, BAD_CAST "support-size");
@@ -297,7 +301,8 @@ common_installer::Step::Status StepGenerateXml::precheck() {
}
if (context_->pkgid.get().empty()) {
LOG(ERROR) << "pkgid attribute is empty";
- return Step::Status::PACKAGE_NOT_FOUND; }
+ return Step::Status::PACKAGE_NOT_FOUND;
+ }
if (!context_->manifest_data.get()->application) {
LOG(ERROR) << "No application in package";
--
2.7.4
From 6bbd3f9ddc27487d54bc2441d8cfba9d8bef2345 Mon Sep 17 00:00:00 2001
From: Tomasz Iwanek
Date: Thu, 16 Jun 2016 14:57:58 +0200
Subject: [PATCH 02/16] Split API in pkgmgr_registration.h
Submit together:
- https://review.tizen.org/gerrit/75107
- https://review.tizen.org/gerrit/75108
- https://review.tizen.org/gerrit/75109
Change-Id: I259d3aac621443e7985fc2d5aa87e99d5a7bd959
---
src/unit_tests/smoke_test.cc | 6 +++---
src/wgt/wgt_app_query_interface.cc | 8 ++++----
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/unit_tests/smoke_test.cc b/src/unit_tests/smoke_test.cc
index f150590..56dfb15 100644
--- a/src/unit_tests/smoke_test.cc
+++ b/src/unit_tests/smoke_test.cc
@@ -8,7 +8,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
@@ -217,13 +217,13 @@ void PackageCheckCleanup(const std::string& pkgid,
void ValidatePackage(const std::string& pkgid,
const std::vector& appids) {
- ASSERT_TRUE(ci::IsPackageInstalled(pkgid, ci::GetRequestMode()));
+ ASSERT_TRUE(ci::QueryIsPackageInstalled(pkgid, ci::GetRequestMode()));
ValidatePackageFS(pkgid, appids);
}
void CheckPackageNonExistance(const std::string& pkgid,
const std::vector& appids) {
- ASSERT_FALSE(ci::IsPackageInstalled(pkgid, ci::GetRequestMode()));
+ ASSERT_FALSE(ci::QueryIsPackageInstalled(pkgid, ci::GetRequestMode()));
PackageCheckCleanup(pkgid, appids);
}
diff --git a/src/wgt/wgt_app_query_interface.cc b/src/wgt/wgt_app_query_interface.cc
index e4245cc..912c861 100644
--- a/src/wgt/wgt_app_query_interface.cc
+++ b/src/wgt/wgt_app_query_interface.cc
@@ -11,7 +11,7 @@
#include
#include
-#include
+#include
#include
#include
#include
@@ -107,21 +107,21 @@ bool WgtAppQueryInterface::IsAppInstalledByArgv(int argc, char** argv) {
return false;
// argument from commandline is package id
- if (ci::IsPackageInstalled(arg, ci::GetRequestMode()))
+ if (ci::QueryIsPackageInstalled(arg, ci::GetRequestMode()))
return true;
// argument from commandline is path to file
std::string pkg_id = GetPkgIdFromPath(arg);
if (pkg_id.empty())
return false;
- return ci::IsPackageInstalled(pkg_id, ci::GetRequestMode());
+ return ci::QueryIsPackageInstalled(pkg_id, ci::GetRequestMode());
}
bool WgtAppQueryInterface::IsHybridApplication(int argc, char** argv) {
std::string arg = GetInstallationRequestInfo(argc, argv);
if (arg.find("apps_rw/recovery-") != std::string::npos)
arg = ReadPkgidFromRecovery(arg);
- if (ci::IsPackageInstalled(arg, ci::GetRequestMode())) {
+ if (ci::QueryIsPackageInstalled(arg, ci::GetRequestMode())) {
bf::path package_directory(ci::GetRootAppPath(false));
if (bf::exists(package_directory / arg / kTizenManifestLocation) &&
bf::exists(package_directory / arg / kHybridConfigLocation))
--
2.7.4
From 70f676c0d426d55dc0dc7201f83e7c4e9aac1c06 Mon Sep 17 00:00:00 2001
From: Arkadiusz Szulakiewicz
Date: Wed, 22 Jun 2016 14:29:06 +0200
Subject: [PATCH 03/16] Add 'multiple-accounts-support' attribute for false
values
Change-Id: I16f212ec25689115c890f5688cdd7f8657cbebda
---
src/wgt/step/pkgmgr/step_generate_xml.cc | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/wgt/step/pkgmgr/step_generate_xml.cc b/src/wgt/step/pkgmgr/step_generate_xml.cc
index 1173a85..8e92818 100644
--- a/src/wgt/step/pkgmgr/step_generate_xml.cc
+++ b/src/wgt/step/pkgmgr/step_generate_xml.cc
@@ -504,6 +504,10 @@ void StepGenerateXml::GenerateAccount(xmlTextWriterPtr writer) {
xmlTextWriterWriteAttribute(writer,
BAD_CAST "multiple-accounts-support",
BAD_CAST "true");
+ else
+ xmlTextWriterWriteAttribute(writer,
+ BAD_CAST "multiple-accounts-support",
+ BAD_CAST "false");
for (auto& icon_pair : account.icon_paths) {
xmlTextWriterStartElement(writer, BAD_CAST "icon");
if (icon_pair.first == "AccountSmall")
--
2.7.4
From a90c5e7a6e9bd7302109e7e91f0d44b6ce67cc96 Mon Sep 17 00:00:00 2001
From: JongHeon Choi
Date: Mon, 27 Jun 2016 13:26:44 +0900
Subject: [PATCH 04/16] Modify nodisplay value of widget-application
Change-Id: I1cc298f5761d9bdd0b446a7cc06a937244f83187
---
src/wgt/step/configuration/step_parse.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/wgt/step/configuration/step_parse.cc b/src/wgt/step/configuration/step_parse.cc
index 602df3f..df06790 100644
--- a/src/wgt/step/configuration/step_parse.cc
+++ b/src/wgt/step/configuration/step_parse.cc
@@ -388,7 +388,7 @@ bool StepParse::FillWidgetApplicationInfo(manifest_x* manifest) {
strdup((context_->root_application_path.get() / manifest->package
/ "bin" / application->appid).c_str());
application->type = strdup("webapp");
- application->nodisplay = strdup("false");
+ application->nodisplay = strdup("true");
application->taskmanage = strdup("false");
SetApplicationXDefaults(application);
application->ambient_support = strdup("false");
--
2.7.4
From f3af9bd52c8664b63d301a4c62e1d45e5bd3d063 Mon Sep 17 00:00:00 2001
From: Piotr Ganicz
Date: Tue, 28 Jun 2016 12:52:34 +0200
Subject: [PATCH 05/16] [Refactor] check-coding-style
Change-Id: If44523674d80b403d32af34848230f53a2620d0b
---
src/wgt/step/pkgmgr/step_generate_xml.cc | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/wgt/step/pkgmgr/step_generate_xml.cc b/src/wgt/step/pkgmgr/step_generate_xml.cc
index 8e92818..dffb4c8 100644
--- a/src/wgt/step/pkgmgr/step_generate_xml.cc
+++ b/src/wgt/step/pkgmgr/step_generate_xml.cc
@@ -119,7 +119,8 @@ bool WriteWidgetApplicationAttributesAndElements(
std::string type = wgt::parse::AppWidgetSizeTypeToString(size.type);
if (!size.preview.empty()) {
- std::string icon_name = shared_path.string() + "/" + appwidget->id + "." + type + "." + "preview" +
+ std::string icon_name = shared_path.string() + "/"
+ + appwidget->id + "." + type + "." + "preview" +
bf::path(size.preview).extension().string();
xmlTextWriterWriteAttribute(writer, BAD_CAST "preview",
BAD_CAST icon_name.c_str()); // NOLINT
--
2.7.4
From 5957350d379b2307e5b2d33ce2ce90137fe536a0 Mon Sep 17 00:00:00 2001
From: Tomasz Iwanek
Date: Fri, 1 Jul 2016 11:01:36 +0200
Subject: [PATCH 06/16] Check if widget's shared/res/ entry is directory
Installation will succeed if shared/res entry is not directory.
Change-Id: I06e2b3934dd1342ad7ae98fd681a4b2a21d13885
---
src/wgt/step/filesystem/step_wgt_patch_storage_directories.cc | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/wgt/step/filesystem/step_wgt_patch_storage_directories.cc b/src/wgt/step/filesystem/step_wgt_patch_storage_directories.cc
index 3c5d9e9..fbb8519 100644
--- a/src/wgt/step/filesystem/step_wgt_patch_storage_directories.cc
+++ b/src/wgt/step/filesystem/step_wgt_patch_storage_directories.cc
@@ -52,6 +52,10 @@ bool StepWgtPatchStorageDirectories::ShareDirFor3x() {
bf::path src = context_->pkg_path.get() / kResWgtSubPath / kSharedResLocation;
if (!bf::exists(src))
return true;
+ if (!bf::is_directory(src)) {
+ LOG(WARNING) << "Widget's shared/res/ is not directory";
+ return true;
+ }
bf::path dst = context_->pkg_path.get() / kSharedResLocation;
if (!common_installer::MoveDir(src, dst,
common_installer::FS_MERGE_DIRECTORIES)) {
--
2.7.4
From 5f8f5211a72c991d466192146ce0bbfba45ef22c Mon Sep 17 00:00:00 2001
From: JongHeon Choi
Date: Tue, 5 Jul 2016 14:29:55 +0900
Subject: [PATCH 07/16] Fixed app_keys name.(kAccountKey -> kTizenImeKey)
Change-Id: Ifba625f6d0513499fed01360f63cacfc64b9d86d
---
src/wgt/step/configuration/step_parse.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/wgt/step/configuration/step_parse.cc b/src/wgt/step/configuration/step_parse.cc
index df06790..0295903 100644
--- a/src/wgt/step/configuration/step_parse.cc
+++ b/src/wgt/step/configuration/step_parse.cc
@@ -537,7 +537,7 @@ bool StepParse::FillAccounts(manifest_x* manifest) {
bool StepParse::FillImeInfo() {
auto ime_info =
GetManifestDataForKey(
- app_keys::kAccountKey);
+ app_keys::kTizenImeKey);
if (!ime_info)
return true;
--
2.7.4
From 3014326fcc25ea087930aa64b855dbfb9eabf785 Mon Sep 17 00:00:00 2001
From: Inhwan Lee
Date: Thu, 16 Jun 2016 19:14:55 +0900
Subject: [PATCH 08/16] implement step for use user extension
Change-Id: Ie5442f543f6e4dc3dbf78685716db2b113c021d0
---
src/wgt/CMakeLists.txt | 2 +
src/wgt/extension_config_parser.cc | 190 +++++++++++++++++++++
src/wgt/extension_config_parser.h | 36 ++++
.../security/step_check_extension_privileges.cc | 132 ++++++++++++++
.../security/step_check_extension_privileges.h | 55 ++++++
src/wgt/wgt_installer.cc | 7 +
6 files changed, 422 insertions(+)
mode change 100644 => 100755 src/wgt/CMakeLists.txt
create mode 100755 src/wgt/extension_config_parser.cc
create mode 100755 src/wgt/extension_config_parser.h
create mode 100755 src/wgt/step/security/step_check_extension_privileges.cc
create mode 100755 src/wgt/step/security/step_check_extension_privileges.h
mode change 100644 => 100755 src/wgt/wgt_installer.cc
diff --git a/src/wgt/CMakeLists.txt b/src/wgt/CMakeLists.txt
old mode 100644
new mode 100755
index f45acc5..2e70267
--- a/src/wgt/CMakeLists.txt
+++ b/src/wgt/CMakeLists.txt
@@ -18,8 +18,10 @@ SET(SRCS
step/security/step_check_wgt_notification_category.cc
step/security/step_check_wgt_ime_privilege.cc
step/security/step_direct_manifest_check_signature.cc
+ step/security/step_check_extension_privileges.cc
wgt_app_query_interface.cc
wgt_installer.cc
+ extension_config_parser.cc
)
IF(WRT_LAUNCHER)
diff --git a/src/wgt/extension_config_parser.cc b/src/wgt/extension_config_parser.cc
new file mode 100755
index 0000000..4813d72
--- /dev/null
+++ b/src/wgt/extension_config_parser.cc
@@ -0,0 +1,190 @@
+// Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#include "wgt/extension_config_parser.h"
+#include
+#include
+
+#include
+#include
+
+namespace wgt {
+
+namespace {
+const xmlChar kExtensionNodeKey[] = "extension";
+const xmlChar kNamePrivilegeKey[] = "privilege";
+const xmlChar kPrivigeNameAttributeKey[] = "name";
+const char kAttributePrefix[] = "@";
+const xmlChar kDirAttributeKey[] = "dir";
+const char kXmlTextKey[] = "#text";
+const char kNamespaceKey[] = "@namespace";
+const char kExtensionPath[] = "extension.privilege";
+const char kExtensionNameKey[] = "@name";
+} // namespace
+
+ExtensionConfigParser::ExtensionConfigParser(std::string config_xml) {
+ config_xml_ = config_xml;
+}
+
+std::unique_ptr
+ ExtensionConfigParser::LoadExtensionConfig(const std::string& config_xml) {
+ xmlDoc *doc = nullptr;
+ xmlNode* root_node = nullptr;
+ doc = xmlReadFile(config_xml.c_str(), nullptr, XML_PARSE_NOENT);
+ if (!doc) {
+ LOG(ERROR) << "Failed to read xml document model from" << config_xml;
+ return nullptr;
+ }
+ root_node = xmlDocGetRootElement(doc);
+ std::unique_ptr dv = LoadXMLNode(root_node);
+ std::unique_ptr result(new parser::DictionaryValue);
+ if (dv)
+ result->Set(reinterpret_cast(root_node->name), dv.release());
+ return result;
+}
+
+std::string ExtensionConfigParser::GetNodeDir(
+ xmlNode* node, const std::string& inherit_dir) {
+ std::string dir(inherit_dir);
+ for (xmlAttr* prop = node->properties; prop; prop = prop->next) {
+ if (xmlStrEqual(prop->name, kDirAttributeKey)) {
+ char* prop_value = reinterpret_cast(xmlNodeListGetString(
+ node->doc, prop->children, 1));
+ dir = prop_value;
+ xmlFree(prop_value);
+ break;
+ }
+ }
+ return dir;
+}
+std::string ExtensionConfigParser::GetNodeText(
+ xmlNode* root, const std::string& inherit_dir) {
+ if (root->type != XML_ELEMENT_NODE)
+ return std::string();
+ std::string current_dir(GetNodeDir(root, inherit_dir));
+ std::string text;
+ if (!current_dir.empty())
+ text += parser::utils::GetDirUTF8Start(current_dir);
+ for (xmlNode* node = root->children; node; node = node->next) {
+ if (node->type == XML_TEXT_NODE || node->type == XML_CDATA_SECTION_NODE)
+ text = text + std::string(reinterpret_cast(node->content));
+ else
+ text += GetNodeText(node, current_dir);
+ }
+ if (!current_dir.empty())
+ text += parser::utils::GetDirUTF8End();
+ return text;
+}
+bool ExtensionConfigParser::IsPropSupportDir(xmlNode* root, xmlAttr* prop) {
+ if (xmlStrEqual(root->name, kNamePrivilegeKey)
+ && xmlStrEqual(prop->name, kPrivigeNameAttributeKey)) {
+ return true;
+ }
+ return false;
+}
+bool ExtensionConfigParser::IsTrimRequiredForElement(xmlNode* root) {
+ if (xmlStrEqual(root->name, kNamePrivilegeKey)) {
+ return true;
+ }
+ return false;
+}
+bool ExtensionConfigParser::IsTrimRequiredForProp(
+ xmlNode* root, xmlAttr* prop) {
+ if (xmlStrEqual(root->name, kNamePrivilegeKey) &&
+ xmlStrEqual(prop->name, kPrivigeNameAttributeKey)) {
+ return true;
+ }
+ return false;
+}
+std::unique_ptr
+ ExtensionConfigParser::LoadXMLNode(
+ xmlNode* root, const std::string& inherit_dir) {
+ std::unique_ptr value(new parser::DictionaryValue());
+ if (root->type != XML_ELEMENT_NODE)
+ return nullptr;
+
+ std::string current_dir(GetNodeDir(root, inherit_dir));
+
+ xmlAttr* prop = nullptr;
+ for (prop = root->properties; prop; prop = prop->next) {
+ xmlChar* value_ptr = xmlNodeListGetString(root->doc, prop->children, 1);
+ std::string prop_value(reinterpret_cast(value_ptr));
+ xmlFree(value_ptr);
+ if (IsPropSupportDir(root, prop))
+ prop_value = parser::utils::GetDirTextUTF8(prop_value, current_dir);
+
+ if (IsTrimRequiredForProp(root, prop))
+ prop_value = parser::utils::CollapseWhitespaceUTF8(prop_value);
+
+ value->SetString(
+ std::string(kAttributePrefix)
+ + reinterpret_cast(prop->name),
+ prop_value);
+ }
+
+ if (root->ns)
+ value->SetString(kNamespaceKey,
+ reinterpret_cast(root->ns->href));
+
+ for (xmlNode* node = root->children; node; node = node->next) {
+ std::string sub_node_name(reinterpret_cast(node->name));
+ std::unique_ptr sub_value =
+ LoadXMLNode(node, current_dir);
+
+ if (!sub_value) {
+ continue;
+ }
+ if (!value->HasKey(sub_node_name)) {
+ value->Set(sub_node_name, sub_value.release());
+ continue;
+ }
+
+ parser::Value* temp;
+ value->Get(sub_node_name, &temp);
+
+ if (temp->IsType(parser::Value::TYPE_LIST)) {
+ parser::ListValue* list;
+ temp->GetAsList(&list);
+ list->Append(sub_value.release());
+ } else {
+ assert(temp->IsType(parser::Value::TYPE_DICTIONARY));
+ parser::DictionaryValue* dict;
+ temp->GetAsDictionary(&dict);
+ parser::DictionaryValue* prev_value = dict->DeepCopy();
+
+ parser::ListValue* list = new parser::ListValue();
+ list->Append(prev_value);
+ list->Append(sub_value.release());
+ value->Set(sub_node_name, list);
+ }
+ }
+
+ std::string text;
+ xmlChar* text_ptr = xmlNodeListGetString(root->doc, root->children, 1);
+ if (text_ptr) {
+ text = reinterpret_cast(text_ptr);
+ xmlFree(text_ptr);
+ }
+ if (IsTrimRequiredForElement(root))
+ text = parser::utils::CollapseWhitespaceUTF8(text);
+ if (!text.empty())
+ value->SetString(kXmlTextKey, text);
+
+ return value;
+}
+std::vector ExtensionConfigParser::GetExtensionPrivilegeList() {
+ std::unique_ptr dic
+ = LoadExtensionConfig(config_xml_);
+ std::vector privilege_list;
+
+ for (auto& item : parser::GetOneOrMany(dic.get(), kExtensionPath, "")) {
+ std::string privilege;
+ if (item->GetString(kExtensionNameKey, &privilege)) {
+ LOG(DEBUG) << "User defined extra privilege: " << privilege;
+ privilege_list.push_back(privilege);
+ }
+ }
+ return privilege_list;
+}
+} // namespace wgt
diff --git a/src/wgt/extension_config_parser.h b/src/wgt/extension_config_parser.h
new file mode 100755
index 0000000..c5cd454
--- /dev/null
+++ b/src/wgt/extension_config_parser.h
@@ -0,0 +1,36 @@
+// Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef WGT_EXTENSION_CONFIG_PARSER_H_
+#define WGT_EXTENSION_CONFIG_PARSER_H_
+
+#include
+#include
+#include
+#include
+
+#include
+#include