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 ""
"Project-Id-Version: PACKAGE VERSION\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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

View File

@ -3,12 +3,13 @@
#include "../../include/ctx.h"
#include <linux/limits.h>
#include <strings.h>
#include <stdbool.h>
#include <stdlib.h>
#include <locale.h>
#include <string.h>
#include <stdio.h>
#include <strings.h>
#include <errno.h>
bool __lm_ctx_init_checkdir(char *path){
if(!mkdir_ifnot(path, 0755)){
@ -100,6 +101,8 @@ end:
void lm_ctx_free(lm_ctx_t *ctx) {
lm_ctx_pool_clear(ctx);
lm_ctx_temp_clear(ctx);
free(ctx->data);
free(ctx->root);
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;
}
if(!mkdir_ifnot(ctx->temp, 0755)){
lm_error_set(LM_ERR_CtxTempFailMkdir);
return false;
}
if(!lm_ctx_temp_clear(ctx))
return false; // error set by function
if(!lm_ctx_database_init(ctx))
return false; // error set by function

View File

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

View File

@ -38,7 +38,7 @@ lm_database_t *lm_database_new(char *path){
char *err = NULL;
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);
return NULL;
}
@ -58,7 +58,7 @@ lm_database_t *lm_database_new(char *path){
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);
lm_error_set(LM_ERR_DbSqlCreateFail);
sqlite3_free(err);