Remove external RW dir creation logic 65/310865/1 tizen
authorSangyoon Jang <jeremy.jang@samsung.com>
Thu, 9 May 2024 05:40:40 +0000 (14:40 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Thu, 9 May 2024 05:42:42 +0000 (14:42 +0900)
External RW dir is no longer used.

Change-Id: I3b476c9d04a24f9b99ae28d47110d40f701a0d23
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
packaging/app-installers.spec
src/common/installer/app_installer.cc
src/common/step/security/step_check_old_certificate.cc
src/common/step/security/step_check_old_certificate.h
src/pkgdir_tool/pkgdir_tool.cc

index f925a4d..68c3da6 100644 (file)
@@ -1,6 +1,6 @@
 Name:           app-installers
 Summary:        Application installers
-Version:        1.34.48
+Version:        1.34.49
 Release:        1
 Group:          Application Framework/Package Management
 License:        Apache-2.0
index 2eaa429..054dc35 100644 (file)
@@ -738,7 +738,9 @@ void AppInstaller::ReadonlyUpdateInstallSteps() {
   AddStep<ci::configuration::StepParsePreload>();
   AddStep<ci::configuration::StepCheckTizenVersion>();
   AddStep<ci::security::StepSignature>(true);
+  AddStep<ci::configuration::StepSwitchReadonlyMode>();
   AddStep<ci::security::StepCheckOldCertificate>();
+  AddStep<ci::configuration::StepSwitchReadonlyMode>();
   AddStep<ci::configuration::StepBlockCrossUpdate>();
   AddStep<ci::pkgmgr::StepKillApps>();
   AddStep<ci::security::StepRevokeTrustAnchor>();
index 81ed7be..66ca04a 100644 (file)
 namespace common_installer {
 namespace security {
 
+std::string StepCheckOldCertificate::GetOldAuthorCertFromFile() {
+  CertificateInfo cert_info;
+  std::string error_message;
+  PrivilegeLevel level = PrivilegeLevel::UNTRUSTED;
+  if (!ValidateSignatures(context_->GetPkgPath() / root_extra_path_, &level,
+                        &cert_info, false,
+                        &error_message)) {
+    LOG(ERROR) << "Failed to verify signature: " << error_message;
+    return {};
+  } else if (cert_info.auth_cert.get()) {
+    return cert_info.auth_cert.get()->getBase64();
+  }
+
+  return {};
+}
+
 Step::Status StepCheckOldCertificate::process() {
   std::string old_author_cert =
       QueryCertificateAuthorCertificate(context_->pkgid.get(),
                                         context_->uid.get());
   const auto& cert = context_->certificate_info.get().auth_cert.get();
+  if (old_author_cert.empty() && cert)
+    old_author_cert = GetOldAuthorCertFromFile();
 
   if (!old_author_cert.empty()) {
     if (!cert) {
index 1cbb72a..4ebb9d9 100644 (file)
@@ -21,6 +21,10 @@ class StepCheckOldCertificate : public Step {
  public:
   using Step::Step;
 
+  explicit StepCheckOldCertificate(InstallerContext* context,
+      const std::string& root_extra_path = "")
+          : Step(context), root_extra_path_(root_extra_path) {}
+
   /**
    * \brief main checking/comparing logic.
    *
@@ -31,6 +35,11 @@ class StepCheckOldCertificate : public Step {
   Status clean() override { return Status::OK; }
   Status precheck() override { return Status::OK; }
 
+ private:
+  std::string GetOldAuthorCertFromFile();
+
+  std::string root_extra_path_;
+
   STEP_NAME(CheckOldCertificate)
 };
 
index 0a2db04..c695d16 100644 (file)
@@ -118,14 +118,17 @@ void PkgdirToolService::HandleMethodCall(GDBusConnection* connection,
   UNUSED(interface_name);
   UNUSED(parameters);
   UNUSED(user_data);
-  bool r = false;
+  bool r = true;
 
   LOG(INFO) << "Incomming method call: " << method_name;
+// TODO: external rw directory is no longer used. pkgdir_tool will be removed.
+#if 0
   if (g_strcmp0(method_name, "CreateExternalDirsForAllPkgs") == 0) {
     r = ci::PerformExternalDirectoryCreationForAllPkgs();
   } else {
     LOG(ERROR) << "Unknown method call: " << method_name;
   }
+#endif
   g_dbus_method_invocation_return_value(invocation, g_variant_new("(b)", r));
 
   RenewTimeout(5000);