Add convert uid logic
authorJunghyun Yeon <jungh.yeon@samsung.com>
Mon, 15 Mar 2021 06:09:52 +0000 (15:09 +0900)
committer연정현/Tizen Platform Lab(SR)/Staff Engineer/삼성전자 <jungh.yeon@samsung.com>
Mon, 15 Mar 2021 06:17:08 +0000 (15:17 +0900)
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/common/database/abstract_db_handler.cc

index 505e140..e47e9b4 100644 (file)
@@ -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);