Change permission of pkgmgr db files 05/116805/1
authorJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 28 Feb 2017 09:22:25 +0000 (18:22 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 28 Feb 2017 09:22:25 +0000 (18:22 +0900)
- Change permission of pkgmgr db files to app_fw:app_fw

Change-Id: Ie41683c8b153d9c1f5f87eab9da5092d56604dd8
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
parser/src/pkgmgr_parser_db.c

index 582f40f..d5c516c 100644 (file)
@@ -50,6 +50,7 @@
 #define MAX_QUERY_LEN          4096
 #define BUFSIZE 4096
 #define OWNER_ROOT 0
+#define APPFW_USER "app_fw"
 #define MAX_INTEGER_LENGTH 10
 
 #define LDPI "ldpi"
@@ -2411,8 +2412,13 @@ static int __parserdb_change_perm(const char *db_file, uid_t uid)
        if (getuid() != OWNER_ROOT) /* At this time we should be root to apply this */
                return 0;
        snprintf(journal_file, sizeof(journal_file), "%s%s", db_file, "-journal");
-       if (uid == OWNER_ROOT)
-               uid = GLOBAL_USER;
+       if (uid == OWNER_ROOT || uid == GLOBAL_USER) {
+               ret = getpwnam_r(APPFW_USER, &userinfo, buf, sizeof(buf), &result);
+               if (ret != 0 || result == NULL)
+                       return -1;
+               uid = userinfo.pw_uid;
+       }
+
        ret = getpwuid_r(uid, &userinfo, pwuid_buf, sizeof(pwuid_buf), &result);
        if (ret != 0 || result == NULL) {
                _LOGE("FAIL: user %d doesn't exist", uid);