From a850e047f2f939cfe3d8f5efd1e2f11bf0a8c14e Mon Sep 17 00:00:00 2001 From: Jungki Kwak Date: Wed, 15 May 2013 19:57:56 +0900 Subject: [PATCH] Create default download directory with app ownership [Issue#] N_SE-38644 [Cause] The default download directory is re-created with root permision [Solution] The default download directoy is re-created with app ownership modified: agent/download-agent-file.c modified: agent/download-agent-interface.c --- agent/download-agent-file.c | 30 +++++++----------------------- agent/download-agent-interface.c | 4 ---- 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/agent/download-agent-file.c b/agent/download-agent-file.c index e44863f..9df7099 100755 --- a/agent/download-agent-file.c +++ b/agent/download-agent-file.c @@ -55,29 +55,6 @@ static da_result_t __file_write_buf_directly_write(stage_info *stage, file_info *file_storage, char *body, int body_len); -da_result_t create_saved_dir(void) -{ - da_result_t ret = DA_RESULT_OK; - char *tmp_default_path = DA_NULL; - - DA_LOG_FUNC_START(FileManager); - - ret = get_default_install_dir(&tmp_default_path); - if (ret != DA_RESULT_OK) - goto ERR; - - if (!is_dir_exist(tmp_default_path)) { - ret = create_dir(tmp_default_path); - } - -ERR: - if (tmp_default_path) { - free(tmp_default_path); - tmp_default_path = DA_NULL; - } - return ret; -} - da_result_t clean_files_from_dir(char *dir_path) { da_result_t ret = DA_RESULT_OK; @@ -1177,6 +1154,10 @@ da_result_t create_dir(const char *install_dir) ret = DA_ERR_FAIL_TO_ACCESS_STORAGE; } else { DA_LOG(FileManager, "[%s] is created!", install_dir); + if (chown(install_dir, 5000, 5000) < 0) { + DA_LOG_ERR(FileManager, "Fail to chown"); + ret = DA_ERR_FAIL_TO_ACCESS_STORAGE; + } } return ret; } @@ -1239,6 +1220,9 @@ da_result_t get_default_install_dir(char **out_path) *out_path = default_path; + if (!is_dir_exist(default_path)) { + ret = create_dir(default_path); + } DA_LOG_VERBOSE(FileManager, "default temp path = [%s]", *out_path); return DA_RESULT_OK; } diff --git a/agent/download-agent-interface.c b/agent/download-agent-interface.c index 2ac32dd..e16d6ff 100755 --- a/agent/download-agent-interface.c +++ b/agent/download-agent-interface.c @@ -56,10 +56,6 @@ int da_init( if (ret != DA_RESULT_OK) goto ERR; - ret = create_saved_dir(); - if (ret != DA_RESULT_OK) - goto ERR; - ERR: if (DA_RESULT_OK != ret) da_deinit(); -- 2.7.4