summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinje Ahn <minje.ahn@samsung.com>2017-01-25 07:25:57 (GMT)
committerMinje Ahn <minje.ahn@samsung.com>2017-01-25 23:42:06 (GMT)
commite4c7c363293cb16a6cae16680913e3111be7d564 (patch)
tree4cc33e95781738fab6da664d02248e482714439c
parent53b62578d0e07f3026d1ad7a994591ab1ab92889 (diff)
downloadlibmedia-thumbnail-e4c7c363293cb16a6cae16680913e3111be7d564.zip
libmedia-thumbnail-e4c7c363293cb16a6cae16680913e3111be7d564.tar.gz
libmedia-thumbnail-e4c7c363293cb16a6cae16680913e3111be7d564.tar.bz2
Update get_path functionsrefs/changes/73/111973/3
use tzplatform API instead of grp(pwd) API Change-Id: I1c3f79769304377b68c98a1a03ded53b02c21b42 Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
-rw-r--r--packaging/libmedia-thumbnail.spec2
-rwxr-xr-xserver/thumb-server-internal.c2
-rwxr-xr-xsrc/media-thumb-internal.c88
3 files changed, 21 insertions, 71 deletions
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 <string.h>
#include <Ecore_Evas.h>
#include <vconf.h>
-#include <grp.h>
-#include <pwd.h>
#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 <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,