fix: temp directory and permission fixes
This commit is contained in:
@ -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);
|
||||
|
@ -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
|
||||
|
@ -42,4 +42,3 @@ bool lm_ctx_temp_clear(lm_ctx_t *ctx) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user