From: Ilho Kim Date: Wed, 18 May 2022 08:29:34 +0000 (+0900) Subject: Modify database backup sequence X-Git-Tag: submit/tizen_5.5/20220519.064647~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bd314f8a40daee6ecee815ce66bd193d8ed903bf;p=platform%2Fcore%2Fappfw%2Fpkgmgr-tool.git 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 (cherry picked from commit f6700a0517f044ebc4e2ef70026f3272aa1f145f) --- diff --git a/src/pkg_upgrade.c b/src/pkg_upgrade.c index b5f0e42..255ba9a 100644 --- a/src/pkg_upgrade.c +++ b/src/pkg_upgrade.c @@ -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) {