fix: temp directory and permission fixes

This commit is contained in:
ngn 2024-08-16 06:52:05 +03:00
parent e41a627882
commit ebc9192ae2
5 changed files with 9 additions and 9 deletions

View File

@ -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 05:23+0300\n" "POT-Creation-Date: 2024-08-16 06:47+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"

View File

@ -3,12 +3,13 @@
#include "../../include/ctx.h" #include "../../include/ctx.h"
#include <linux/limits.h> #include <linux/limits.h>
#include <strings.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
#include <locale.h> #include <locale.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <strings.h> #include <errno.h>
bool __lm_ctx_init_checkdir(char *path){ bool __lm_ctx_init_checkdir(char *path){
if(!mkdir_ifnot(path, 0755)){ if(!mkdir_ifnot(path, 0755)){
@ -100,6 +101,8 @@ end:
void lm_ctx_free(lm_ctx_t *ctx) { void lm_ctx_free(lm_ctx_t *ctx) {
lm_ctx_pool_clear(ctx); lm_ctx_pool_clear(ctx);
lm_ctx_temp_clear(ctx);
free(ctx->data); free(ctx->data);
free(ctx->root); free(ctx->root);
free(ctx->temp); free(ctx->temp);

View File

@ -229,10 +229,8 @@ 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, 0755)){ if(!lm_ctx_temp_clear(ctx))
lm_error_set(LM_ERR_CtxTempFailMkdir); return false; // error set by function
return false;
}
if(!lm_ctx_database_init(ctx)) if(!lm_ctx_database_init(ctx))
return false; // error set by function return false; // error set by function

View File

@ -42,4 +42,3 @@ bool lm_ctx_temp_clear(lm_ctx_t *ctx) {
return true; return true;
} }

View File

@ -38,7 +38,7 @@ lm_database_t *lm_database_new(char *path){
char *err = NULL; char *err = NULL;
bzero(db, sizeof(lm_database_t)); bzero(db, sizeof(lm_database_t));
if(exists(path, NULL) && (is_file(path) || !can_read(path) || !can_write(path))){ if(exists(path, NULL) && (is_file(path) || !can_read(path))){
lm_error_set(LM_ERR_DbCantAccess); lm_error_set(LM_ERR_DbCantAccess);
return NULL; return NULL;
} }
@ -58,7 +58,7 @@ lm_database_t *lm_database_new(char *path){
return NULL; return NULL;
} }
if(sqlite3_exec(db->sql, queries[QUERY_CREATE_TABLE], NULL, 0, &err) != SQLITE_OK){ if(can_write(path) && sqlite3_exec(db->sql, queries[QUERY_CREATE_TABLE], NULL, 0, &err) != SQLITE_OK){
pdebug(__func__, "(%s) failed to create packages table: %s", packagesdb, err); pdebug(__func__, "(%s) failed to create packages table: %s", packagesdb, err);
lm_error_set(LM_ERR_DbSqlCreateFail); lm_error_set(LM_ERR_DbSqlCreateFail);
sqlite3_free(err); sqlite3_free(err);