From 8eb7ab570513da2cf2c5bf63b411943f9c36db2b Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Tue, 9 Jan 2018 11:06:39 +0900 Subject: [PATCH 01/16] Add a step for recovering ReadonlyUpdateInstall mode Requires: - https://review.tizen.org/gerrit/158844 Change-Id: Ib5483a13729787be094cd0a0144aaa32450a0ae1 Signed-off-by: Sangyoon Jang --- src/wgt/wgt_installer.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index d6a3b55..b90690b 100755 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -347,6 +348,7 @@ void WgtInstaller::RecoverySteps() { AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); -- 2.7.4 From c5eea02c665df1eaf0cdba88205a46734edbb7a8 Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Thu, 11 Jan 2018 18:54:46 +0900 Subject: [PATCH 02/16] Add condition to check nullptr Signed-off-by: Seungha Son Change-Id: I4557bbb36ede24d897f80f38dd488c07f4320736 --- src/hybrid/step/pkgmgr/step_generate_xml.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hybrid/step/pkgmgr/step_generate_xml.cc b/src/hybrid/step/pkgmgr/step_generate_xml.cc index 6e85efb..10246e9 100644 --- a/src/hybrid/step/pkgmgr/step_generate_xml.cc +++ b/src/hybrid/step/pkgmgr/step_generate_xml.cc @@ -111,8 +111,8 @@ void StepGenerateXml::MergeXmlNode(xmlNodePtr node1, xmlNodePtr node2) { if (std::find(kNeedMergeNodes.begin(), kNeedMergeNodes.end(), reinterpret_cast(cur->name)) != kNeedMergeNodes.end()) continue; - xmlAddNextSibling(last, cur); - last = last->next; + if (xmlAddNextSibling(last, cur) != nullptr) + last = last->next; } } -- 2.7.4 From 8a504f3958f80eb8b7f3480de6266e009f696512 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Tue, 16 Jan 2018 14:34:52 +0900 Subject: [PATCH 03/16] Add StepPrivilegeCompatibility at RecoverySteps To recover internal privileges, StepPrivilegeCompatibility should be added. Change-Id: I4a162bfc3f2fd00ccbf6724f691e6bf98c4b4262 Signed-off-by: Sangyoon Jang --- src/wgt/wgt_installer.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index b90690b..b502737 100755 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -352,6 +352,8 @@ void WgtInstaller::RecoverySteps() { AddStep(); AddStep(); AddStep(); + AddStep( + ci::security::StepPrivilegeCompatibility::InternalPrivType::WGT); AddStep(); AddStep(); AddStep(); -- 2.7.4 From b36f9ab645512fb12dc937e11b88ff25444c0f7d Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Wed, 17 Jan 2018 14:41:45 +0900 Subject: [PATCH 04/16] Add StepPrivilegeCompatibility at ReadonlyUpdateUninstallSteps To install internal privileges, StepPrivilegeCompatibility should be added. Change-Id: I7c6b3042d8729c78906d6982b4ce4d4239c9fa2d Signed-off-by: Sangyoon Jang --- src/wgt/wgt_installer.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index b502737..ce20ebd 100755 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -578,6 +578,8 @@ void WgtInstaller::ReadonlyUpdateUninstallSteps() { AddStep(); AddStep(); AddStep(); + AddStep( + ci::security::StepPrivilegeCompatibility::InternalPrivType::WGT); AddStep(); AddStep(); AddStep(); -- 2.7.4 From e7a8379036e7fa1a20cf7001ecf4d0da41ac0dbc Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Wed, 17 Jan 2018 21:00:04 +0900 Subject: [PATCH 05/16] Add StepCreateRecoveryFile at ReadonlyUpdateInstallSteps Change-Id: Ia4a0335c3c43b5f3222c98b958deb0cd677b5601 Signed-off-by: Sangyoon Jang --- src/wgt/wgt_installer.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index ce20ebd..96fa5ab 100755 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -521,6 +521,7 @@ void WgtInstaller::ManifestDirectUpdateSteps() { void WgtInstaller::ReadonlyUpdateInstallSteps() { AddStep(pkgmgr_); + AddStep(); AddStep(); AddStep( wgt::configuration::StepParse::ConfigLocation::PACKAGE, true); -- 2.7.4 From 362b56335ec32ed28ca69f5175cfc61132353fac Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Wed, 17 Jan 2018 21:14:51 +0900 Subject: [PATCH 06/16] Replace StepPrivilegeCompatibility with StepRecoverPrivilegeCompatibility Requires: - https://review.tizen.org/gerrit/167411 Change-Id: I1ba4b0461d42657516584f4c09a68fa7dedae705 Signed-off-by: Sangyoon Jang --- src/wgt/wgt_installer.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index 96fa5ab..8c6961a 100755 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -76,6 +76,7 @@ #include #include #include +#include #include #include #include @@ -352,7 +353,7 @@ void WgtInstaller::RecoverySteps() { AddStep(); AddStep(); AddStep(); - AddStep( + AddStep( ci::security::StepPrivilegeCompatibility::InternalPrivType::WGT); AddStep(); AddStep(); -- 2.7.4 From d73f0d2ab846bf344f48070aca63812114356b79 Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Fri, 19 Jan 2018 16:51:44 +0900 Subject: [PATCH 07/16] Release version 0.9.3 Changes: - Refactoring ValidatePackage() functions parameter - Set nodisplay attribute of widget application as manifest value - Add a step for recovering ReadonlyUpdateInstall mode - Add condition to check nullptr - Add StepPrivilegeCompatibility at RecoverySteps - Add StepPrivilegeCompatibility at ReadonlyUpdateUninstallSteps - Add StepCreateRecoveryFile at ReadonlyUpdateInstallSteps - Replace StepPrivilegeCompatibility with StepRecoverPrivilegeCompatibility Change-Id: I5e16453f2a10c961091582a4471c26d1fe4f6a4f 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 cc48776..365b887 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.9.2 +Version: 0.9.3 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From a619faf452f2573cc20d38e5ff3cceb0286b9561 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Wed, 24 Jan 2018 14:14:27 +0900 Subject: [PATCH 08/16] Fix RecoverySteps of hybrid backend Add missing steps. Change-Id: I1aa19c050223689869954b9f0e55e18d3bf151c4 Signed-off-by: Sangyoon Jang --- src/hybrid/hybrid_installer.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/hybrid/hybrid_installer.cc b/src/hybrid/hybrid_installer.cc index 5ec69e9..3b69022 100644 --- a/src/hybrid/hybrid_installer.cc +++ b/src/hybrid/hybrid_installer.cc @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -66,6 +67,7 @@ #include #include #include +#include #include #include #include @@ -331,10 +333,13 @@ void HybridInstaller::RecoverySteps() { AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); AddStep(); + AddStep( + ci::security::StepPrivilegeCompatibility::InternalPrivType::BOTH); AddStep(); AddStep(); AddStep(); -- 2.7.4 From f891123d32554039738fb1347c4cfa91b5246c01 Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Fri, 26 Jan 2018 11:39:29 +0900 Subject: [PATCH 09/16] Remove unnecessary step StepRollbackDeinstallationSecurity is meaningless. It is meaningless to rollback in undo() because removing the security is done after uninstall process() steps have been compelted. Signed-off-by: Seungha Son Change-Id: I8aeae5000320b7707b252f496aedfe6e19dada2e --- src/hybrid/hybrid_installer.cc | 2 -- src/wgt/wgt_installer.cc | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/hybrid/hybrid_installer.cc b/src/hybrid/hybrid_installer.cc index 3b69022..9be075e 100644 --- a/src/hybrid/hybrid_installer.cc +++ b/src/hybrid/hybrid_installer.cc @@ -71,7 +71,6 @@ #include #include #include -#include #include #include #include @@ -242,7 +241,6 @@ void HybridInstaller::UninstallSteps() { AddStep(); AddStep(); AddStep(); - AddStep(); AddStep(); AddStep(); AddStep(); diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index 8c6961a..75630c9 100755 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -80,7 +80,6 @@ #include #include #include -#include #include #include #include @@ -238,7 +237,6 @@ void WgtInstaller::UninstallSteps() { ci::Plugin::ActionType::Uninstall); AddStep(); AddStep(); - AddStep(); AddStep(); AddStep(); AddStep(); -- 2.7.4 From 8500bc921a3572a7dc4b55c5a7cf076b5ca43581 Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Fri, 2 Feb 2018 14:03:32 +0900 Subject: [PATCH 10/16] Release version 0.9.4 Changes: - Fix RecoverySteps of hybrid backend - Remove unnecessary step Change-Id: Iac1f21516fe6709a5f3e4e1631a27b0ac71a7a2d 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 365b887..dce227b 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.9.3 +Version: 0.9.4 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From f0dd91560b64b43f03cf4dad701fe382bac1ec08 Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Thu, 18 Jan 2018 11:14:38 +0900 Subject: [PATCH 11/16] Add codes to enable ManifestDirectInstall for mount intalled pkg - Some files should be extracted. - Add Step to determine whether given pkg is mount installed or not. - Override undo() to enable undo operation. Related changes: [app-installers] : https://review.tizen.org/gerrit/167144 Change-Id: I03d22721135e8b3607c5a18f11dc06e9b82ef070 Signed-off-by: Junghyun Yeon --- .../step_wgt_prepare_package_directory.cc | 110 ++++++++++++++++++--- .../step_wgt_prepare_package_directory.h | 7 +- src/wgt/wgt_installer.cc | 3 + 3 files changed, 102 insertions(+), 18 deletions(-) diff --git a/src/wgt/step/filesystem/step_wgt_prepare_package_directory.cc b/src/wgt/step/filesystem/step_wgt_prepare_package_directory.cc index d3f53b1..10c44a7 100644 --- a/src/wgt/step/filesystem/step_wgt_prepare_package_directory.cc +++ b/src/wgt/step/filesystem/step_wgt_prepare_package_directory.cc @@ -19,42 +19,102 @@ namespace { const char kResWgtDirectory[] = "res/wgt"; +const std::vector kExtractEntries = { + "config.xml", + "index.html", + "author-signature.xml", + "signature1.xml", + "signature2.xml" +}; + +const std::vector& GetExtractEntries() { + return kExtractEntries; +} + } // namespace namespace wgt { namespace filesystem { -ci::Step::Status StepWgtPreparePackageDirectory::CreateSymlinkToMountPoint() { +ci::Step::Status StepWgtPreparePackageDirectory::CreateSymlinks() { bs::error_code error; bf::path mount_point = ci::GetMountLocation(context_->GetPkgPath()); bf::path res_wgt_link = context_->GetPkgPath() / kResWgtDirectory; - if (bf::exists(res_wgt_link)) { - if (!bf::is_symlink(symlink_status(res_wgt_link))) { - LOG(ERROR) << res_wgt_link << " is not symlink. Cannot proceed"; - return Status::APP_DIR_ERROR; - } - bf::remove(res_wgt_link, error); - if (error) { - LOG(ERROR) << "Failed to remote old symlink to wgt resource directory"; - return Status::APP_DIR_ERROR; + + std::vector fileList; + std::vector extractEntries = GetExtractEntries(); + for (bf::directory_iterator iter(mount_point); + iter != bf::directory_iterator(); ++iter) { + bf::path current(iter->path()); + if (std::find(extractEntries.begin(), extractEntries.end(), + current.filename()) != extractEntries.end()) + continue; + + bf::path destination = res_wgt_link / current.filename(); + if (bf::exists(destination)) { + if (!bf::is_symlink(symlink_status(destination))) { + LOG(ERROR) << "Cannot proceed. " + << "Location of link is used by another file"; + return Status::APP_DIR_ERROR; + } + bf::remove(destination, error); + if (error) { + LOG(ERROR) << "Failed to remove previous symlink"; + return Status::APP_DIR_ERROR; + } } - } else { - bf::create_directories(res_wgt_link.parent_path(), error); + bf::create_symlink(iter->path(), destination, error); if (error) { - LOG(ERROR) << "Failed to create " << kResWgtDirectory << " directory"; + LOG(ERROR) << "Failed to create symlink to widget image :" << + boost::system::system_error(error).what(); return Status::APP_DIR_ERROR; } } - bf::create_symlink(mount_point, res_wgt_link, error); + + return Status::OK; +} + +ci::Step::Status StepWgtPreparePackageDirectory::ExtractEntries() { + bf::path backup_path = + ci::GetBackupPathForPackagePath(context_->GetPkgPath()); + backupPath_ = backup_path; + if (context_->request_type.get() == ci::RequestType::MountUpdate && + context_->recovery_info.get().recovery_file) { + context_->recovery_info.get().recovery_file->set_unpacked_dir(backup_path); + context_->recovery_info.get().recovery_file->WriteAndCommitFileContent(); + } + + bf::path resource_path = context_->GetPkgPath() / kResWgtDirectory; + bs::error_code error; + bf::create_directories(resource_path, error); if (error) { - LOG(ERROR) << "Failed to create symlink to widget image"; + LOG(ERROR) << "Failed to create proper directory structure in widget"; return Status::APP_DIR_ERROR; } + + for (auto& entry : GetExtractEntries()) { + if (context_->request_type.get() == ci::RequestType::MountUpdate) + if (!ci::BackupDir(resource_path, backup_path, entry)) + return Status::APP_DIR_ERROR; + + if (!ci::ExtractToTmpDir(context_->file_path.get().c_str(), + resource_path.c_str(), entry)) { + LOG(ERROR) << "Failed to extract file"; + return Status::UNZIP_ERROR; + } + } + return Status::OK; } ci::Step::Status StepWgtPreparePackageDirectory::process() { - Status status = CreateSymlinkToMountPoint(); + Status status; + + status = ExtractEntries(); + if (status != Status::OK) + return status; + + status = CreateSymlinks(); if (status != Status::OK) return status; LOG(DEBUG) << "Symlink to mount point created"; @@ -70,5 +130,23 @@ ci::Step::Status StepWgtPreparePackageDirectory::precheck() { return Status::OK; } +ci::Step::Status StepWgtPreparePackageDirectory::undo() { + if (backupPath_.empty()) + return Status::OK; + + for (auto& entry : GetExtractEntries()) { + ci::RemoveAll(context_->GetPkgPath() / kResWgtDirectory / entry); + if (!bf::exists(backupPath_ / entry)) + continue; + ci::MoveDir(backupPath_ / entry, + context_->GetPkgPath() / kResWgtDirectory / entry, + ci::FSFlag::FS_MERGE_OVERWRITE | + ci::FSFlag::FS_COMMIT_COPY_FILE | + ci::FSFlag::FS_PRESERVE_OWNERSHIP_AND_PERMISSIONS); + } + ci::RemoveAll(backupPath_); + return Status::OK; +} + } // namespace filesystem } // namespace wgt diff --git a/src/wgt/step/filesystem/step_wgt_prepare_package_directory.h b/src/wgt/step/filesystem/step_wgt_prepare_package_directory.h index dd98d4c..8b9f14c 100644 --- a/src/wgt/step/filesystem/step_wgt_prepare_package_directory.h +++ b/src/wgt/step/filesystem/step_wgt_prepare_package_directory.h @@ -30,11 +30,14 @@ class StepWgtPreparePackageDirectory : public common_installer::Step { Status process() override; Status clean() override { return Status::OK; } - Status undo() override { return Status::OK; } + Status undo() override; Status precheck() override; private: - Status CreateSymlinkToMountPoint(); + boost::filesystem::path backupPath_; + + Status ExtractEntries(); + Status CreateSymlinks(); STEP_NAME(WgtPreparePackageDirectory) }; diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index 75630c9..056c8b6 100755 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -52,6 +52,7 @@ #include #include #include +#include #include #include #include @@ -458,6 +459,7 @@ void WgtInstaller::ManifestDirectInstallSteps() { AddStep( wgt::configuration::StepParse::ConfigLocation::INSTALLED, true); AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); @@ -488,6 +490,7 @@ void WgtInstaller::ManifestDirectUpdateSteps() { AddStep(pkgmgr_); AddStep( wgt::configuration::StepParse::ConfigLocation::INSTALLED, true); + AddStep(); AddStep(); AddStep(); AddStep(); -- 2.7.4 From 7b6c8bc6bce55a27748d0441d64901ef565c006f Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Mon, 5 Feb 2018 19:08:05 +0900 Subject: [PATCH 12/16] Fix smoke test - Cast global environment object just once when allocating. Use static_cast for downcasting, because we know obviously that SmokeEnvironment class is derived from testing::Environment class. - Remove unused variables. Change-Id: If5865c60aed4047cce7824a4e94f6379102d8767 Signed-off-by: Sangyoon Jang --- src/unit_tests/smoke_test.cc | 56 +++++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 34 deletions(-) diff --git a/src/unit_tests/smoke_test.cc b/src/unit_tests/smoke_test.cc index 14fda52..b5bf24d 100644 --- a/src/unit_tests/smoke_test.cc +++ b/src/unit_tests/smoke_test.cc @@ -55,26 +55,22 @@ class SmokeEnvironment : public testing::Environment { namespace { -testing::Environment *env = nullptr; +smoke_test::SmokeEnvironment* env = nullptr; void signalHandler(int signum) { env->TearDown(); exit(signum); } -smoke_test::SmokeEnvironment *dcast(testing::Environment* _env) { - return dynamic_cast(_env); -} - } // namespace namespace smoke_test { class SmokeTest : public testing::Test { public: - SmokeTest() : backend(std::to_string(dcast(env)->test_user.uid)), + SmokeTest() : backend(std::to_string(env->test_user.uid)), params{PackageType::WGT, false} { - params.test_user.uid = dcast(env)->test_user.uid; - params.test_user.gid = dcast(env)->test_user.gid; + params.test_user.uid = env->test_user.uid; + params.test_user.gid = env->test_user.gid; } protected: WgtBackendInterface backend; @@ -83,10 +79,10 @@ class SmokeTest : public testing::Test { class RollbackSmokeTest : public testing::Test { public: - RollbackSmokeTest() : backend(std::to_string(dcast(env)->test_user.uid), + RollbackSmokeTest() : backend(std::to_string(env->test_user.uid), RequestResult::FAIL), params{PackageType::WGT, false} { - params.test_user.uid = dcast(env)->test_user.uid; - params.test_user.gid = dcast(env)->test_user.gid; + params.test_user.uid = env->test_user.uid; + params.test_user.gid = env->test_user.gid; } protected: WgtBackendInterface backend; @@ -95,10 +91,10 @@ class RollbackSmokeTest : public testing::Test { class HybridSmokeTest : public testing::Test { public: - HybridSmokeTest() : backend(std::to_string(dcast(env)->test_user.uid)), + HybridSmokeTest() : backend(std::to_string(env->test_user.uid)), params{PackageType::HYBRID, false} { - params.test_user.uid = dcast(env)->test_user.uid; - params.test_user.gid = dcast(env)->test_user.gid; + params.test_user.uid = env->test_user.uid; + params.test_user.gid = env->test_user.gid; } protected: HybridBackendInterface backend; @@ -107,10 +103,10 @@ class HybridSmokeTest : public testing::Test { class RollbackHybridSmokeTest : public testing::Test { public: - RollbackHybridSmokeTest() : backend(std::to_string(dcast(env)->test_user.uid), + RollbackHybridSmokeTest() : backend(std::to_string(env->test_user.uid), RequestResult::FAIL), params{PackageType::HYBRID, false} { - params.test_user.uid = dcast(env)->test_user.uid; - params.test_user.gid = dcast(env)->test_user.gid; + params.test_user.uid = env->test_user.uid; + params.test_user.gid = env->test_user.gid; } protected: HybridBackendInterface backend; @@ -119,10 +115,10 @@ class RollbackHybridSmokeTest : public testing::Test { class PreloadSmokeTest : public testing::Test { public: - PreloadSmokeTest() : backend(std::to_string(dcast(env)->test_user.uid)), + PreloadSmokeTest() : backend(std::to_string(env->test_user.uid)), params{PackageType::WGT, true} { - params.test_user.uid = dcast(env)->test_user.uid; - params.test_user.gid = dcast(env)->test_user.gid; + params.test_user.uid = env->test_user.uid; + params.test_user.gid = env->test_user.gid; } protected: WgtBackendInterface backend; @@ -131,10 +127,10 @@ class PreloadSmokeTest : public testing::Test { class HybridPreloadSmokeTest : public testing::Test { public: - HybridPreloadSmokeTest() : backend(std::to_string(dcast(env)->test_user.uid)), + HybridPreloadSmokeTest() : backend(std::to_string(env->test_user.uid)), params{PackageType::HYBRID, true} { - params.test_user.uid = dcast(env)->test_user.uid; - params.test_user.gid = dcast(env)->test_user.gid; + params.test_user.uid = env->test_user.uid; + params.test_user.gid = env->test_user.gid; } protected: HybridBackendInterface backend; @@ -167,7 +163,6 @@ TEST_F(SmokeTest, UpdateMode) { TEST_F(SmokeTest, DeinstallationMode) { bf::path path = kSmokePackagesDirectory / "DeinstallationMode.wgt"; std::string pkgid = "smokewgt05"; - std::string appid = "smokewgt05.DeinstallationMode"; ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK); ASSERT_EQ(backend.Uninstall(pkgid), ci::AppInstaller::Result::OK); ASSERT_TRUE(CheckPackageNonExistance(pkgid, params)); @@ -246,7 +241,6 @@ TEST_F(SmokeTest, RecoveryMode_ForInstallation) { ASSERT_NE(backend_crash.Wait(), 0); std::string pkgid = "smokewgt09"; - std::string appid = "smokewgt09.RecoveryModeForInstallation"; bf::path recovery_file = FindRecoveryFile("/wgt-recovery", params.test_user.uid); ASSERT_FALSE(recovery_file.empty()); @@ -309,7 +303,6 @@ TEST_F(SmokeTest, RecoveryMode_ForMountInstall) { ASSERT_NE(backend_crash.Wait(), 0); std::string pkgid = "smokewgt31"; - std::string appid = "smokewgt31.RecoveryModeForMountInstall"; bf::path recovery_file = FindRecoveryFile("/wgt-recovery", params.test_user.uid); ASSERT_FALSE(recovery_file.empty()); @@ -364,7 +357,6 @@ TEST_F(SmokeTest, InstallationMode_WrongSignature) { TEST_F(RollbackSmokeTest, InstallationMode) { bf::path path = kSmokePackagesDirectory / "InstallationMode_Rollback.wgt"; std::string pkgid = "smokewgt06"; - std::string appid = "smokewgt06.InstallationModeRollback"; ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::ERROR); ASSERT_TRUE(CheckPackageNonExistance(pkgid, params)); } @@ -432,7 +424,6 @@ TEST_F(HybridSmokeTest, UpdateMode) { TEST_F(HybridSmokeTest, DeinstallationMode) { bf::path path = kSmokePackagesDirectory / "DeinstallationMode_Hybrid.wgt"; std::string pkgid = "smokehyb03"; - std::string appid1 = "smokehyb03.Web"; ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK); ASSERT_EQ(backend.Uninstall(pkgid), ci::AppInstaller::Result::OK); ASSERT_TRUE(CheckPackageNonExistance(pkgid, params)); @@ -492,7 +483,6 @@ TEST_F(RollbackHybridSmokeTest, InstallationMode) { bf::path path = kSmokePackagesDirectory / "InstallationMode_Rollback_Hybrid.wgt"; std::string pkgid = "smokehyb07"; - std::string appid1 = "smokehyb07.web"; ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::ERROR); ASSERT_TRUE(CheckPackageNonExistance(pkgid, params)); } @@ -545,7 +535,6 @@ TEST_F(RollbackHybridSmokeTest, MountInstallationMode) { bf::path path = kSmokePackagesDirectory / "MountInstallationMode_Rollback_Hybrid.wgt"; std::string pkgid = "smokehyb09"; - std::string appid1 = "smokehyb09.web"; ASSERT_EQ(backend.MountInstall(path), ci::AppInstaller::Result::ERROR); ScopedTzipInterface interface(pkgid, params.test_user.uid); ASSERT_TRUE(CheckPackageNonExistance(pkgid, params)); @@ -602,7 +591,6 @@ TEST_F(RollbackSmokeTest, MountInstallationMode) { bf::path path = kSmokePackagesDirectory / "MountInstallationMode_Rollback.wgt"; std::string pkgid = "smokewgt33"; - std::string appid = "smokewgt33.web"; ASSERT_EQ(backend.MountInstall(path), ci::AppInstaller::Result::ERROR); ScopedTzipInterface interface(pkgid, params.test_user.uid); ASSERT_TRUE(CheckPackageNonExistance(pkgid, params)); @@ -703,7 +691,6 @@ TEST_F(PreloadSmokeTest, DeinstallationMode) { ASSERT_EQ(getuid(), 0) << "Test cannot be run by normal user"; bf::path path = kSmokePackagesDirectory / "DeinstallationMode_Preload.wgt"; std::string pkgid = "smokewgt39"; - std::string appid = "smokewgt39.DeinstallationModePreload"; ASSERT_EQ(backend.InstallPreload(path), ci::AppInstaller::Result::OK); ASSERT_EQ(backend.UninstallPreload(pkgid), ci::AppInstaller::Result::OK); CheckPackageReadonlyNonExistance(pkgid, params); @@ -886,8 +873,9 @@ int main(int argc, char** argv) { ::testing::GTEST_FLAG(filter) = "SmokeTest.*"; } testing::InitGoogleTest(&argc, argv); - ::env = testing::AddGlobalTestEnvironment( - new smoke_test::SmokeEnvironment(request_mode)); + ::env = static_cast( + testing::AddGlobalTestEnvironment( + new smoke_test::SmokeEnvironment(request_mode))); signal(SIGINT, ::signalHandler); signal(SIGSEGV, ::signalHandler); return RUN_ALL_TESTS(); -- 2.7.4 From 53aa13bcf2d99537a12ab91ead6f628e292edf71 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Fri, 9 Feb 2018 11:24:29 +0900 Subject: [PATCH 13/16] Remove user data when ReadonlyUpdateUninstall mode Submit with: - https://review.tizen.org/gerrit/169698 Change-Id: Ia7c6f140e4d48e2d10de16c0bb25925d0b127dd1 Signed-off-by: Sangyoon Jang --- src/wgt/wgt_installer.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index 056c8b6..c4b8988 100755 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -590,6 +591,7 @@ void WgtInstaller::ReadonlyUpdateUninstallSteps() { AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep( ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE); -- 2.7.4 From dab87da27ad5a1a876444a3ff38ea07da5d18343 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Thu, 8 Mar 2018 15:03:36 +0900 Subject: [PATCH 14/16] Release version 0.9.5 Changes: - Add codes to enable ManifestDirectInstall for mount intalled pkg - Fix smoke test - Remove user data when ReadonlyUpdateUninstall mode Change-Id: I615e6db7f24d8e0c886865366b19675071508050 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 dce227b..59730c4 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.9.4 +Version: 0.9.5 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From 61253ab27c9ca904349107aa444d68ec4f101379 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Thu, 22 Mar 2018 17:06:20 +0900 Subject: [PATCH 15/16] Fix extensive smoke test Cast global environment object just once when allocating. Use static_cast for downcasting, because we know obviously that SmokeEnvironment class is derived from testing::Environment class. Change-Id: I89629f81453235f7dfc526a1e796bf7396cafe89 Signed-off-by: Sangyoon Jang --- src/unit_tests/extensive_smoke_test.cc | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/unit_tests/extensive_smoke_test.cc b/src/unit_tests/extensive_smoke_test.cc index ed51023..5c88971 100644 --- a/src/unit_tests/extensive_smoke_test.cc +++ b/src/unit_tests/extensive_smoke_test.cc @@ -50,26 +50,22 @@ class SmokeEnvironment : public testing::Environment { namespace { -testing::Environment *env = nullptr; +smoke_test::SmokeEnvironment *env = nullptr; void signalHandler(int signum) { env->TearDown(); exit(signum); } -smoke_test::SmokeEnvironment *dcast(testing::Environment* _env) { - return dynamic_cast(_env); -} - } // namespace namespace smoke_test { class SmokeTest : public testing::Test { public: - SmokeTest() : backend(std::to_string(dcast(env)->test_user.uid)), + SmokeTest() : backend(std::to_string(env->test_user.uid)), params{PackageType::WGT, false} { - params.test_user.uid = dcast(env)->test_user.uid; - params.test_user.gid = dcast(env)->test_user.gid; + params.test_user.uid = env->test_user.uid; + params.test_user.gid = env->test_user.gid; } protected: WgtBackendInterface backend; @@ -78,10 +74,10 @@ class SmokeTest : public testing::Test { class HybridSmokeTest : public testing::Test { public: - HybridSmokeTest() : backend(std::to_string(dcast(env)->test_user.uid)), + HybridSmokeTest() : backend(std::to_string(env->test_user.uid)), params{PackageType::HYBRID, false} { - params.test_user.uid = dcast(env)->test_user.uid; - params.test_user.gid = dcast(env)->test_user.gid; + params.test_user.uid = env->test_user.uid; + params.test_user.gid = env->test_user.gid; } protected: HybridBackendInterface backend; @@ -429,8 +425,9 @@ int main(int argc, char** argv) { ::testing::GTEST_FLAG(filter) = "SmokeTest.*"; } testing::InitGoogleTest(&argc, argv); - ::env = testing::AddGlobalTestEnvironment( - new smoke_test::SmokeEnvironment(request_mode)); + ::env = static_cast( + testing::AddGlobalTestEnvironment( + new smoke_test::SmokeEnvironment(request_mode))); signal(SIGINT, ::signalHandler); signal(SIGSEGV, ::signalHandler); return RUN_ALL_TESTS(); -- 2.7.4 From 80fb8bdc3b0d501411c263a19a609546711b9510 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Thu, 22 Mar 2018 15:52:28 +0900 Subject: [PATCH 16/16] Fix static analyzer issues - Fix memory leak - Fix using uninitialized variables - Fix dereferencing before null check Change-Id: I119e803a3e9acb9e63abc1f28c2fbd93f7e92699 Signed-off-by: Sangyoon Jang --- src/hybrid/step/pkgmgr/step_generate_xml.h | 2 ++ src/unit_tests/extensive_smoke_test.cc | 27 ++++++++++++++---------- src/wgt/step/configuration/step_parse.cc | 2 ++ src/wgt/step/encryption/step_encrypt_resources.h | 3 +++ src/wgt/step/filesystem/step_wgt_patch_icons.cc | 2 ++ 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/hybrid/step/pkgmgr/step_generate_xml.h b/src/hybrid/step/pkgmgr/step_generate_xml.h index b2a0f6e..8fce64d 100644 --- a/src/hybrid/step/pkgmgr/step_generate_xml.h +++ b/src/hybrid/step/pkgmgr/step_generate_xml.h @@ -19,6 +19,8 @@ namespace pkgmgr { class StepGenerateXml : public common_installer::Step { public: using Step::Step; + explicit StepGenerateXml(common_installer::InstallerContext* context) + : Step(context), wgt_doc_(nullptr), tpk_doc_(nullptr) {} Status process() override; Status clean() override { return Status::OK; } Status undo() override { return Status::OK; } diff --git a/src/unit_tests/extensive_smoke_test.cc b/src/unit_tests/extensive_smoke_test.cc index 5c88971..1f0a8ab 100644 --- a/src/unit_tests/extensive_smoke_test.cc +++ b/src/unit_tests/extensive_smoke_test.cc @@ -419,16 +419,21 @@ TEST_F(SmokeTest, MountUpdateMode_Rollback) { } // namespace smoke_test int main(int argc, char** argv) { - ci::RequestMode request_mode = smoke_test::ParseRequestMode(argc, argv); - if (getuid() != 0 || request_mode != ci::RequestMode::GLOBAL) { - std::cout << "Skip tests for preload request" << std::endl; - ::testing::GTEST_FLAG(filter) = "SmokeTest.*"; + try { + ci::RequestMode request_mode = smoke_test::ParseRequestMode(argc, argv); + if (getuid() != 0 || request_mode != ci::RequestMode::GLOBAL) { + std::cout << "Skip tests for preload request" << std::endl; + ::testing::GTEST_FLAG(filter) = "SmokeTest.*"; + } + testing::InitGoogleTest(&argc, argv); + ::env = static_cast( + testing::AddGlobalTestEnvironment( + new smoke_test::SmokeEnvironment(request_mode))); + signal(SIGINT, ::signalHandler); + signal(SIGSEGV, ::signalHandler); + return RUN_ALL_TESTS(); + } catch (...) { + std::cout << "Exception occurred during testing"; + return 1; } - testing::InitGoogleTest(&argc, argv); - ::env = static_cast( - testing::AddGlobalTestEnvironment( - new smoke_test::SmokeEnvironment(request_mode))); - signal(SIGINT, ::signalHandler); - signal(SIGSEGV, ::signalHandler); - return RUN_ALL_TESTS(); } diff --git a/src/wgt/step/configuration/step_parse.cc b/src/wgt/step/configuration/step_parse.cc index 4447368..1637c54 100644 --- a/src/wgt/step/configuration/step_parse.cc +++ b/src/wgt/step/configuration/step_parse.cc @@ -490,6 +490,7 @@ bool StepParse::FillServiceApplicationInfo(manifest_x* manifest) { calloc(1, sizeof(metadata_x))); if (!item) { LOG(ERROR) << "Out of memory"; + pkgmgrinfo_basic_free_application(application); return false; } item->key = strdup(pair.first.c_str()); @@ -943,6 +944,7 @@ common_installer::Step::Status StepParse::process() { if (!FillManifestX(manifest)) { LOG(ERROR) << "[Parse] Storing manifest_x failed. " << parser_->GetErrorMessage(); + pkgmgr_parser_free_manifest_xml(manifest); return common_installer::Step::Status::PARSE_ERROR; } diff --git a/src/wgt/step/encryption/step_encrypt_resources.h b/src/wgt/step/encryption/step_encrypt_resources.h index 27e4d02..6b420fd 100644 --- a/src/wgt/step/encryption/step_encrypt_resources.h +++ b/src/wgt/step/encryption/step_encrypt_resources.h @@ -22,6 +22,9 @@ class StepEncryptResources : public common_installer::Step { public: using Step::Step; + explicit StepEncryptResources(common_installer::InstallerContext* context) + : Step(context), backend_data_(nullptr) {} + /** * \brief Encrypt files * diff --git a/src/wgt/step/filesystem/step_wgt_patch_icons.cc b/src/wgt/step/filesystem/step_wgt_patch_icons.cc index e0a1be0..b80263a 100644 --- a/src/wgt/step/filesystem/step_wgt_patch_icons.cc +++ b/src/wgt/step/filesystem/step_wgt_patch_icons.cc @@ -18,6 +18,8 @@ namespace { const char kDefaultIconPath[] = "/usr/share/wgt-backend/default.png"; bool PatchIcon(icon_x* icon, const bf::path& dst_path) { + if (!icon) + return false; bs::error_code error; bf::path icon_text(icon->text); bf::path icon_path = dst_path; -- 2.7.4