consideration about legacy media path. 61/103561/2 accepted/tizen/3.0/common/20161212.060358 accepted/tizen/3.0/ivi/20161212.022756 accepted/tizen/3.0/mobile/20161212.022542 accepted/tizen/3.0/tv/20161212.022653 accepted/tizen/3.0/wearable/20161212.022725 submit/tizen_3.0/20161209.072525
authorjongmyeongko <jongmyeong.ko@samsung.com>
Thu, 8 Dec 2016 16:38:16 +0000 (01:38 +0900)
committerjongmyeongko <jongmyeong.ko@samsung.com>
Fri, 9 Dec 2016 07:16:27 +0000 (16:16 +0900)
if caller uid is regular user, then check and convert legacy path.

Change-Id: I22d4ead49a6b599b08a2cdea6f6b590fe6319b97
Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
include/pkgmgr-server.h
src/request.c
src/util.c

index 210a8a4..530ca0d 100644 (file)
@@ -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_ */
index 7fb6e20..c03f602 100644 (file)
@@ -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) {
index 6a1b7b9..d64ccb7 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <unzip.h>
 
+#include <tzplatform_config.h>
 #include <pkgmgr-info.h>
 
 #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);