if caller uid is regular user, then check and convert legacy path.
Change-Id: I22d4ead49a6b599b08a2cdea6f6b590fe6319b97
Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
#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,
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_ */
return 1;
}
-#define REGULAR_USER 5000
static int __check_caller_permission(uid_t uid,
GDBusMethodInvocation *invocation, GVariant *parameters)
{
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) {
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) {
#include <unzip.h>
+#include <tzplatform_config.h>
#include <pkgmgr-info.h>
#include "pkgmgr-server.h"
{ 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);