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_ */
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) {
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) {
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);
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;
+}