fix: make dirs readable by other users

This commit is contained in:
ngn 2024-08-16 05:25:02 +03:00
parent 2aa147b351
commit e41a627882
10 changed files with 17 additions and 17 deletions

View File

@ -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);

View File

@ -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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

View File

@ -11,7 +11,7 @@
#include <strings.h>
bool __lm_ctx_init_checkdir(char *path){
if(!mkdir_ifnot(path)){
if(!mkdir_ifnot(path, 0755)){
lm_error_set(LM_ERR_FailMkdir);
return false;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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) {