Fix StepUpdateSecurity 46/321546/1
authorSangyoon Jang <jeremy.jang@samsung.com>
Tue, 25 Mar 2025 05:04:37 +0000 (14:04 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Tue, 25 Mar 2025 05:04:37 +0000 (14:04 +0900)
Use old_manifest_data when undo().

Change-Id: I295fe1b087dedf559ae17d28b968142107476e15
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
src/common/security_registration.cc
src/common/security_registration.h
src/common/step/security/step_update_security.cc

index 3a526e7baba7a7d1d49d18be38c6ac95567e19af..c7796f0fb8eb2d4a4f05ff55d8d9913141390170 100644 (file)
@@ -421,13 +421,15 @@ void PrepareAppDefinedPrivilegeData(GList *privileges,
 }
 
 bool RegisterSecurityContextForManifest(const ci::InstallerContext* context,
-    std::string* error_message) {
+    std::string* error_message, bool is_undo) {
   std::string pkg_id = context->pkgid.get();
   std::string pkg_type = context->pkg_type.get();
   fs::path path = context->GetPkgPath();
   uid_t uid = context->uid.get();
   const ci::CertificateInfo* cert_info = &(context->certificate_info.get());
-  manifest_x* manifest = context->manifest_data.get();
+  manifest_x* manifest = is_undo ?
+      context->old_manifest_data.get() :
+      context->manifest_data.get();
   bool cross_app_rules = context->cross_app_rules.get();
 
   // Although application framework hold list of privilege per package, there
index c0af6849b3c328c8ae253a46a6074e34b0c9e1d8..e40364a063dc30308ac6eb3582b97ca190037463 100644 (file)
@@ -23,12 +23,14 @@ namespace common_installer {
  *
  * \param context installer context contains necessary information
  * \param error_message extra/detailed error message
+ * \param undo optional, default set to false, indicate if operation is undo
  *
  * \return true if success
  */
 bool RegisterSecurityContextForManifest(
         const common_installer::InstallerContext* context,
-        std::string* error_message);
+        std::string* error_message,
+        bool is_undo = false);
 
 /**
  * Adapter interface for external Security module.
index 6ccf10937a6038169d37887ef2f40e11b9a296d4..92ca13913a297c9c99783b831b68f4090081a7aa 100644 (file)
@@ -39,7 +39,7 @@ Step::Status StepUpdateSecurity::process() {
 
 Step::Status StepUpdateSecurity::undo() {
   std::string error_message;
-  if (!RegisterSecurityContextForManifest(context_, &error_message)) {
+  if (!RegisterSecurityContextForManifest(context_, &error_message), true) {
     if (!error_message.empty()) {
       LOG(ERROR) << "error_message: " << error_message;
     }