fix: make dirs readable by other users
This commit is contained in:
parent
2aa147b351
commit
e41a627882
@ -42,7 +42,7 @@ void pdebug_binary(char *data, size_t len);
|
|||||||
bool parse_host(char *addr, char *host, uint16_t *port);
|
bool parse_host(char *addr, char *host, uint16_t *port);
|
||||||
bool copy_blocks(struct archive *w, struct archive *r);
|
bool copy_blocks(struct archive *w, struct archive *r);
|
||||||
bool extract_archive(char *dst, char *src);
|
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_multiple(char *res, const char *base, const char *pth, const char *pth2);
|
||||||
int join(char *res, const char *base, const char *pth);
|
int join(char *res, const char *base, const char *pth);
|
||||||
|
@ -8,7 +8,7 @@ msgid ""
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \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"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
|
|
||||||
bool __lm_ctx_init_checkdir(char *path){
|
bool __lm_ctx_init_checkdir(char *path){
|
||||||
if(!mkdir_ifnot(path)){
|
if(!mkdir_ifnot(path, 0755)){
|
||||||
lm_error_set(LM_ERR_FailMkdir);
|
lm_error_set(LM_ERR_FailMkdir);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -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);
|
sprintf(script_name, "install_%s", pkg->data.name);
|
||||||
join(script_dir, ctx->data, "scripts");
|
join(script_dir, ctx->data, "scripts");
|
||||||
|
|
||||||
if(!mkdir_ifnot(script_dir)){
|
if(!mkdir_ifnot(script_dir, 0755)){
|
||||||
lm_error_set(LM_ERR_InstallDirFail);
|
lm_error_set(LM_ERR_InstallDirFail);
|
||||||
return false;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!mkdir_ifnot(ctx->temp)){
|
if(!mkdir_ifnot(ctx->temp, 0755)){
|
||||||
lm_error_set(LM_ERR_CtxTempFailMkdir);
|
lm_error_set(LM_ERR_CtxTempFailMkdir);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ char *lm_ctx_temp_dir(lm_ctx_t *ctx, char *dir){
|
|||||||
char td[strlen(ctx->temp)+strlen(dir)+10];
|
char td[strlen(ctx->temp)+strlen(dir)+10];
|
||||||
join(td, ctx->temp, dir);
|
join(td, ctx->temp, dir);
|
||||||
|
|
||||||
if(!mkdir_ifnot(td)){
|
if(!mkdir_ifnot(td, 0755)){
|
||||||
lm_error_set(LM_ERR_CtxTempFailMkdir);
|
lm_error_set(LM_ERR_CtxTempFailMkdir);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -35,7 +35,7 @@ bool lm_ctx_temp_clear(lm_ctx_t *ctx) {
|
|||||||
|
|
||||||
rmrf(ctx->temp);
|
rmrf(ctx->temp);
|
||||||
|
|
||||||
if(!mkdir_ifnot(ctx->temp)){
|
if(!mkdir_ifnot(ctx->temp, 0755)){
|
||||||
lm_error_set(LM_ERR_CtxTempFailMkdir);
|
lm_error_set(LM_ERR_CtxTempFailMkdir);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ lm_database_t *lm_database_new(char *path){
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!exists(path, NULL) && !mkdir_ifnot(path)){
|
if(!exists(path, NULL) && !mkdir_ifnot(path, 0755)){
|
||||||
lm_error_set(LM_ERR_DbCantAccess);
|
lm_error_set(LM_ERR_DbCantAccess);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ bool lm_pool_info_download(lm_pool_t *pool, lm_mptp_transfer_callback_t callback
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!mkdir_ifnot(pool->dir)){
|
if(!mkdir_ifnot(pool->dir, 0755)){
|
||||||
lm_error_set(LM_ERR_PoolBadDir);
|
lm_error_set(LM_ERR_PoolBadDir);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -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);
|
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);
|
lm_error_set(LM_ERR_PoolBadDir);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!mkdir_ifnot(dir)){
|
if(!mkdir_ifnot(dir, 0755)){
|
||||||
lm_error_set(LM_ERR_PoolListBadDir);
|
lm_error_set(LM_ERR_PoolListBadDir);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -102,7 +102,7 @@ bool lm_pool_list_download(lm_pool_t *pool, char *dir, lm_mptp_transfer_callback
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!mkdir_ifnot(pool->dir)){
|
if(!mkdir_ifnot(pool->dir, 0755)){
|
||||||
lm_error_set(LM_ERR_PoolBadDir);
|
lm_error_set(LM_ERR_PoolBadDir);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ bool lm_pool_path_set_dir(lm_pool_t *pool, char *dir){
|
|||||||
if(NULL == dir)
|
if(NULL == dir)
|
||||||
return true;
|
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);
|
lm_error_set(LM_ERR_PoolBadDir);
|
||||||
return false;
|
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->info_file = join_alloc(dir, "INFO");
|
||||||
pool->list_file = join_alloc(dir, "LIST");
|
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);
|
lm_error_set(LM_ERR_PoolBadPaths);
|
||||||
return false;
|
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);
|
lm_error_set(LM_ERR_PoolBadPaths);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -278,8 +278,8 @@ bool can_write(char *path) {
|
|||||||
return access(path, W_OK) == 0;
|
return access(path, W_OK) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mkdir_ifnot(char *path) {
|
bool mkdir_ifnot(char *path, int mode) {
|
||||||
return !(mkdir(path, 0700) < 0 && errno != EEXIST);
|
return !(mkdir(path, mode) < 0 && errno != EEXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool package_name_valid(char *name) {
|
bool package_name_valid(char *name) {
|
||||||
|
Loading…
Reference in New Issue
Block a user