diff --git a/include/error.h b/include/error.h index c3f439e..57f0d03 100644 --- a/include/error.h +++ b/include/error.h @@ -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, diff --git a/locale/tr/LC_MESSAGES/libmp.po b/locale/tr/LC_MESSAGES/libmp.po index 3940e9f..ebf14ff 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 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 \n" "Language-Team: LANGUAGE \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 diff --git a/src/ctx/ctx.c b/src/ctx/ctx.c index e3addb0..883a428 100644 --- a/src/ctx/ctx.c +++ b/src/ctx/ctx.c @@ -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); diff --git a/src/error.c b/src/error.c index 26f4f1b..9f152d7 100644 --- a/src/error.c +++ b/src/error.c @@ -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") },