Fix StepRemovePrivSharedres 76/265476/1
authorJunghyun Yeon <jungh.yeon@samsung.com>
Wed, 20 Oct 2021 08:43:38 +0000 (17:43 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Wed, 20 Oct 2021 08:43:38 +0000 (17:43 +0900)
Installer will tries to remove privileged sharedres directory itself
when installer unable to send request to server such as pkg recovery.

Change-Id: If3de55eb19e5e1db18f2313f506fb42a7aee8208
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/common/step/pkgmgr/step_remove_priv_sharedres.cc

index 503d335..dfa4383 100644 (file)
@@ -35,13 +35,13 @@ bool RemoveResForUid(const std::string& pkgid, uid_t uid) {
   return true;
 }
 
-bool SendUninstallRequest(const std::string& pkgid, uid_t uid) {
+int SendUninstallRequest(const std::string& pkgid, uid_t uid) {
   pkgmgr_client *pc = pkgmgr_client_new(PC_REQUEST);
 
   int ret = pkgmgr_client_res_usr_uninstall(pc, pkgid.c_str(), uid);
   pkgmgr_client_free(pc);
 
-  return (ret == PKGMGR_R_OK) ? true : false;
+  return ret;
 }
 
 }  // namespace
@@ -77,9 +77,14 @@ Step::Status StepRemovePrivSharedres::RequestRemove() {
     common_installer::UserList user_list = common_installer::GetUserList();
     for (auto l : user_list) {
       uid_t uid = std::get<0>(l);
-      if (!SendUninstallRequest(context_->pkgid.get(), uid)) {
-        LOG(ERROR) << "Failed to remove privileged shared resources";
-        return Status::ERROR;
+      int ret = SendUninstallRequest(context_->pkgid.get(), uid);
+      if (ret == PKGMGR_R_OK) {
+        return Status::OK;
+      } else if (ret == PKGMGR_R_ECOMM) {
+          return OfflineRemove();
+      } else {
+          LOG(ERROR) << "Failed to remove privileged shared resources";
+          return Status::ERROR;
       }
     }
   } else {