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;
+ }
+ }
}
}