diff --git a/include/util.h b/include/util.h index 21b58a0..cd8a109 100644 --- a/include/util.h +++ b/include/util.h @@ -42,7 +42,7 @@ void pdebug_binary(char *data, size_t len); bool parse_host(char *addr, char *host, uint16_t *port); bool copy_blocks(struct archive *w, struct archive *r); bool extract_archive(char *dst, char *src); -bool mkdir_ifnot(char *path); +bool mkdir_ifnot(char *path, int mode); int join_multiple(char *res, const char *base, const char *pth, const char *pth2); int join(char *res, const char *base, const char *pth); diff --git a/locale/tr/LC_MESSAGES/libmp.po b/locale/tr/LC_MESSAGES/libmp.po index ebf14ff..4acaa5f 100644 --- a/locale/tr/LC_MESSAGES/libmp.po +++ b/locale/tr/LC_MESSAGES/libmp.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-16 04:21+0300\n" +"POT-Creation-Date: 2024-08-16 05:23+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/src/ctx/ctx.c b/src/ctx/ctx.c index 883a428..c07fefb 100644 --- a/src/ctx/ctx.c +++ b/src/ctx/ctx.c @@ -11,7 +11,7 @@ #include bool __lm_ctx_init_checkdir(char *path){ - if(!mkdir_ifnot(path)){ + if(!mkdir_ifnot(path, 0755)){ lm_error_set(LM_ERR_FailMkdir); return false; } diff --git a/src/ctx/install.c b/src/ctx/install.c index 06ed6cc..897966b 100644 --- a/src/ctx/install.c +++ b/src/ctx/install.c @@ -29,7 +29,7 @@ bool __lm_ctx_save_install(lm_ctx_t *ctx, lm_pkg_t *pkg, char *install_path){ sprintf(script_name, "install_%s", pkg->data.name); join(script_dir, ctx->data, "scripts"); - if(!mkdir_ifnot(script_dir)){ + if(!mkdir_ifnot(script_dir, 0755)){ lm_error_set(LM_ERR_InstallDirFail); return false; } @@ -229,7 +229,7 @@ bool lm_ctx_install(lm_ctx_t *ctx, lm_pkg_t *pkg, bool run_install, lm_ctx_insta return false; } - if(!mkdir_ifnot(ctx->temp)){ + if(!mkdir_ifnot(ctx->temp, 0755)){ lm_error_set(LM_ERR_CtxTempFailMkdir); return false; } diff --git a/src/ctx/temp.c b/src/ctx/temp.c index f038178..c52f171 100644 --- a/src/ctx/temp.c +++ b/src/ctx/temp.c @@ -19,7 +19,7 @@ char *lm_ctx_temp_dir(lm_ctx_t *ctx, char *dir){ char td[strlen(ctx->temp)+strlen(dir)+10]; join(td, ctx->temp, dir); - if(!mkdir_ifnot(td)){ + if(!mkdir_ifnot(td, 0755)){ lm_error_set(LM_ERR_CtxTempFailMkdir); return NULL; } @@ -35,7 +35,7 @@ bool lm_ctx_temp_clear(lm_ctx_t *ctx) { rmrf(ctx->temp); - if(!mkdir_ifnot(ctx->temp)){ + if(!mkdir_ifnot(ctx->temp, 0755)){ lm_error_set(LM_ERR_CtxTempFailMkdir); return false; } diff --git a/src/database/database.c b/src/database/database.c index 12acb62..0662e83 100644 --- a/src/database/database.c +++ b/src/database/database.c @@ -43,7 +43,7 @@ lm_database_t *lm_database_new(char *path){ return NULL; } - if(!exists(path, NULL) && !mkdir_ifnot(path)){ + if(!exists(path, NULL) && !mkdir_ifnot(path, 0755)){ lm_error_set(LM_ERR_DbCantAccess); return NULL; } diff --git a/src/pool/info.c b/src/pool/info.c index 75151cb..c84e081 100644 --- a/src/pool/info.c +++ b/src/pool/info.c @@ -89,7 +89,7 @@ bool lm_pool_info_download(lm_pool_t *pool, lm_mptp_transfer_callback_t callback return false; } - if(!mkdir_ifnot(pool->dir)){ + if(!mkdir_ifnot(pool->dir, 0755)){ lm_error_set(LM_ERR_PoolBadDir); return false; } diff --git a/src/pool/list.c b/src/pool/list.c index c4989fb..e031404 100644 --- a/src/pool/list.c +++ b/src/pool/list.c @@ -30,12 +30,12 @@ bool lm_pool_list_load(lm_pool_t *pool, char *dir){ pdebug(__func__, "(%s) extracting pool to %s", pool->name, dir); - if(!mkdir_ifnot(pool->dir)){ + if(!mkdir_ifnot(pool->dir, 0755)){ lm_error_set(LM_ERR_PoolBadDir); return false; } - if(!mkdir_ifnot(dir)){ + if(!mkdir_ifnot(dir, 0755)){ lm_error_set(LM_ERR_PoolListBadDir); return false; } @@ -102,7 +102,7 @@ bool lm_pool_list_download(lm_pool_t *pool, char *dir, lm_mptp_transfer_callback return false; } - if(!mkdir_ifnot(pool->dir)){ + if(!mkdir_ifnot(pool->dir, 0755)){ lm_error_set(LM_ERR_PoolBadDir); return false; } diff --git a/src/pool/path.c b/src/pool/path.c index d003b3f..633ae0e 100644 --- a/src/pool/path.c +++ b/src/pool/path.c @@ -17,7 +17,7 @@ bool lm_pool_path_set_dir(lm_pool_t *pool, char *dir){ if(NULL == dir) return true; - if(exists(dir, NULL) && (is_file(dir) || !can_read(dir) || !can_write(dir))){ + if(exists(dir, NULL) && (is_file(dir) || !can_read(dir))){ lm_error_set(LM_ERR_PoolBadDir); return false; } @@ -26,12 +26,12 @@ bool lm_pool_path_set_dir(lm_pool_t *pool, char *dir){ pool->info_file = join_alloc(dir, "INFO"); pool->list_file = join_alloc(dir, "LIST"); - if(exists(pool->info_file, NULL) && (!is_file(pool->info_file) || !can_read(pool->info_file) || !can_write(pool->info_file))){ + if(exists(pool->info_file, NULL) && (!is_file(pool->info_file) || !can_read(pool->info_file))){ lm_error_set(LM_ERR_PoolBadPaths); return false; } - if(exists(pool->list_file, NULL) && (!is_file(pool->list_file) || !can_read(pool->list_file) || !can_write(pool->list_file))){ + if(exists(pool->list_file, NULL) && (!is_file(pool->list_file) || !can_read(pool->list_file))){ lm_error_set(LM_ERR_PoolBadPaths); return false; } diff --git a/src/util.c b/src/util.c index eb0a02e..27b5d94 100644 --- a/src/util.c +++ b/src/util.c @@ -278,8 +278,8 @@ bool can_write(char *path) { return access(path, W_OK) == 0; } -bool mkdir_ifnot(char *path) { - return !(mkdir(path, 0700) < 0 && errno != EEXIST); +bool mkdir_ifnot(char *path, int mode) { + return !(mkdir(path, mode) < 0 && errno != EEXIST); } bool package_name_valid(char *name) {