Modify database backup sequence 37/275237/1
authorIlho Kim <ilho159.kim@samsung.com>
Wed, 18 May 2022 08:29:34 +0000 (17:29 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Wed, 18 May 2022 08:37:39 +0000 (17:37 +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: I4742e469fdaf9de35f2d3e266fd8a806c498975a
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
(cherry picked from commit f6700a0517f044ebc4e2ef70026f3272aa1f145f)

src/pkg_upgrade.c

index b5f0e422a006fdfc9307e11a3e8a516c1cd7d4dd..255ba9a4d67bdd02971b092141e2488251ec77fd 100644 (file)
@@ -1802,6 +1802,10 @@ static int __backup_file(const char *src_path, const char *dest_path)
 
        sqlite3_close_v2(src_db);
        sqlite3_close_v2(dest_db);
+
+       if (__set_db_permission(dest_path) != 0)
+               return -1;
+
        __remove_backup_flag(src_path);
 
        return 0;
@@ -1812,9 +1816,6 @@ static int __backup_db(const char *src_path, const char *dest_path)
        if (__backup_file(src_path, dest_path) != 0)
                return -1;
 
-       if (__set_db_permission(dest_path) != 0)
-               return -1;
-
        return 0;
 }
 
@@ -1859,6 +1860,18 @@ int main(int argc, char *argv[])
                return -1;
        }
 
+  // set the database permission to solve the case of using the backup database
+  // which the smack label is not applied properly
+       if (__set_db_permission(DBPATH) != 0) {
+               _LOGE("set db permissison at parser db failed\n");
+               return -1;
+       }
+
+       if (__set_db_permission(CERT_DBPATH) != 0) {
+               _LOGE("set db permissison at cert db failed\n");
+               return -1;
+       }
+
        /* check pkgmgr-fota dir, if it is not, then exit */
        ret = __check_pkgmgr_fota_dir();
        if (ret < 0) {