summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMinje Ahn <minje.ahn@samsung.com>2017-01-25 16:25:57 +0900
committerMinje Ahn <minje.ahn@samsung.com>2017-01-26 08:42:06 +0900
commite4c7c363293cb16a6cae16680913e3111be7d564 (patch)
tree4cc33e95781738fab6da664d02248e482714439c /src
parent53b62578d0e07f3026d1ad7a994591ab1ab92889 (diff)
downloadlibmedia-thumbnail-e4c7c363293cb16a6cae16680913e3111be7d564.tar.gz
libmedia-thumbnail-e4c7c363293cb16a6cae16680913e3111be7d564.tar.bz2
libmedia-thumbnail-e4c7c363293cb16a6cae16680913e3111be7d564.zip
Update get_path functions
use tzplatform API instead of grp(pwd) API Change-Id: I1c3f79769304377b68c98a1a03ded53b02c21b42 Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
Diffstat (limited to 'src')
-rwxr-xr-xsrc/media-thumb-internal.c88
1 files changed, 20 insertions, 68 deletions
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 <Ecore_Evas.h>
#include <libexif/exif-data.h>
#include <sys/stat.h>
-#include <grp.h>
-#include <pwd.h>
#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,