Fix StepPrivacyPrivilege's undo 33/315333/3
authorIlho Kim <ilho159.kim@samsung.com>
Fri, 1 Dec 2023 10:59:10 +0000 (19:59 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Mon, 2 Dec 2024 03:54:35 +0000 (12:54 +0900)
If the action type is uninstall
the privacy privilege is not recovered in undo

Change-Id: Ic594d2e086c0d35a9320f1a5fb2666ea04b90772
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
src/common/step/security/step_privacy_privilege.cc

index eb460efea649496d42ea6806f6ee83297fdf2ef1..69a0c2d8067a12e1c02795e48ab81d6c2014945c 100644 (file)
@@ -117,9 +117,6 @@ Step::Status StepPrivacyPrivilege::process() {
 }
 
 Step::Status StepPrivacyPrivilege::undo() {
-  if (type_ == ActionType::Uninstall)
-    return Step::Status::OK;
-
   int ret = privilege_package_info_unset_package_privilege_info(
       context_->uid.get(), context_->pkgid.get().c_str());
   if (ret != PRVMGR_ERR_NONE) {
@@ -127,12 +124,14 @@ Step::Status StepPrivacyPrivilege::undo() {
     return Status::SECURITY_ERROR;
   }
 
-  if (context_->old_manifest_data.get()) {
-    manifest_x* old_manifest = context_->old_manifest_data.get();
+  manifest_x* manifest = type_ == ActionType::Uninstall ?
+      context_->manifest_data.get() : context_->old_manifest_data.get();
+
+  if (manifest) {
     if (!SetPrivacyPrivilege(context_->uid.get(),
                              context_->pkgid.get().c_str(),
-                             old_manifest,
-                             old_manifest->privileges)) {
+                             manifest,
+                             manifest->privileges)) {
       LOG(ERROR) << "Failed undo privacy privilege";
       return Step::Status::SECURITY_ERROR;
     }