diff options
-rw-r--r-- | include/pkgmgr-server.h | 3 | ||||
-rw-r--r-- | src/request.c | 6 | ||||
-rw-r--r-- | src/util.c | 32 |
3 files changed, 25 insertions, 16 deletions
diff --git a/include/pkgmgr-server.h b/include/pkgmgr-server.h index e22bfeb..0180fcb 100644 --- a/include/pkgmgr-server.h +++ b/include/pkgmgr-server.h @@ -94,7 +94,8 @@ 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, uid_t uid); +const char *_get_pkgtype_from_file(const char *file_path); char *_get_pkgtype_from_pkgid(const char *pkgid, uid_t uid); +const char *_get_adjusted_pkgpath(const char *org_file_path, uid_t caller_uid); #endif/* _PKGMGR_SERVER_H_ */ diff --git a/src/request.c b/src/request.c index fce8210..2e4fbc1 100644 --- a/src/request.c +++ b/src/request.c @@ -327,7 +327,8 @@ static int __handle_request_install(uid_t caller_uid, goto catch; } - pkgtype = _get_pkgtype_from_file(pkgpath, caller_uid); + pkgpath = _get_adjusted_pkgpath(pkgpath, caller_uid); + pkgtype = _get_pkgtype_from_file(pkgpath); if (!pkgtype && arg_pkgtype && strlen(arg_pkgtype)) pkgtype = (const char *)arg_pkgtype; if (pkgtype == NULL) { @@ -416,7 +417,8 @@ static int __handle_request_mount_install(uid_t caller_uid, goto catch; } - pkgtype = _get_pkgtype_from_file(pkgpath, caller_uid); + pkgpath = _get_adjusted_pkgpath(pkgpath, caller_uid); + pkgtype = _get_pkgtype_from_file(pkgpath); if (!pkgtype && arg_pkgtype && strlen(arg_pkgtype)) pkgtype = (const char *)arg_pkgtype; if (pkgtype == NULL) { @@ -22,24 +22,12 @@ struct manifest_and_type type_map[] = { 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 *_get_pkgtype_from_file(const char *file_path) { 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); @@ -83,3 +71,21 @@ char *_get_pkgtype_from_pkgid(const char *pkgid, uid_t uid) return type; } + +const char *_get_adjusted_pkgpath(const char *org_file_path, uid_t caller_uid) +{ + const char *file_path; + + 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; + } + + return file_path; +} |