[0.2.49] fix error of internal path checking 28/125228/1 accepted/tizen/3.0/common/20170508.153025 accepted/tizen/3.0/ivi/20170508.050145 accepted/tizen/3.0/mobile/20170508.050028 accepted/tizen/3.0/tv/20170508.050055 accepted/tizen/3.0/wearable/20170508.050117 submit/tizen_3.0-common/20170508.080135 submit/tizen_3.0-common/20170508.081301 submit/tizen_3.0-common/20170508.091535 submit/tizen_3.0/20170417.044315 submit/tizen_3.0_common/20170508.091735
authorEunhae Choi <eunhae1.choi@samsung.com>
Fri, 14 Apr 2017 07:40:04 +0000 (16:40 +0900)
committerEunhae Choi <eunhae1.choi@samsung.com>
Fri, 14 Apr 2017 07:40:04 +0000 (16:40 +0900)
Change-Id: I75e7fe14c382535d6ebc194253bcd55ad44dfd5b

muse/src/muse_player.c
packaging/mmsvc-player.spec

index ecc34e5..7cfe8bc 100644 (file)
@@ -346,12 +346,32 @@ static int _check_supportable(muse_module_h module, char *path)
                        privilege = INTERNET_PRIVILEGE_NAME;
 
                if (!privilege) {
-                       if (strncmp(file_path, MEDIA_PATH_EXTERNAL, strlen(MEDIA_PATH_EXTERNAL)) == 0)
+                       if (strncmp(file_path, MEDIA_PATH_EXTERNAL, strlen(MEDIA_PATH_EXTERNAL)) == 0) { /* external media storage */
                                privilege = EXTERNAL_STORAGE_PRIVILEGE_NAME;
-                       else if (strncmp(file_path, MEDIA_PATH_USER, strlen(MEDIA_PATH_USER)) == 0)
-                               privilege = MEDIA_STORAGE_PRIVILEGE_NAME;
-                       else
-                               return PLAYER_ERROR_NONE;
+                       } else {
+                               char *internal_path = NULL;
+                               struct ucred cred;
+                               socklen_t len = sizeof(cred);
+                               if (getsockopt(client_fd, SOL_SOCKET, SO_PEERCRED, &cred, &len) < 0) {
+                                       LOGE("failed to get peer client uid of socketfd %d", client_fd);
+                                       return PLAYER_ERROR_INVALID_OPERATION;
+                               }
+
+                               /* get home/media path of client and can be different in case of multi-user */
+                               tzplatform_set_user(cred.uid);
+                               internal_path = g_strdup(MEDIA_PATH_USER);
+                               tzplatform_reset_user();
+
+                               // LOGD("internal storage path %s", internal_path);
+
+                               if (strncmp(file_path, internal_path, strlen(internal_path)) == 0) { /* internal media storage */
+                                       privilege = MEDIA_STORAGE_PRIVILEGE_NAME;
+                                       g_free(internal_path);
+                               } else {        /* can access without permission */
+                                       g_free(internal_path);
+                                       return PLAYER_ERROR_NONE;
+                               }
+                       }
                }
        }
 
index 4260ed7..32c7681 100644 (file)
@@ -1,6 +1,6 @@
 Name:       mmsvc-player
 Summary:    A Media Player module for muse server
-Version:    0.2.48
+Version:    0.2.49
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0