From a68087af829d967f5f68332e69d27283bc88e899 Mon Sep 17 00:00:00 2001 From: Bartlomiej Kunikowski Date: Fri, 11 Aug 2017 10:44:34 +0200 Subject: [PATCH 01/16] Perform code style checking fixes Change-Id: If802ce932ed42bf53e11a1f7d5213e48f9794a8c --- src/unit_tests/smoke_test_helper.cc | 4 ++-- src/unit_tests/smoke_utils.cc | 29 ++++++++++++++--------------- src/wgt/step/configuration/step_parse.cc | 6 ++---- src/wgt/step/pkgmgr/step_generate_xml.cc | 3 ++- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/unit_tests/smoke_test_helper.cc b/src/unit_tests/smoke_test_helper.cc index 156b64b..d767cdb 100644 --- a/src/unit_tests/smoke_test_helper.cc +++ b/src/unit_tests/smoke_test_helper.cc @@ -41,8 +41,8 @@ int main(int argc, char** argv) { ci::PkgmgrInstaller pkgmgr_installer; wgt::WgtAppQueryInterface query_interface; - auto pkgmgr = ci::PkgMgrInterface::Create(backend_argc, argv, &pkgmgr_installer, - &query_interface); + auto pkgmgr = ci::PkgMgrInterface::Create(backend_argc, argv, + &pkgmgr_installer, &query_interface); if (!pkgmgr) { LOG(ERROR) << "Options of pkgmgr installer cannot be parsed"; return EINVAL; diff --git a/src/unit_tests/smoke_utils.cc b/src/unit_tests/smoke_utils.cc index 2a8fb85..fabb37c 100644 --- a/src/unit_tests/smoke_utils.cc +++ b/src/unit_tests/smoke_utils.cc @@ -868,19 +868,18 @@ void UninstallAllSmokeApps(ci::RequestMode request_mode) { } } -int GetAppInstalledTime(const char *appid, uid_t uid) -{ - int ret = 0; - int installed_time = 0; - pkgmgrinfo_appinfo_h handle = NULL; - ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, uid, &handle); - if (ret != PMINFO_R_OK) - return -1; - ret = pkgmgrinfo_appinfo_get_installed_time(handle, &installed_time); - if (ret != PMINFO_R_OK) { - pkgmgrinfo_appinfo_destroy_appinfo(handle); - return -1; - } - pkgmgrinfo_appinfo_destroy_appinfo(handle); - return installed_time; +int GetAppInstalledTime(const char *appid, uid_t uid) { + int ret = 0; + int installed_time = 0; + pkgmgrinfo_appinfo_h handle = NULL; + ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, uid, &handle); + if (ret != PMINFO_R_OK) + return -1; + ret = pkgmgrinfo_appinfo_get_installed_time(handle, &installed_time); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_appinfo_destroy_appinfo(handle); + return -1; + } + pkgmgrinfo_appinfo_destroy_appinfo(handle); + return installed_time; } diff --git a/src/wgt/step/configuration/step_parse.cc b/src/wgt/step/configuration/step_parse.cc index a9e3ca1..fa8bed7 100644 --- a/src/wgt/step/configuration/step_parse.cc +++ b/src/wgt/step/configuration/step_parse.cc @@ -65,8 +65,7 @@ const char kTTSCategoryName[] = "http://tizen.org/category/tts"; const char kResWgt[] = "res/wgt"; const char kConfigFileName[] = "config.xml"; -void FreeMetadataList(gpointer data) -{ +void FreeMetadataList(gpointer data) { metadata_x* metadata = reinterpret_cast(data); if (metadata) { if (metadata->key) @@ -325,8 +324,7 @@ bool StepParse::FillWidgetInfo(manifest_x* manifest) { manifest->update = strdup("true"); else manifest->update = strdup("false"); - } - else { + } else { manifest->update = strdup("false"); } diff --git a/src/wgt/step/pkgmgr/step_generate_xml.cc b/src/wgt/step/pkgmgr/step_generate_xml.cc index 6743f2a..404b5c8 100644 --- a/src/wgt/step/pkgmgr/step_generate_xml.cc +++ b/src/wgt/step/pkgmgr/step_generate_xml.cc @@ -525,7 +525,8 @@ void StepGenerateXml::GeneratePrivilege(xmlTextWriterPtr writer) { void StepGenerateXml::GenerateProvidesAppDefinedPrivilege( xmlTextWriterPtr writer) { if (context_->manifest_data.get()->provides_appdefined_privileges) { - xmlTextWriterStartElement(writer, BAD_CAST "provides-appdefined-privileges"); + xmlTextWriterStartElement(writer, + BAD_CAST "provides-appdefined-privileges"); for (appdefined_privilege_x* priv : GListRange( context_->manifest_data.get()->provides_appdefined_privileges)) { xmlTextWriterStartElement(writer, BAD_CAST "appdefined-privilege"); -- 2.7.4 From ce5f401ef0eb5c84ffbe33f3adb208ca614cae7f Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Fri, 18 Aug 2017 13:47:30 +0900 Subject: [PATCH 02/16] Fix memory leak Signed-off-by: Seungha Son Change-Id: Ic777cdeb6517bc87e56d1671cd810edf8babbf5c --- src/wgt/step/configuration/step_parse.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wgt/step/configuration/step_parse.cc b/src/wgt/step/configuration/step_parse.cc index a9e3ca1..fbdfb4b 100644 --- a/src/wgt/step/configuration/step_parse.cc +++ b/src/wgt/step/configuration/step_parse.cc @@ -32,6 +32,7 @@ #include #include +#include #include @@ -414,6 +415,7 @@ bool StepParse::FillMainApplicationInfo(manifest_x* manifest) { icon_x* app_icon = reinterpret_cast(calloc(1, sizeof(icon_x))); if (!app_icon) { LOG(ERROR) << "Out of memory"; + pkgmgrinfo_basic_free_application(application); return false; } app_icon->text = strdup(icon->text); @@ -468,6 +470,7 @@ bool StepParse::FillServiceApplicationInfo(manifest_x* manifest) { icon_x* icon = reinterpret_cast(calloc(1, sizeof(icon_x))); if (!icon) { LOG(ERROR) << "Out of memory"; + pkgmgrinfo_basic_free_application(application); return false; } icon->text = strdup(icon_path.c_str()); @@ -536,6 +539,7 @@ bool StepParse::FillWidgetApplicationInfo(manifest_x* manifest) { icon_x* icon = reinterpret_cast(calloc(1, sizeof(icon_x))); if (!icon) { LOG(ERROR) << "Out of memory"; + pkgmgrinfo_basic_free_application(application); return false; } icon->text = strdup(app_widget.icon_src.c_str()); -- 2.7.4 From 7a800e36404a8ac9577b3ac5515fa707d3152b23 Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Fri, 18 Aug 2017 16:35:02 +0900 Subject: [PATCH 03/16] Release version 0.6.2 Changes: - Fix memory leak Signed-off-by: Seungha Son Change-Id: Iaed04b854ee70dc556f28602ec8c3794521977fb --- packaging/wgt-backend.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/wgt-backend.spec b/packaging/wgt-backend.spec index c99cc8d..8530831 100644 --- a/packaging/wgt-backend.spec +++ b/packaging/wgt-backend.spec @@ -1,6 +1,6 @@ Name: wgt-backend Summary: Application installer backend for WGT -Version: 0.6.1 +Version: 0.6.2 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From 08c58a1984d90ac93c25f51ac6a566ab08ca441f Mon Sep 17 00:00:00 2001 From: Damian Pietruchowski Date: Mon, 12 Jun 2017 16:01:32 +0200 Subject: [PATCH 04/16] AppQueryInterface logic export IsPkgInstalled() and GetPkgId() have the same implementation for wgt-backend and tpk-backend, so only GetPkgIdFromPath() should be overrided in each backend. Submit together: - https://review.tizen.org/gerrit/#/c/133520/ - https://review.tizen.org/gerrit/#/c/133518/ Change-Id: I40b61fbea37838ccd372b964fe3cf54eb5f5f5a6 Signed-off-by: Damian Pietruchowski --- src/wgt/wgt_app_query_interface.cc | 62 +++++++++++++------------------------- src/wgt/wgt_app_query_interface.h | 19 +++--------- 2 files changed, 25 insertions(+), 56 deletions(-) diff --git a/src/wgt/wgt_app_query_interface.cc b/src/wgt/wgt_app_query_interface.cc index 7b2eee4..908cd6b 100644 --- a/src/wgt/wgt_app_query_interface.cc +++ b/src/wgt/wgt_app_query_interface.cc @@ -37,20 +37,26 @@ namespace { const char kHybridConfigLocation[] = "res/wgt/config.xml"; const char kTizenManifestLocation[] = "tizen-manifest.xml"; -std::string GetPkgIdFromPath(const std::string& path) { - if (!bf::exists(path)) - return {}; - bf::path tmp_path = common_installer::GenerateTmpDir("/tmp"); - bs::error_code code; - bf::create_directories(tmp_path, code); - if (code) - return {}; - if (!common_installer::ExtractToTmpDir(path.c_str(), tmp_path, - "config.xml")) { - ci::RemoveAll(tmp_path); +std::string ReadPkgidFromRecovery(const std::string& recovery_path) { + std::unique_ptr recovery_file = + ci::recovery::RecoveryFile::OpenRecoveryFileForPath(recovery_path); + recovery_file->Detach(); + return recovery_file->pkgid(); +} + +} // namespace + +namespace wgt { + +std::string WgtAppQueryInterface::GetManifestFileName() const { + return "config.xml"; +} + +std::string WgtAppQueryInterface::GetPkgIdFromPath( + const std::string& path) const { + bf::path tmp_path = ExtractManifest(path); + if (tmp_path.empty()) return {}; - } - bf::path config_path = tmp_path / "config.xml"; std::vector> handlers = { std::make_shared(), std::make_shared() @@ -59,6 +65,7 @@ std::string GetPkgIdFromPath(const std::string& path) { new parser::ManifestHandlerRegistry(handlers)); std::unique_ptr parser( new parser::ManifestParser(std::move(registry))); + bf::path config_path = tmp_path / GetManifestFileName(); if (!parser->ParseManifest(config_path)) { ci::RemoveAll(tmp_path); return {}; @@ -76,31 +83,8 @@ std::string GetPkgIdFromPath(const std::string& path) { return pkg_id; } -std::string ReadPkgidFromRecovery(const std::string& recovery_path) { - std::unique_ptr recovery_file = - ci::recovery::RecoveryFile::OpenRecoveryFileForPath(recovery_path); - recovery_file->Detach(); - return recovery_file->pkgid(); -} - -} // namespace - -namespace wgt { - -bool WgtAppQueryInterface::IsPkgInstalled(const std::string& arg, uid_t uid) { - // argument from commandline is package id - if (ci::QueryIsPackageInstalled(arg, ci::GetRequestMode(uid), uid)) - return true; - - // argument from commandline is path to file - std::string pkg_id = GetPkgIdFromPath(arg); - if (pkg_id.empty()) - return false; - return ci::QueryIsPackageInstalled(pkg_id, ci::GetRequestMode(uid), uid); -} - bool WgtAppQueryInterface::IsHybridApplication(const std::string& arg, - uid_t uid) { + uid_t uid) const { std::string info; bool is_recovery = arg.find("wgt-recovery-") != std::string::npos; if (is_recovery) @@ -128,8 +112,4 @@ bool WgtAppQueryInterface::IsHybridApplication(const std::string& arg, return false; } -std::string WgtAppQueryInterface::GetPkgId(const std::string& arg) { - return GetPkgIdFromPath(arg); -} - } // namespace wgt diff --git a/src/wgt/wgt_app_query_interface.h b/src/wgt/wgt_app_query_interface.h index 3610da9..c19d46a 100644 --- a/src/wgt/wgt_app_query_interface.h +++ b/src/wgt/wgt_app_query_interface.h @@ -21,27 +21,16 @@ namespace wgt { class WgtAppQueryInterface : public common_installer::AppQueryInterface { public: /** - * \brief method for checking if package is installed based - * on argv - * - * \return true if package is installed - */ - bool IsPkgInstalled(const std::string& arg, uid_t uid) override; - - /** * \brief This method is workaround for detecting installation of hybrid * application. * * \return true if package is hybrid */ - bool IsHybridApplication(const std::string& arg, uid_t uid); + bool IsHybridApplication(const std::string& arg, uid_t uid) const; - /** - * \brief method for getting package id from package file - * - * \return package id - */ - std::string GetPkgId(const std::string& arg) override; + private: + std::string GetPkgIdFromPath(const std::string& path) const override; + std::string GetManifestFileName() const override; }; } // namespace wgt -- 2.7.4 From e235b5f6469dff0d5baaaf4a4d87e4749f525a38 Mon Sep 17 00:00:00 2001 From: Damian Pietruchowski Date: Tue, 18 Jul 2017 13:37:28 +0200 Subject: [PATCH 05/16] Adapter interface for external PkgMgr module Submit together: - https://review.tizen.org/gerrit/#/c/138998/ - https://review.tizen.org/gerrit/#/c/139346/ Change-Id: Ia27cf4fa824258cb1df1a8a48b8601ddacc66f89 Signed-off-by: Damian Pietruchowski --- src/unit_tests/smoke_test.cc | 16 ++++++++-------- src/unit_tests/smoke_utils.cc | 22 +++++++++++----------- src/wgt/step/configuration/step_parse.cc | 14 ++++++-------- src/wgt/wgt_app_query_interface.cc | 4 ++-- 4 files changed, 27 insertions(+), 29 deletions(-) diff --git a/src/unit_tests/smoke_test.cc b/src/unit_tests/smoke_test.cc index d907386..b55392a 100644 --- a/src/unit_tests/smoke_test.cc +++ b/src/unit_tests/smoke_test.cc @@ -120,9 +120,8 @@ TEST_F(SmokeTest, EnablePkg) { ASSERT_EQ(EnablePackage(pkgid, PackageType::WGT), ci::AppInstaller::Result::OK); - ASSERT_TRUE(ci::QueryIsPackageInstalled(pkgid, - ci::GetRequestMode(kTestUserId), - kTestUserId)); + ci::PkgQueryInterface pkg_query(pkgid, kTestUserId); + ASSERT_TRUE(pkg_query.IsPackageInstalled(ci::GetRequestMode(kTestUserId))); } TEST_F(SmokeTest, DisablePkg) { @@ -559,7 +558,8 @@ TEST_F(SmokeTest, UserDefinedPlugins) { ASSERT_EQ(Install(path, PackageType::WGT), ci::AppInstaller::Result::OK); ASSERT_TRUE(ValidatePackage(pkgid, {appid})); std::vector res; - ASSERT_TRUE(ci::QueryPrivilegesForPkgId(pkgid, kTestUserId, &res)); + ci::PkgQueryInterface pkg_query(pkgid, kTestUserId); + ASSERT_TRUE(pkg_query.PrivilegesForPkgId(&res)); ASSERT_TRUE(std::find(res.begin(), res.end(), call_privilege) != res.end()); ASSERT_TRUE(std::find(res.begin(), res.end(), location_privilege) != res.end()); @@ -641,8 +641,8 @@ TEST_F(PreloadSmokeTest, ManifestDirectInstallMode) { bf::path pkg_path = ci::GetRootAppPath(false, kTestUserId); CopyDir(src_path / pkgid, pkg_path / pkgid); - ASSERT_FALSE(QueryIsPackageInstalled(pkgid, ci::GetRequestMode(kTestUserId), - kTestUserId)); + ci::PkgQueryInterface pkg_query(pkgid, kTestUserId); + ASSERT_FALSE(pkg_query.IsPackageInstalled(ci::GetRequestMode(kTestUserId))); ASSERT_EQ(ManifestDirectInstall(pkgid, PackageType::WGT), ci::AppInstaller::Result::OK); ASSERT_TRUE(ValidatePackage(pkgid, {appid})); @@ -702,8 +702,8 @@ TEST_F(PreloadSmokeTest, ManifestDirectInstallMode_Hybrid) { bf::path pkg_path = ci::GetRootAppPath(false, kTestUserId); CopyDir(src_path / pkgid, pkg_path / pkgid); - ASSERT_FALSE(QueryIsPackageInstalled(pkgid, ci::GetRequestMode(kTestUserId), - kTestUserId)); + ci::PkgQueryInterface pkg_query(pkgid, kTestUserId); + ASSERT_FALSE(pkg_query.IsPackageInstalled(ci::GetRequestMode(kTestUserId))); ASSERT_EQ(ManifestDirectInstall(pkgid, PackageType::HYBRID), ci::AppInstaller::Result::OK); ASSERT_TRUE(ValidatePackage(pkgid, {appid})); diff --git a/src/unit_tests/smoke_utils.cc b/src/unit_tests/smoke_utils.cc index fabb37c..41c777d 100644 --- a/src/unit_tests/smoke_utils.cc +++ b/src/unit_tests/smoke_utils.cc @@ -377,8 +377,9 @@ void PackageCheckCleanup(const std::string& pkgid, bool ValidatePackage(const std::string& pkgid, const std::vector& appids, bool is_readonly) { - EXTENDED_ASSERT_TRUE(ci::QueryIsPackageInstalled( - pkgid, ci::GetRequestMode(kTestUserId), kTestUserId)); + ci::PkgQueryInterface pkg_query(pkgid, kTestUserId); + EXTENDED_ASSERT_TRUE(pkg_query.IsPackageInstalled( + ci::GetRequestMode(kTestUserId))); EXTENDED_ASSERT_TRUE(ValidatePackageFS( pkgid, appids, kTestUserId, kTestGroupId, is_readonly)); if (kTestUserId == kGlobalUserUid) { @@ -403,10 +404,9 @@ void ValidateExternalPackageFS(const std::string& pkgid, void ValidateExternalPackage(const std::string& pkgid, const std::vector& appids) { - ASSERT_TRUE(ci::QueryIsPackageInstalled( - pkgid, ci::GetRequestMode(kTestUserId), - kTestUserId)); - std::string storage = ci::QueryStorageForPkgId(pkgid, kTestUserId); + ci::PkgQueryInterface pkg_query(pkgid, kTestUserId); + ASSERT_TRUE(pkg_query.IsPackageInstalled(ci::GetRequestMode(kTestUserId))); + std::string storage = pkg_query.StorageForPkgId(); bf::path ext_mount_path = ci::GetExternalCardPath(); if (bf::is_empty(ext_mount_path)) { LOG(INFO) << "Sdcard not exists!"; @@ -426,9 +426,9 @@ void ValidateExternalPackage(const std::string& pkgid, bool CheckPackageNonExistance(const std::string& pkgid, const std::vector& appids) { - EXTENDED_ASSERT_FALSE(ci::QueryIsPackageInstalled( - pkgid, ci::GetRequestMode(kTestUserId), - kTestUserId)); + ci::PkgQueryInterface pkg_query(pkgid, kTestUserId); + EXTENDED_ASSERT_FALSE(pkg_query.IsPackageInstalled( + ci::GetRequestMode(kTestUserId))); PackageCheckCleanup(pkgid, appids); if (kTestUserId == kGlobalUserUid) { ci::UserList list = ci::GetUserList(); @@ -445,8 +445,8 @@ bool CheckPackageNonExistance(const std::string& pkgid, void CheckPackageReadonlyNonExistance(const std::string& pkgid, const std::vector& appids) { - ASSERT_FALSE(ci::QueryIsPackageInstalled( - pkgid, ci::GetRequestMode(kTestUserId), kTestUserId)); + ci::PkgQueryInterface pkg_query(pkgid, kTestUserId); + ASSERT_FALSE(pkg_query.IsPackageInstalled(ci::GetRequestMode(kTestUserId))); PackageCheckCleanup(pkgid, appids, true); } diff --git a/src/wgt/step/configuration/step_parse.cc b/src/wgt/step/configuration/step_parse.cc index 9045043..c339a8f 100644 --- a/src/wgt/step/configuration/step_parse.cc +++ b/src/wgt/step/configuration/step_parse.cc @@ -314,19 +314,17 @@ bool StepParse::FillWidgetInfo(manifest_x* manifest) { if (!context_->pkgid.get().empty()) { // set update true if package is updated preload package ci::RequestType req_type = context_->request_type.get(); - if (ci::QueryIsUpdatedPackage(context_->pkgid.get(), context_->uid.get())) + ci::PkgQueryInterface pkg_query(manifest->package, context_->uid.get()); + if (pkg_query.IsUpdatedPackage()) manifest->update = strdup("true"); - else if (ci::QueryIsPreloadPackage(context_->pkgid.get(), - context_->uid.get()) && + else if (pkg_query.IsPreloadPackage() && (req_type == ci::RequestType::Update || - req_type == ci::RequestType::Delta || - req_type == ci::RequestType::MountUpdate || - req_type == ci::RequestType::ReadonlyUpdateInstall)) + req_type == ci::RequestType::Delta || + req_type == ci::RequestType::MountUpdate || + req_type == ci::RequestType::ReadonlyUpdateInstall)) manifest->update = strdup("true"); else manifest->update = strdup("false"); - } else { - manifest->update = strdup("false"); } return true; diff --git a/src/wgt/wgt_app_query_interface.cc b/src/wgt/wgt_app_query_interface.cc index 908cd6b..5f931e0 100644 --- a/src/wgt/wgt_app_query_interface.cc +++ b/src/wgt/wgt_app_query_interface.cc @@ -91,8 +91,8 @@ bool WgtAppQueryInterface::IsHybridApplication(const std::string& arg, info = ReadPkgidFromRecovery(arg); else info = arg; - - if (ci::QueryIsPackageInstalled(info, ci::GetRequestMode(uid), uid)) { + ci::PkgQueryInterface pkg_query(info, uid); + if (pkg_query.IsPackageInstalled(ci::GetRequestMode(uid))) { bf::path package_directory(ci::GetRootAppPath(false, uid)); if (bf::exists(package_directory / info / kTizenManifestLocation) && bf::exists(package_directory / info / kHybridConfigLocation)) -- 2.7.4 From 10701396f2b48b43317db12bcbf43733d0fbde8d Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Tue, 29 Aug 2017 13:53:56 +0900 Subject: [PATCH 06/16] Release version 0.7.0 Changes: - Perform code style checking fixes - Merge "Perform code style checking fixes" into tizen - AppQueryInterface logic export - Adapter interface for external PkgMgr module Change-Id: I11e9458090277484b8176e5dbabd7a7328c3b291 Signed-off-by: Sangyoon Jang --- packaging/wgt-backend.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/wgt-backend.spec b/packaging/wgt-backend.spec index 8530831..e0c49df 100644 --- a/packaging/wgt-backend.spec +++ b/packaging/wgt-backend.spec @@ -1,6 +1,6 @@ Name: wgt-backend Summary: Application installer backend for WGT -Version: 0.6.2 +Version: 0.7.0 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From 0f0538eafbb2361498066f8c1671adf6728e9764 Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Mon, 4 Sep 2017 17:09:17 +0900 Subject: [PATCH 07/16] Fix codes for ManifestDirectInstall in Hybrid pkg - Backend couldn't detect hybrid pkg if pkginfo doesn't exist in db. - ManifestDirectInstall cannot be performed because of reason above. - So change if statement to check designated directory even if there are no information in db. - RO path will be checked only if given uid is privileged one. Change-Id: Ic4855cfa1090b1e5bac1b98d6ca69507657de357 Signed-off-by: Junghyun Yeon --- src/wgt/wgt_app_query_interface.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/wgt/wgt_app_query_interface.cc b/src/wgt/wgt_app_query_interface.cc index 5f931e0..4afdc3d 100644 --- a/src/wgt/wgt_app_query_interface.cc +++ b/src/wgt/wgt_app_query_interface.cc @@ -91,11 +91,14 @@ bool WgtAppQueryInterface::IsHybridApplication(const std::string& arg, info = ReadPkgidFromRecovery(arg); else info = arg; - ci::PkgQueryInterface pkg_query(info, uid); - if (pkg_query.IsPackageInstalled(ci::GetRequestMode(uid))) { - bf::path package_directory(ci::GetRootAppPath(false, uid)); - if (bf::exists(package_directory / info / kTizenManifestLocation) && - bf::exists(package_directory / info / kHybridConfigLocation)) + bf::path rw_package_directory(ci::GetRootAppPath(false, uid)); + bf::path ro_package_directory; + if (uid == tzplatform_getuid(TZ_SYS_GLOBALAPP_USER) || uid == 0) + ro_package_directory = ci::GetRootAppPath(true, uid); + if ((bf::exists(rw_package_directory / info / kTizenManifestLocation) && + bf::exists(rw_package_directory / info / kHybridConfigLocation)) || + (bf::exists(ro_package_directory / info / kTizenManifestLocation) && + bf::exists(ro_package_directory / info / kHybridConfigLocation))) { return true; } else if (!is_recovery) { bool tizen_manifest_found = false; -- 2.7.4 From 21e72ace3b7b3df228173ffc839bbf02b7219e9b Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Tue, 19 Sep 2017 18:39:34 +0900 Subject: [PATCH 08/16] Fix build fail Signed-off-by: Seungha Son Change-Id: Ia0aaccb503d49a56d7af6598276853bc1b770acb --- src/wgt/wgt_app_query_interface.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wgt/wgt_app_query_interface.cc b/src/wgt/wgt_app_query_interface.cc index 4afdc3d..87252a0 100644 --- a/src/wgt/wgt_app_query_interface.cc +++ b/src/wgt/wgt_app_query_interface.cc @@ -23,6 +23,8 @@ #include #include +#include + #include #include #include -- 2.7.4 From df344f8339869ac75e4d04ca48275888a72ff9d7 Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Tue, 26 Sep 2017 15:52:18 +0900 Subject: [PATCH 09/16] Release version 0.7.1 Changes: - Fix codes for ManifestDirectInstall in Hybrid pkg Change-Id: Id90a2cf250611c181d66cc5c6ab195807c731258 Signed-off-by: Junghyun Yeon --- packaging/wgt-backend.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/wgt-backend.spec b/packaging/wgt-backend.spec index e0c49df..fa09ad8 100644 --- a/packaging/wgt-backend.spec +++ b/packaging/wgt-backend.spec @@ -1,6 +1,6 @@ Name: wgt-backend Summary: Application installer backend for WGT -Version: 0.7.0 +Version: 0.7.1 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From b0e4ad894443261c61a6611f5a62cc63e93caa23 Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Fri, 1 Sep 2017 09:29:54 +0900 Subject: [PATCH 10/16] Add step for privacy privilege Signed-off-by: Seungha Son Change-Id: I699da12a566354021361202c68b6567a162f78ec --- src/wgt/wgt_installer.cc | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index 1e09e65..3a8956b 100755 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -70,6 +70,7 @@ #include #include #include +#include #include #include #include @@ -233,6 +234,8 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep( + ci::security::StepPrivacyPrivilege::ActionType::Install); AddStep(); AddStep( ci::Plugin::ActionType::Install); @@ -281,6 +284,8 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep( + ci::security::StepPrivacyPrivilege::ActionType::Update); AddStep(); AddStep( ci::Plugin::ActionType::Upgrade); @@ -311,6 +316,8 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep( + ci::security::StepPrivacyPrivilege::ActionType::Uninstall); AddStep(); AddStep(); AddStep(); @@ -336,6 +343,8 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep( + ci::security::StepPrivacyPrivilege::ActionType::Update); AddStep(); AddStep(); AddStep(); @@ -385,6 +394,8 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep( + ci::security::StepPrivacyPrivilege::ActionType::Update); AddStep(); AddStep( ci::Plugin::ActionType::Upgrade); @@ -445,6 +456,8 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep( + ci::security::StepPrivacyPrivilege::ActionType::Install); AddStep(); AddStep( ci::Plugin::ActionType::Install); @@ -490,6 +503,8 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep( + ci::security::StepPrivacyPrivilege::ActionType::Update); AddStep(); AddStep( ci::Plugin::ActionType::Upgrade); @@ -517,6 +532,8 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep( + ci::security::StepPrivacyPrivilege::ActionType::Install); AddStep(); AddStep(ci::Plugin::ActionType::Install); AddStep( @@ -548,6 +565,8 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep( + ci::security::StepPrivacyPrivilege::ActionType::Update); AddStep(); AddStep( ci::Plugin::ActionType::Upgrade); @@ -591,6 +610,8 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep( + ci::security::StepPrivacyPrivilege::ActionType::Update); AddStep(); AddStep(ci::Plugin::ActionType::Upgrade); AddStep(); @@ -620,6 +641,8 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep( + ci::security::StepPrivacyPrivilege::ActionType::Update); AddStep(); AddStep(); AddStep(ci::Plugin::ActionType::Upgrade); @@ -637,6 +660,8 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep( + ci::security::StepPrivacyPrivilege::ActionType::Install); AddStep(); AddStep(ci::Plugin::ActionType::Install); AddStep( @@ -660,6 +685,8 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep( + ci::security::StepPrivacyPrivilege::ActionType::Update); AddStep(); AddStep( ci::Plugin::ActionType::Upgrade); @@ -682,6 +709,8 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep( + ci::security::StepPrivacyPrivilege::ActionType::Uninstall); AddStep(); } -- 2.7.4 From 5dc947088c5f35dead54268b60226c51c72a8fbc Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Thu, 28 Sep 2017 13:46:37 +0900 Subject: [PATCH 11/16] Release version 0.7.2 Changes: - Add step for privacy privilege Signed-off-by: Seungha Son Change-Id: I1967ce52af6a2951f6a8aa728eb101bd4ed336be --- packaging/wgt-backend.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/wgt-backend.spec b/packaging/wgt-backend.spec index fa09ad8..45e107b 100644 --- a/packaging/wgt-backend.spec +++ b/packaging/wgt-backend.spec @@ -1,6 +1,6 @@ Name: wgt-backend Summary: Application installer backend for WGT -Version: 0.7.1 +Version: 0.7.2 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From 89e87396cc8312f2ac3e5bb08f6ab9f04841cb8c Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Tue, 10 Oct 2017 21:22:21 +0900 Subject: [PATCH 12/16] Fix appdefined privilege parsing Requires: - https://review.tizen.org/gerrit/154530 Change-Id: If9add359f17bc952b86498c06f5dd3525d3130a5 Signed-off-by: Sangyoon Jang --- .../config.xml | 4 +- .../config.xml | 4 +- .../config.xml | 4 +- .../config.xml | 4 +- .../config.xml | 6 +-- .../config.xml | 4 +- .../config.xml | 4 +- .../config.xml | 6 +-- .../config.xml | 4 +- src/wgt/step/configuration/step_parse.cc | 43 +++++++++++----------- 10 files changed, 32 insertions(+), 51 deletions(-) diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_InvalidName/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_InvalidName/config.xml index 78ca65a..948de8c 100644 --- a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_InvalidName/config.xml +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_InvalidName/config.xml @@ -1,7 +1,5 @@ - - - + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_NoPKGID/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_NoPKGID/config.xml index 748f827..1fce6a4 100644 --- a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_NoPKGID/config.xml +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_NoPKGID/config.xml @@ -1,7 +1,5 @@ - - - + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_NoURI/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_NoURI/config.xml index 68e32f7..cfdfa4a 100644 --- a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_NoURI/config.xml +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_NoURI/config.xml @@ -1,7 +1,5 @@ - - - + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_OverLength/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_OverLength/config.xml index 201ebd7..8897072 100644 --- a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_OverLength/config.xml +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_OverLength/config.xml @@ -1,7 +1,5 @@ - - - + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_ManyElements/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_ManyElements/config.xml index f01fb27..9eecba2 100644 --- a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_ManyElements/config.xml +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_ManyElements/config.xml @@ -1,8 +1,6 @@ - - - - + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_MissingName/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_MissingName/config.xml index bb84800..1be2518 100644 --- a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_MissingName/config.xml +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_MissingName/config.xml @@ -1,7 +1,5 @@ - - - + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_ValidName/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_ValidName/config.xml index 613eae7..64572e9 100644 --- a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_ValidName/config.xml +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_ValidName/config.xml @@ -1,7 +1,5 @@ - - - + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_WithLicenseManyElements/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_WithLicenseManyElements/config.xml index 297cbdf..ad2ce75 100644 --- a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_WithLicenseManyElements/config.xml +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_WithLicenseManyElements/config.xml @@ -1,8 +1,6 @@ - - - - + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_WithLicenseValidName/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_WithLicenseValidName/config.xml index 7d85238..7985282 100644 --- a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_WithLicenseValidName/config.xml +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_WithLicenseValidName/config.xml @@ -1,7 +1,5 @@ - - - + diff --git a/src/wgt/step/configuration/step_parse.cc b/src/wgt/step/configuration/step_parse.cc index c339a8f..aa62f48 100644 --- a/src/wgt/step/configuration/step_parse.cc +++ b/src/wgt/step/configuration/step_parse.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -24,7 +25,7 @@ #include #include #include -#include +#include #include #include #include @@ -645,14 +646,13 @@ bool StepParse::FillPrivileges(manifest_x* manifest) { } bool StepParse::FillAppDefinedPrivileges(manifest_x* manifest) { - auto priv_info = - GetManifestDataForKey( + auto priv_info_list = + GetManifestDataForKey( app_keys::kTizenAppDefinedPrivilegeKey); - if (!priv_info) + if (!priv_info_list) return true; - const auto& privileges = priv_info->GetAppDefinedPrivilegeList(); - for (auto& priv : privileges) { + for (auto& priv : priv_info_list->appdefined_privileges) { appdefined_privilege_x* privilege = reinterpret_cast(calloc(1, sizeof(appdefined_privilege_x))); @@ -660,14 +660,14 @@ bool StepParse::FillAppDefinedPrivileges(manifest_x* manifest) { LOG(ERROR) << "Memory alloc failure"; return false; } - privilege->value = strdup(priv.privilege.c_str()); + privilege->value = strdup(priv.name().c_str()); privilege->type = strdup(common_installer::kWebPrivilegeType); - if (!priv.license.empty()) { - if (bf::path(priv.license).is_absolute()) - privilege->license = strdup(priv.license.c_str()); + if (!priv.license().empty()) { + if (bf::path(priv.license()).is_absolute()) + privilege->license = strdup(priv.license().c_str()); else privilege->license = strdup((context_->root_application_path.get() - / manifest->package / priv.license).c_str()); + / manifest->package / priv.license()).c_str()); } manifest->appdefined_privileges = g_list_append(manifest->appdefined_privileges, privilege); @@ -676,14 +676,13 @@ bool StepParse::FillAppDefinedPrivileges(manifest_x* manifest) { } bool StepParse::FillProvidesAppDefinedPrivileges(manifest_x* manifest) { - auto priv_info = - GetManifestDataForKey( - app_keys::kTizenProvidesAppDefinedPrivilegesKey); - if (!priv_info) + auto priv_info_list = + GetManifestDataForKey( + app_keys::kTizenProvidesAppDefinedPrivilegeKey); + if (!priv_info_list) return true; - const auto& privileges = priv_info->GetAppDefinedPrivilegeList(); - for (auto& priv : privileges) { + for (auto& priv : priv_info_list->appdefined_privileges) { appdefined_privilege_x* privilege = reinterpret_cast(calloc(1, sizeof(appdefined_privilege_x))); @@ -691,14 +690,14 @@ bool StepParse::FillProvidesAppDefinedPrivileges(manifest_x* manifest) { LOG(ERROR) << "Memory alloc failure"; return false; } - privilege->value = strdup(priv.privilege.c_str()); + privilege->value = strdup(priv.name().c_str()); privilege->type = strdup(common_installer::kWebPrivilegeType); - if (!priv.license.empty()) { - if (bf::path(priv.license).is_absolute()) - privilege->license = strdup(priv.license.c_str()); + if (!priv.license().empty()) { + if (bf::path(priv.license()).is_absolute()) + privilege->license = strdup(priv.license().c_str()); else privilege->license = strdup((context_->root_application_path.get() - / manifest->package / priv.license).c_str()); + / manifest->package / priv.license()).c_str()); } manifest->provides_appdefined_privileges = g_list_append(manifest->provides_appdefined_privileges, privilege); -- 2.7.4 From e21f1383ac2b2c2a787d0787a7b927b1f820eed9 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Tue, 10 Oct 2017 23:00:13 +0900 Subject: [PATCH 13/16] Fix smoke test We don't need to validate pkgid of appdefined-privilege for client. Change-Id: I5ee7f12398e682a1071d92c37091025573c12f2d Signed-off-by: Sangyoon Jang --- src/unit_tests/manifest_test.cc | 5 ----- .../config.xml | 5 ----- 2 files changed, 10 deletions(-) delete mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_Invalid_NoPKGID/config.xml diff --git a/src/unit_tests/manifest_test.cc b/src/unit_tests/manifest_test.cc index 90c9ed6..051d2f3 100644 --- a/src/unit_tests/manifest_test.cc +++ b/src/unit_tests/manifest_test.cc @@ -223,11 +223,6 @@ TEST_F(ManifestTest, AppDefinedPrivilegeElement_Invalid_NotURI) { ASSERT_FALSE(runner.Run()); } -TEST_F(ManifestTest, AppDefinedPrivilegeElement_Invalid_NoPKGID) { - StepParseRunner runner(GetMyName()); - ASSERT_FALSE(runner.Run()); -} - TEST_F(ManifestTest, AppDefinedPrivilegeElement_Invalid_OverLength) { StepParseRunner runner(GetMyName()); ASSERT_FALSE(runner.Run()); diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_Invalid_NoPKGID/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_Invalid_NoPKGID/config.xml deleted file mode 100644 index 4cb239b..0000000 --- a/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_Invalid_NoPKGID/config.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - -- 2.7.4 From ed442f20db110d4754826bd523026254bf35b72a Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Wed, 11 Oct 2017 21:34:21 +0900 Subject: [PATCH 14/16] Release version 0.7.3 Changes: - Fix appdefined privilege parsing - Fix smoke test Change-Id: Iebcf9a186cdd05a5955cce40cf76ffe20776a5af Signed-off-by: Sangyoon Jang --- packaging/wgt-backend.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/wgt-backend.spec b/packaging/wgt-backend.spec index 45e107b..aaa8808 100644 --- a/packaging/wgt-backend.spec +++ b/packaging/wgt-backend.spec @@ -1,6 +1,6 @@ Name: wgt-backend Summary: Application installer backend for WGT -Version: 0.7.2 +Version: 0.7.3 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From 8177294c286d2c288ad48855ee2057f833dd7da3 Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Tue, 17 Oct 2017 11:40:02 +0900 Subject: [PATCH 15/16] Fix static analysis issue - Check if new operator has failed. Change-Id: I840874abdac89bb91f6e5aca26df2ac265a541ac Signed-off-by: Junghyun Yeon --- src/wgt/step/configuration/step_parse.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/wgt/step/configuration/step_parse.cc b/src/wgt/step/configuration/step_parse.cc index aa62f48..0fe8083 100644 --- a/src/wgt/step/configuration/step_parse.cc +++ b/src/wgt/step/configuration/step_parse.cc @@ -200,7 +200,11 @@ bool StepParse::FillIconPaths(manifest_x* manifest) { GetManifestDataForKey( app_keys::kIconsKey); if (!icons_info) { - icons_info.reset(new wgt::parse::ApplicationIconsInfo()); + icons_info.reset(new(std::nothrow) wgt::parse::ApplicationIconsInfo()); + if (!icons_info) { + LOG(ERROR) << "Out of memory"; + return false; + } } wgt::parse::LocalizedApplicationIconsInfo localized_list = wgt::parse::GetLocalizedIconList(*icons_info, widget_path_); @@ -867,7 +871,11 @@ common_installer::Step::Status StepParse::process() { return common_installer::Step::Status::MANIFEST_NOT_FOUND; } - parser_.reset(new wgt::parse::WidgetConfigParser()); + parser_.reset(new(std::nothrow) wgt::parse::WidgetConfigParser()); + if (!parser_) { + LOG(ERROR) << "Out of memory"; + return common_installer::Step::Status::CONFIG_ERROR; + } if (!parser_->ParseManifest(widget_path_ / kConfigFileName)) { LOG(ERROR) << "[Parse] Parse failed. " << parser_->GetErrorMessage(); return common_installer::Step::Status::PARSE_ERROR; -- 2.7.4 From 4160fc656c905e15a179dc4c758b774a4a428c31 Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Thu, 14 Sep 2017 10:31:17 +0900 Subject: [PATCH 16/16] Change behavior of trust anchor - Trust anchor certificate dir has fixed so it will not defined at manifest. - Remove get/set codes about certificate directory. - Enable trust-anchor on hybrid package. Please note that if both tpk and wgt package have trust-anchor node, wgt's setting will be appliced. Related changes: [pkgmgr-info] : https://review.tizen.org/gerrit/149784 [app-installers] : https://review.tizen.org/gerrit/149836 [tpk-manifest-handlers] : https://review.tizen.org/gerrit/150060 [wgt-manifest-handlers] : https://review.tizen.org/gerrit/150136 Change-Id: Ie110eb1b52695c985495f03b834c9bfd9e5bf960 Signed-off-by: Junghyun Yeon --- src/hybrid/hybrid_installer.cc | 22 +++++++++++++++++ src/hybrid/step/pkgmgr/step_generate_xml.cc | 1 + src/wgt/step/configuration/step_parse.cc | 4 ---- src/wgt/step/pkgmgr/step_generate_xml.cc | 6 +---- src/wgt/wgt_installer.cc | 37 +++++++++++++++++++---------- 5 files changed, 48 insertions(+), 22 deletions(-) diff --git a/src/hybrid/hybrid_installer.cc b/src/hybrid/hybrid_installer.cc index 5a6e342..2a28e39 100644 --- a/src/hybrid/hybrid_installer.cc +++ b/src/hybrid/hybrid_installer.cc @@ -70,6 +70,8 @@ #include #include #include +#include +#include #include #include @@ -148,6 +150,8 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep(); AddStep(); + AddStep( + ci::security::StepRegisterTrustAnchor::RegisterType::INSTALL); AddStep(); AddStep( ci::Plugin::ActionType::Install); @@ -201,6 +205,8 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep(); AddStep(); + AddStep( + ci::security::StepRegisterTrustAnchor::RegisterType::INSTALL); AddStep(); AddStep( ci::Plugin::ActionType::Upgrade); @@ -229,6 +235,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); @@ -285,6 +292,8 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep(); AddStep(); + AddStep( + ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE); AddStep(); AddStep(); AddStep( @@ -351,6 +360,8 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep(); AddStep(); + AddStep( + ci::security::StepRegisterTrustAnchor::RegisterType::INSTALL); AddStep(); AddStep( ci::Plugin::ActionType::Install); @@ -403,6 +414,8 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep(); AddStep(); + AddStep( + ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE); AddStep(); AddStep( ci::Plugin::ActionType::Upgrade); @@ -434,6 +447,8 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep(); AddStep(); + AddStep( + ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE); AddStep(); AddStep( ci::Plugin::ActionType::Install); @@ -468,6 +483,8 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep(); AddStep(); + AddStep( + ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE); AddStep(); AddStep( ci::Plugin::ActionType::Upgrade); @@ -488,6 +505,8 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep(); AddStep(); + AddStep( + ci::security::StepRegisterTrustAnchor::RegisterType::INSTALL); AddStep(); AddStep( ci::Plugin::ActionType::Install); @@ -513,6 +532,8 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep(); AddStep(); + AddStep( + ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE); AddStep(); AddStep( ci::Plugin::ActionType::Upgrade); @@ -535,6 +556,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); break; } diff --git a/src/hybrid/step/pkgmgr/step_generate_xml.cc b/src/hybrid/step/pkgmgr/step_generate_xml.cc index 00e4e5d..89772c2 100644 --- a/src/hybrid/step/pkgmgr/step_generate_xml.cc +++ b/src/hybrid/step/pkgmgr/step_generate_xml.cc @@ -34,6 +34,7 @@ const std::vector kBlackListNodes = { {"profile"}, {"privileges"}, {"provides-appdefined-privileges"}, + {"trust-anchor"}, }; const std::vector kNeedMergeNodes = { {"manifest"}, diff --git a/src/wgt/step/configuration/step_parse.cc b/src/wgt/step/configuration/step_parse.cc index 0fe8083..05a3b5d 100644 --- a/src/wgt/step/configuration/step_parse.cc +++ b/src/wgt/step/configuration/step_parse.cc @@ -592,10 +592,6 @@ bool StepParse::FillTrustAnchorInfo(manifest_x* manifest) { 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()); diff --git a/src/wgt/step/pkgmgr/step_generate_xml.cc b/src/wgt/step/pkgmgr/step_generate_xml.cc index 404b5c8..91d9f56 100644 --- a/src/wgt/step/pkgmgr/step_generate_xml.cc +++ b/src/wgt/step/pkgmgr/step_generate_xml.cc @@ -677,14 +677,10 @@ 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) + if (!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); diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index 3a8956b..130c597 100755 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -80,7 +80,6 @@ #include #include #include -#include #include @@ -233,7 +232,8 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); - AddStep(); + AddStep( + ci::security::StepRegisterTrustAnchor::RegisterType::INSTALL); AddStep( ci::security::StepPrivacyPrivilege::ActionType::Install); AddStep(); @@ -283,7 +283,8 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); - AddStep(); + AddStep( + ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE); AddStep( ci::security::StepPrivacyPrivilege::ActionType::Update); AddStep(); @@ -342,7 +343,8 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); - AddStep(); + AddStep( + ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE); AddStep( ci::security::StepPrivacyPrivilege::ActionType::Update); AddStep(); @@ -393,7 +395,8 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); - AddStep(); + AddStep( + ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE); AddStep( ci::security::StepPrivacyPrivilege::ActionType::Update); AddStep(); @@ -455,7 +458,8 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); - AddStep(); + AddStep( + ci::security::StepRegisterTrustAnchor::RegisterType::INSTALL); AddStep( ci::security::StepPrivacyPrivilege::ActionType::Install); AddStep(); @@ -502,7 +506,8 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); - AddStep(); + AddStep( + ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE); AddStep( ci::security::StepPrivacyPrivilege::ActionType::Update); AddStep(); @@ -531,7 +536,8 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); - AddStep(); + AddStep( + ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE); AddStep( ci::security::StepPrivacyPrivilege::ActionType::Install); AddStep(); @@ -564,7 +570,8 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); - AddStep(); + AddStep( + ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE); AddStep( ci::security::StepPrivacyPrivilege::ActionType::Update); AddStep(); @@ -609,7 +616,8 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); - AddStep(); + AddStep( + ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE); AddStep( ci::security::StepPrivacyPrivilege::ActionType::Update); AddStep(); @@ -640,7 +648,8 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); - AddStep(); + AddStep( + ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE); AddStep( ci::security::StepPrivacyPrivilege::ActionType::Update); AddStep(); @@ -659,7 +668,8 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); - AddStep(); + AddStep( + ci::security::StepRegisterTrustAnchor::RegisterType::INSTALL); AddStep( ci::security::StepPrivacyPrivilege::ActionType::Install); AddStep(); @@ -684,7 +694,8 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); - AddStep(); + AddStep( + ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE); AddStep( ci::security::StepPrivacyPrivilege::ActionType::Update); AddStep(); -- 2.7.4