Remove unnecessary function 99/181599/3
authorJunghyun Yeon <jungh.yeon@samsung.com>
Fri, 15 Jun 2018 04:42:04 +0000 (13:42 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Fri, 15 Jun 2018 05:10:20 +0000 (14:10 +0900)
- Certificate database is integrated into one so functions to get
  individual certificate db path is unnecessary.
- Initializing user parser db will not initialize integrated cert db.

Change-Id: I1864e3e370a2b268a0dd66cbcd90277de3c1605e
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
include/pkgmgr-info.h
parser/src/pkgmgr_parser_db.c
src/pkgmgrinfo_certinfo.c
src/pkgmgrinfo_db.c

index 71247de..9be5008 100644 (file)
@@ -181,7 +181,6 @@ const char *getIconPath(uid_t uid, bool readonly);
 char *getUserPkgParserDBPath(void);
 char *getUserPkgParserDBPathUID(uid_t uid);
 char *getUserPkgCertDBPath(void);
-char *getUserPkgCertDBPathUID(uid_t uid);
 const char *getUserManifestPath(uid_t uid, bool readonly);
 
 /**
index a5f992d..4346cc2 100644 (file)
@@ -453,8 +453,9 @@ API int pkgmgr_parser_create_and_initialize_db(uid_t uid)
        if (pkgmgr_parser_initialize_parser_db(uid))
                return PM_PARSER_R_ERROR;
 
-       if (pkgmgr_parser_initialize_cert_db())
-               return PM_PARSER_R_ERROR;
+       if (uid == OWNER_ROOT || uid == GLOBAL_USER)
+               if (pkgmgr_parser_initialize_cert_db())
+                       return PM_PARSER_R_ERROR;
 
        return PM_PARSER_R_OK;
 }
index f867c61..a524794 100644 (file)
@@ -125,7 +125,7 @@ API int pkgmgrinfo_pkginfo_compare_usr_pkg_cert_info(const char *lhs_package_id,
        }
 
        /* open unified global cert db */
-       dbpath = getUserPkgCertDBPathUID(GLOBAL_USER);
+       dbpath = getUserPkgCertDBPath();
        if (dbpath == NULL)
                return PMINFO_R_ERROR;
 
@@ -363,7 +363,7 @@ static int _pkginfo_get_certinfo(const char *pkgid, pkgmgr_certinfo_x *info)
        char *dbpath;
 
        /* open unified global cert db */
-       dbpath = getUserPkgCertDBPathUID(GLOBAL_USER);
+       dbpath = getUserPkgCertDBPath();
        if (dbpath == NULL)
                return PMINFO_R_ERROR;
 
@@ -620,7 +620,7 @@ API int pkgmgrinfo_save_certinfo(const char *pkgid, pkgmgrinfo_instcertinfo_h ha
        _check_create_cert_db();
 
        /* open unified global cert db */
-       dbpath = getUserPkgCertDBPathUID(GLOBAL_USER);
+       dbpath = getUserPkgCertDBPath();
        if (dbpath == NULL)
                return PMINFO_R_ERROR;
 
@@ -731,7 +731,7 @@ API int pkgmgrinfo_delete_usr_certinfo(const char *pkgid, uid_t uid)
        }
 
        /* open unified global cert db */
-       dbpath = getUserPkgCertDBPathUID(GLOBAL_USER);
+       dbpath = getUserPkgCertDBPath();
        if (dbpath == NULL)
                return PMINFO_R_ERROR;
 
index e382bf5..54492f4 100644 (file)
@@ -191,34 +191,12 @@ API char *getUserPkgParserDBPathUID(uid_t uid)
 
 API char *getUserPkgCertDBPath(void)
 {
-        return getUserPkgCertDBPathUID(_getuid());
-}
-
-API char *getUserPkgCertDBPathUID(uid_t uid)
-{
-       char pkgmgr_cert_db[PATH_MAX];
-       uid_t uid_caller = getuid();
-       gid_t gid = ROOT_UID;
        char *db_path;
+       char pkgmgr_cert_db[PATH_MAX];
 
-       db_path = _get_db_path(uid);
-       if (db_path == NULL) {
-               _LOGE("Failed to get db path %d", uid);
-               return NULL;
-       }
+       db_path = _get_db_path(GLOBAL_USER);
        snprintf(pkgmgr_cert_db, sizeof(pkgmgr_cert_db),
                        "%s/.pkgmgr_cert.db", db_path);
-
-       if (uid != GLOBAL_USER && uid != ROOT_UID) {
-               tzplatform_set_user(uid);
-               gid = _get_gid(tzplatform_getenv(TZ_SYS_USER_GROUP));
-               tzplatform_reset_user();
-       }
-
-       /* just allow certain users to create the dbspace directory if needed. */
-       if (uid_caller == ROOT_UID || uid_caller == APPFW_UID || uid_caller == uid)
-               _mkdir_for_user(db_path, uid, gid);
-
        free(db_path);
 
        return strdup(pkgmgr_cert_db);