fix: do not check write permissions for ctx dirs

This commit is contained in:
ngn 2024-08-16 04:22:04 +03:00
parent a641ef87ed
commit 2aa147b351
4 changed files with 12 additions and 6 deletions

View File

@ -140,7 +140,7 @@ typedef enum lm_error {
LM_ERR_InstallSaveFail = 138,
LM_ERR_FailMkdir = 139,
LM_ERR_NotDir = 140,
LM_ERR_NoWrite = 141,
LM_ERR_NoRead = 141,
LM_ERR_PoolListBadDir = 142,
LM_ERR_FileNotExist = 143,
LM_ERR_FileNotLink = 144,

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 03:06+0300\n"
"POT-Creation-Date: 2024-08-16 04:21+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"
@ -600,7 +600,7 @@ msgid "failed to create install script save directory"
msgstr ""
#: src/error.c:171
msgid "directory does not have write permissions"
msgid "directory does not have read permissions"
msgstr ""
#: src/error.c:172

View File

@ -21,8 +21,8 @@ bool __lm_ctx_init_checkdir(char *path){
return false;
}
if(!can_write(path)){
lm_error_set(LM_ERR_NoWrite);
if(!can_read(path)){
lm_error_set(LM_ERR_NoRead);
return false;
}
@ -63,6 +63,12 @@ bool lm_ctx_new(lm_ctx_t *ctx, char *root_dir, char *temp_dir, char *data_dir) {
goto end;
}
if(root_dir != NULL && !can_write(root_dir)){
pdebug(__func__, "check failed for specified root directory: %s", lm_strerror());
lm_error_set(LM_ERR_CtxRootFail, root_dir, "directory is not writeable");
goto end;
}
if(root_dir != NULL)
ctx->root = realpath(root_dir, NULL);

View File

@ -168,7 +168,7 @@ void lm_error_set(lm_error_t code, ...) {
{.code = LM_ERR_DbChangesNotExists, .desc = _("package changes file not found in the database") },
{.code = LM_ERR_DbChangesChmodFail, .desc = _("failed to change mod of the changes file") },
{.code = LM_ERR_InstallDirFail, .desc = _("failed to create install script save directory") },
{.code = LM_ERR_NoWrite, .desc = _("directory does not have write permissions") },
{.code = LM_ERR_NoRead, .desc = _("directory does not have read permissions") },
{.code = LM_ERR_NotDir, .desc = _("specified path is not a directory") },
{.code = LM_ERR_FailMkdir, .desc = _("failed to create the specified directory") },
{.code = LM_ERR_PoolListBadDir, .desc = _("specified list extraction directory is not accessible") },