From: Junghyun Yeon Date: Mon, 15 Mar 2021 06:09:52 +0000 (+0900) Subject: Add convert uid logic X-Git-Tag: submit/tizen/20210317.082331~23 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e3dc2f91f6a7b09af141f976991391726d310ed9;p=platform%2Fcore%2Fappfw%2Fpkgmgr-info.git Add convert uid logic Signed-off-by: Junghyun Yeon --- diff --git a/src/common/database/abstract_db_handler.cc b/src/common/database/abstract_db_handler.cc index 505e140..e47e9b4 100644 --- a/src/common/database/abstract_db_handler.cc +++ b/src/common/database/abstract_db_handler.cc @@ -211,6 +211,13 @@ static int __open_write_db(uid_t uid, const char *path, sqlite3 **db, int flags) return ret; } +uid_t ConvertUID(uid_t uid) { + if (uid < REGULAR_USER) + return tzplatform_getuid(TZ_SYS_GLOBALAPP_USER); + else + return uid; +} + } // namespace namespace pkgmgr_common { @@ -251,7 +258,7 @@ bool AbstractDBHandler::Connect() { ret = __open_read_db(dbpath.first.c_str(), &db, SQLITE_OPEN_READONLY | SQLITE_OPEN_URI); } else { - if (dbpath.second != uid_) + if (ConvertUID(dbpath.second) != ConvertUID(uid_)) continue; ret = __open_write_db(uid_, dbpath.first.c_str(), &db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE);