From: Minje Ahn Date: Wed, 25 Jan 2017 07:25:57 +0000 (+0900) Subject: Update get_path functions X-Git-Tag: accepted/tizen/common/20170316.161857~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F73%2F111973%2F3;p=platform%2Fcore%2Fmultimedia%2Flibmedia-thumbnail.git Update get_path functions use tzplatform API instead of grp(pwd) API Change-Id: I1c3f79769304377b68c98a1a03ded53b02c21b42 Signed-off-by: Minje Ahn --- diff --git a/packaging/libmedia-thumbnail.spec b/packaging/libmedia-thumbnail.spec index fad5e85..94bfca1 100644 --- a/packaging/libmedia-thumbnail.spec +++ b/packaging/libmedia-thumbnail.spec @@ -1,6 +1,6 @@ Name: libmedia-thumbnail Summary: Media thumbnail service library for multimedia applications -Version: 0.1.101 +Version: 0.1.102 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 and public domain diff --git a/server/thumb-server-internal.c b/server/thumb-server-internal.c index acecb5d..2e6bc8c 100755 --- a/server/thumb-server-internal.c +++ b/server/thumb-server-internal.c @@ -30,8 +30,6 @@ #include #include #include -#include -#include #ifdef LOG_TAG #undef LOG_TAG diff --git a/src/media-thumb-internal.c b/src/media-thumb-internal.c index dfa825b..1fd2614 100755 --- a/src/media-thumb-internal.c +++ b/src/media-thumb-internal.c @@ -44,8 +44,6 @@ #include #include #include -#include -#include #define MEDIA_THUMB_ROUND_UP_8(num) (((num)+7)&~7) /* performance enhanced to make thumbnail */ @@ -1573,83 +1571,37 @@ int _media_thumb_video(const char *origin_path, static char* _media_thumb_mmc_get_path(uid_t uid) { int ret = 0; - char *result_psswd = NULL; - struct group *grpinfo = NULL; - if (uid == getuid()) { - if (THUMB_MMC_PATH != NULL) - result_psswd = strndup(THUMB_MMC_PATH, strlen(THUMB_MMC_PATH)); - grpinfo = getgrnam("users"); - if (grpinfo == NULL) { - thumb_err("getgrnam(users) returns NULL !"); - if (result_psswd) - free(result_psswd); - return NULL; - } + char *result_path = NULL; + + ret = tzplatform_set_user(uid); + if (ret != 0) { + thumb_err("Invalid UID[%d]", uid); + return NULL; } else { - struct passwd *userinfo = getpwuid(uid); - if (userinfo == NULL) { - thumb_err("getpwuid(%d) returns NULL !", uid); - return NULL; - } - grpinfo = getgrnam("users"); - if (grpinfo == NULL) { - thumb_err("getgrnam(users) returns NULL !"); - return NULL; - } - // Compare git_t type and not group name - if (grpinfo->gr_gid != userinfo->pw_gid) { - thumb_err("UID [%d] does not belong to 'users' group!", uid); - return NULL; - } - ret = asprintf(&result_psswd, "%s/share/media/.thumb/mmc", userinfo->pw_dir); - if (ret == -1) { - thumb_err("asprintf failed"); - return NULL; - } + const char *result = tzplatform_mkpath(TZ_USER_SHARE, "media/.thumb/mmc"); + result_path = strndup(result, strlen(result)); + tzplatform_reset_user(); } - return result_psswd; + return result_path; } static char* _media_thumb_phone_get_path(uid_t uid) { int ret = 0; - char *result_psswd = NULL; - struct group *grpinfo = NULL; - if (uid == getuid()) { - if (THUMB_PHONE_PATH != NULL) - result_psswd = strndup(THUMB_PHONE_PATH, strlen(THUMB_PHONE_PATH)); - grpinfo = getgrnam("users"); - if (grpinfo == NULL) { - thumb_err("getgrnam(users) returns NULL !"); - if (result_psswd) - free(result_psswd); - return NULL; - } + char *result_path = NULL; + + ret = tzplatform_set_user(uid); + if (ret != 0) { + thumb_err("Invalid UID[%d]", uid); + return NULL; } else { - struct passwd *userinfo = getpwuid(uid); - if (userinfo == NULL) { - thumb_err("getpwuid(%d) returns NULL !", uid); - return NULL; - } - grpinfo = getgrnam("users"); - if (grpinfo == NULL) { - thumb_err("getgrnam(users) returns NULL !"); - return NULL; - } - // Compare git_t type and not group name - if (grpinfo->gr_gid != userinfo->pw_gid) { - thumb_err("UID [%d] does not belong to 'users' group!", uid); - return NULL; - } - ret = asprintf(&result_psswd, "%s/share/media/.thumb/phone", userinfo->pw_dir); - if (ret == -1) { - thumb_err("asprintf failed"); - return NULL; - } + const char *result = tzplatform_mkpath(TZ_USER_SHARE, "media/.thumb/phone"); + result_path = strndup(result, strlen(result)); + tzplatform_reset_user(); } - return result_psswd; + return result_path; } int _media_thumb_get_hash_name(const char *file_full_path,