From ab806950b0e1b738863038b5ed90be323f8e4230 Mon Sep 17 00:00:00 2001 From: jongmyeongko Date: Fri, 9 Dec 2016 01:38:16 +0900 Subject: [PATCH] consideration about legacy media path. if caller uid is regular user, then check and convert legacy path. Change-Id: I22d4ead49a6b599b08a2cdea6f6b590fe6319b97 Signed-off-by: jongmyeongko --- include/pkgmgr-server.h | 4 +++- src/request.c | 5 ++--- src/util.c | 17 ++++++++++++++++- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/include/pkgmgr-server.h b/include/pkgmgr-server.h index 210a8a4..530ca0d 100644 --- a/include/pkgmgr-server.h +++ b/include/pkgmgr-server.h @@ -52,6 +52,8 @@ #define MAX_PKG_ARGS_LEN 4096 #define DESKTOP_FILE_DIRS_NUM 1024 +#define REGULAR_USER 5000 + enum request_type { REQUEST_TYPE_INSTALL, REQUEST_TYPE_MOUNT_INSTALL, @@ -91,7 +93,7 @@ void _send_fail_signal(struct backend_job *job); int _set_restriction_mode(uid_t uid, const char *pkgid, int mode); int _unset_restriction_mode(uid_t uid, const char *pkgid, int mode); int _get_restriction_mode(uid_t uid, const char *pkgid, int *mode); -const char *_get_pkgtype_from_file(const char *file_path); +const char *_get_pkgtype_from_file(const char *file_path, uid_t uid); char *_get_pkgtype_from_pkgid(const char *pkgid, uid_t uid); #endif/* _PKGMGR_SERVER_H_ */ diff --git a/src/request.c b/src/request.c index 7fb6e20..c03f602 100644 --- a/src/request.c +++ b/src/request.c @@ -235,7 +235,6 @@ static int __is_admin_user(uid_t uid) return 1; } -#define REGULAR_USER 5000 static int __check_caller_permission(uid_t uid, GDBusMethodInvocation *invocation, GVariant *parameters) { @@ -321,7 +320,7 @@ static int __handle_request_install(uid_t caller_uid, goto catch; } - pkgtype = _get_pkgtype_from_file(pkgpath); + pkgtype = _get_pkgtype_from_file(pkgpath, caller_uid); if (!pkgtype && arg_pkgtype && strlen(arg_pkgtype)) pkgtype = (const char *)arg_pkgtype; if (pkgtype == NULL) { @@ -410,7 +409,7 @@ static int __handle_request_mount_install(uid_t caller_uid, goto catch; } - pkgtype = _get_pkgtype_from_file(pkgpath); + pkgtype = _get_pkgtype_from_file(pkgpath, caller_uid); if (!pkgtype && arg_pkgtype && strlen(arg_pkgtype)) pkgtype = (const char *)arg_pkgtype; if (pkgtype == NULL) { diff --git a/src/util.c b/src/util.c index 6a1b7b9..d64ccb7 100644 --- a/src/util.c +++ b/src/util.c @@ -3,6 +3,7 @@ #include +#include #include #include "pkgmgr-server.h" @@ -19,12 +20,26 @@ struct manifest_and_type type_map[] = { { NULL, NULL } }; -const char *_get_pkgtype_from_file(const char *file_path) +static const char legacy_content_path[] = "/opt/usr/media"; + +const char *_get_pkgtype_from_file(const char *org_file_path, uid_t caller_uid) { const char *type = NULL; + const char *file_path = NULL; unzFile uf; int i; + if (caller_uid >= REGULAR_USER && + strstr(org_file_path, legacy_content_path) == org_file_path) { + DBG("legacy media path!"); + tzplatform_set_user(caller_uid); + file_path = tzplatform_mkpath(TZ_USER_CONTENT, + org_file_path + strlen(legacy_content_path)); + tzplatform_reset_user(); + } else { + file_path = org_file_path; + } + uf = unzOpen(file_path); if (uf == NULL) { ERR("failed to open zip file %s", file_path); -- 2.7.4