preload_add: only allow mgmt app to store or delete

This commit is contained in:
Daniel Jobson 2024-09-18 11:19:31 +02:00
parent 0669df4c27
commit 4770f18137
No known key found for this signature in database
GPG Key ID: 3707A9DBF4BB8F1A

View File

@ -5,6 +5,7 @@
#include "../tk1_mem.h" #include "../tk1_mem.h"
#include "flash.h" #include "flash.h"
#include "lib.h" #include "lib.h"
#include "mgmt_app.h"
#include "partition_table.h" #include "partition_table.h"
#include <stdbool.h> #include <stdbool.h>
@ -50,6 +51,11 @@ int preload_store(partition_table_t *part_table)
// where to store. // where to store.
// Most likely needs to aggregate some data, before it writes to flash. // Most likely needs to aggregate some data, before it writes to flash.
/* Check if we are allowed to deleted */
if (!mgmt_app_authenticate(&part_table->mgmt_app_data)) {
return -1;
}
/*Check for a valid app in flash, bale out if it already exists */ /*Check for a valid app in flash, bale out if it already exists */
if (preload_check_valid_app(part_table)) { if (preload_check_valid_app(part_table)) {
return -1; return -1;
@ -60,6 +66,11 @@ int preload_store(partition_table_t *part_table)
int preload_delete(partition_table_t *part_table) int preload_delete(partition_table_t *part_table)
{ {
/* Check if we are allowed to deleted */
if (!mgmt_app_authenticate(&part_table->mgmt_app_data)) {
return -1;
}
/*Check for a valid app in flash */ /*Check for a valid app in flash */
if (!preload_check_valid_app(part_table)) { if (!preload_check_valid_app(part_table)) {
return 0; return 0;