From 31922938bea71a4fa7a1d517a24a147018376fa6 Mon Sep 17 00:00:00 2001 From: Seonah Moon Date: Fri, 7 Jan 2022 15:26:54 +0900 Subject: [PATCH] Do not change a permission of files stored in external storage Change-Id: I1971284beff321a28d50b2e4769cdcf72a441eab --- packaging/download-provider.spec | 2 +- provider/download-provider-plugin-download-agent.c | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/packaging/download-provider.spec b/packaging/download-provider.spec index 6ffefad..7494d34 100755 --- a/packaging/download-provider.spec +++ b/packaging/download-provider.spec @@ -1,6 +1,6 @@ Name: download-provider Summary: Download the contents in background -Version: 2.3.0 +Version: 2.3.1 Release: 0 Group: Development/Libraries License: Apache-2.0 diff --git a/provider/download-provider-plugin-download-agent.c b/provider/download-provider-plugin-download-agent.c index 521921f..f32e2e9 100755 --- a/provider/download-provider-plugin-download-agent.c +++ b/provider/download-provider-plugin-download-agent.c @@ -48,6 +48,7 @@ #include "content/mime_type.h" #define DP_SDCARD_MNT_POINT tzplatform_mkpath(TZ_SYS_STORAGE, "sdcard") +#define DP_EXTERNAL_STORAGE "/opt/media/" #define DP_MAX_FILE_PATH_LEN 256 #define DP_MAX_MIME_TABLE_NUM 15 @@ -209,6 +210,13 @@ static int __set_file_permission_to_client(dp_client_slots_fmt *slot, dp_request return DP_ERROR_INVALID_PARAMETER; } + if (strncmp(saved_path, DP_EXTERNAL_STORAGE, strlen(DP_EXTERNAL_STORAGE)) == 0 + || strncmp(DP_SDCARD_MNT_POINT, + saved_path, strlen(DP_SDCARD_MNT_POINT)) == 0) { + TRACE_INFO("Do not change permission for %s", saved_path); + return DP_ERROR_NONE; + } + struct stat lstat_info; int fd; dp_credential cred = slot->credential; @@ -232,12 +240,12 @@ static int __set_file_permission_to_client(dp_client_slots_fmt *slot, dp_request // Change the owner to client's uid. if (fchown(fd, cred.uid, lstat_info.st_gid) != 0) { TRACE_ERROR("[ERROR][%d] permission user:%d group:%d", - request->id, cred.uid, cred.gid); + request->id, cred.uid, lstat_info.st_gid); close(fd); return DP_ERROR_PERMISSION_DENIED; } - TRACE_INFO("file owner has been changed to %d.", cred.uid); + TRACE_INFO("file owner has been changed to %d:%d", cred.uid, lstat_info.st_gid); close(fd); return DP_ERROR_NONE; @@ -282,7 +290,8 @@ static void __finished_cb(finished_info_t *info, void *user_req_data, TRACE_SECURE_DEBUG("[FINISH][%d][%s]", request->id, info->saved_path); if (info->err == DA_RESULT_OK) { if (info->saved_path != NULL) { - errorcode = __set_file_permission_to_client(slot, request, info->saved_path); + errorcode = __set_file_permission_to_client(slot, + request, info->saved_path); } else { TRACE_ERROR("[ERROR][%d] No SavedPath", request->id); errorcode = DP_ERROR_INVALID_DESTINATION; -- 2.7.4