Modify database backup sequence 12/275212/2
authorIlho Kim <ilho159.kim@samsung.com>
Wed, 18 May 2022 07:18:31 +0000 (16:18 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Wed, 18 May 2022 07:51:32 +0000 (16:51 +0900)
If there is a forced termination before erasing the backup flag
and applying the smack label, there is a problem of using the backup database
which the smack label is not applied in the next upgrade
so modify the smack label setting of the backup database
before removing the backup flag

Change-Id: I5201ef7b3c24e5f79abb32f030908a5d2e026c43
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
(cherry picked from commit 0f92e1fed086178170bbe809bb90c28427fff53e)

src/pkg_upgrade/src/upgrader.cc

index 63e9fcaa465f12446057e51a590b4496796db41f..49543d10d1817f03dd480ef119988e8107cc3cab 100644 (file)
@@ -117,6 +117,18 @@ bool Upgrader::Process(PkgFinder* finder) {
     return false;
   }
 
+  // set the database permission to solve the case of using the backup database
+  // which the smack label is not applied properly
+  if (SetDbPermission(parser_db_) != 0) {
+    LOG(ERROR) << "SetDbPermission at parser_db failed";
+    return -1;
+  }
+
+  if (SetDbPermission(cert_db_) != 0) {
+    LOG(ERROR) << "SetDbPermission at cert_db failed";
+    return -1;
+  }
+
   PkgUpgraderFactory factory;
   auto list = factory.MakeList(finder);
 
@@ -391,6 +403,9 @@ int Upgrader::BackupFile(const string& src_path, const string& dest_path) {
     return -1;
   }
 
+  if (SetDbPermission(dest_path) != 0)
+    return -1;
+
   RemoveBackupFlag(src_path);
 
   return 0;
@@ -400,9 +415,6 @@ int Upgrader::BackupDb(const string& src_path, const string& dest_path) {
   if (BackupFile(src_path, dest_path) != 0)
     return -1;
 
-  if (SetDbPermission(dest_path) != 0)
-    return -1;
-
   return 0;
 }