Modify database backup sequence 15/275215/2
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:31:16 +0000 (17:31 +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>
src/pkg_upgrade/pkg_upgrade.c

index 6d86cbd288373ef309cad42970f05839138717f1..72c7a61d919b2b866a5bd70d083d14ddbf42d014 100644 (file)
@@ -1834,6 +1834,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;
@@ -1844,9 +1848,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;
 }
 
@@ -1891,6 +1892,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) {