update: make the package changes file read-only

This commit is contained in:
ngn
2024-07-19 19:23:48 +03:00
parent 2e918b55ee
commit b8d2d69752
8 changed files with 41 additions and 14 deletions

View File

@ -20,7 +20,15 @@ bool lm_database_changes_update(lm_database_t *db, lm_pkg_t *pkg, char *file){
char changes_path[strlen(db->dir)+sizeof(changes_file)];
join(changes_path, db->dir, changes_file);
return copy_file(changes_path, file);
if(!copy_file(changes_path, file))
return false;
if(chmod(changes_path, 0444) < 0){
lm_error_set(LM_ERR_DbChangesChmodFail);
return false;
}
return true;
}
bool lm_database_changes_del(lm_database_t *db, lm_pkg_t *pkg){
@ -51,6 +59,7 @@ char *lm_database_changes_get(lm_database_t *db, lm_pkg_t *pkg){
join(changes_path, db->dir, changes_file);
if(!exists(changes_path)){
lm_error_set(LM_ERR_DbChangesNotExists);
free(changes_path);
return NULL;
}