From 10887fd64f75c5eb086a301d6c84ad930e7caab7 Mon Sep 17 00:00:00 2001 From: Yong Yeon Kim Date: Fri, 4 Nov 2016 10:52:49 +0900 Subject: [PATCH] remove duplicated code Change-Id: Iddd4f366a20ef79f967773cf6f08616579dbea55 --- lib/media-util-db.c | 40 ++++++++-------------------------------- packaging/media-server.spec | 2 +- 2 files changed, 9 insertions(+), 33 deletions(-) diff --git a/lib/media-util-db.c b/lib/media-util-db.c index 54b2711..863d2d4 100755 --- a/lib/media-util-db.c +++ b/lib/media-util-db.c @@ -813,40 +813,16 @@ RETRY: int media_db_get_media_db_path(uid_t uid, char **db_path) { - int len = 0; - struct group *grpinfo = NULL; - + int ret = MS_MEDIA_ERR_NONE; *db_path = NULL; - if (uid == getuid()) { - grpinfo = getgrnam("users"); - if (grpinfo == NULL) { - MSAPI_DBG_ERR("getgrnam(users) returns NULL !"); - return MS_MEDIA_ERR_DB_INTERNAL; - } - if (MS_STRING_VALID(MEDIA_DB_NAME)) - *db_path = strdup(MEDIA_DB_NAME); - } else { - char passwd_str[MAX_FILEPATH_LEN] = {0, }; - struct passwd *userinfo = getpwuid(uid); - if (userinfo == NULL) { - MSAPI_DBG_ERR("getpwuid(%d) returns NULL !", uid); - return MS_MEDIA_ERR_DB_INTERNAL; - } - grpinfo = getgrnam("users"); - if (grpinfo == NULL) { - MSAPI_DBG_ERR("getgrnam(users) returns NULL !"); - return MS_MEDIA_ERR_DB_INTERNAL; - } - // Compare git_t type and not group name - if (grpinfo->gr_gid != userinfo->pw_gid) { - MSAPI_DBG_ERR("UID [%d] does not belong to 'users' group!", uid); - return MS_MEDIA_ERR_DB_INTERNAL; - } - len = snprintf(passwd_str, sizeof(passwd_str), "%s/.applications/dbspace/.media.db", userinfo->pw_dir); - if (len > 0) - *db_path = strndup(passwd_str, len); + *db_path = __media_get_media_DB(uid); + if (*db_path == NULL) { + MSAPI_DBG_ERR("__media_get_media_DB failed", uid); + ret = MS_MEDIA_ERR_INTERNAL; } - return MS_MEDIA_ERR_NONE; +// MSAPI_DBG("DB PATH[%s]", *db_path); + + return ret; } diff --git a/packaging/media-server.spec b/packaging/media-server.spec index 794c5b3..3b0e04f 100755 --- a/packaging/media-server.spec +++ b/packaging/media-server.spec @@ -1,6 +1,6 @@ Name: media-server Summary: A server for media content management -Version: 0.3.8 +Version: 0.3.9 Release: 0 Group: Multimedia/Service License: Apache-2.0 -- 2.7.4