Fix StepSaveSignature 93/174993/1
authorJunghyun Yeon <jungh.yeon@samsung.com>
Fri, 6 Apr 2018 00:27:30 +0000 (09:27 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Fri, 6 Apr 2018 00:27:30 +0000 (09:27 +0900)
- Remove duplicated code about removing dist signatures.
- dist signatures will not be extracted during mount install or update.

Change-Id: I08272080a7202afcd05c69dbb9acc278b5231187
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/common/step/security/step_save_signature.cc

index e1964ed..2430ed5 100644 (file)
@@ -104,32 +104,14 @@ Step::Status StepSaveSignature::process() {
     return Step::Status::APP_DIR_ERROR;
   ofs.close();
 
+  // dist signatures cannot be removed when mount install/update
+  if (context_->request_type.get() == RequestType::MountInstall ||
+      context_->request_type.get() == RequestType::MountUpdate)
+    return Step::Status::OK;
+
   if (!RemoveSignature(context_->unpacked_dir_path.get()))
     return Step::Status::APP_DIR_ERROR;
 
-  for (bf::directory_iterator file(context_->unpacked_dir_path.get());
-      file != bf::directory_iterator();
-      ++file) {
-    try {
-      bf::path file_path(file->path());
-
-      if (bf::is_symlink(symlink_status(file_path)) ||
-          bf::is_directory(file_path))
-        continue;
-
-      std::regex distributor_regex("^(signature)([1-9][0-9]*)(\\.xml)");
-      if (std::regex_search(file_path.filename().string(), distributor_regex)) {
-        if (!Remove(file_path)) {
-          LOG(ERROR) << "Failed to remove signature file";
-          return Step::Status::APP_DIR_ERROR;
-        }
-      }
-    } catch (const bf::filesystem_error& error) {
-      LOG(ERROR) << "Failed to remove signature files: " << error.what();
-      return Step::Status::APP_DIR_ERROR;
-    }
-  }
-
   sync();
   return Step::Status::OK;
 }