Do not change a permission of files stored in external storage 63/269063/1 accepted/tizen/6.5/unified/20220110.135814 submit/tizen_6.5/20220107.075951
authorSeonah Moon <seonah1.moon@samsung.com>
Fri, 7 Jan 2022 06:26:54 +0000 (15:26 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Fri, 7 Jan 2022 06:26:59 +0000 (15:26 +0900)
Change-Id: I2976c08ca9c76691883d30966b46976fd8e50b6d

packaging/download-provider.spec
provider/download-provider-plugin-download-agent.c

index 3e79dd42e5c88e1b359837c08840426d0c6928fb..1c4fa7a9831ba51a63393ec48ddc952a51c9fadd 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       download-provider
 Summary:    Download the contents in background
-Version:    2.2.8
+Version:    2.2.9
 Release:    0
 Group:      Development/Libraries
 License:    Apache-2.0
index 521921fe33c8b23124227bd02e7551ac663aa950..f32e2e9a76d407b7f846f154e1b07bdb83704f69 100755 (executable)
@@ -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;