From f6700a0517f044ebc4e2ef70026f3272aa1f145f Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Wed, 18 May 2022 17:29:34 +0900 Subject: [PATCH] Modify database backup sequence 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 --- src/pkg_upgrade/pkg_upgrade.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/pkg_upgrade/pkg_upgrade.c b/src/pkg_upgrade/pkg_upgrade.c index 6d86cbd..72c7a61 100644 --- a/src/pkg_upgrade/pkg_upgrade.c +++ b/src/pkg_upgrade/pkg_upgrade.c @@ -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) { -- 2.34.1