Merge pull request #1706 from pi-hole/fix/env_vars_put_delete

PUT and DELETE on forced config items are errors
This commit is contained in:
DL6ER
2023-10-29 19:12:09 +01:00
committed by GitHub
+14
View File
@@ -843,6 +843,20 @@ static int api_config_put_delete(struct ftl_conn *api)
if(min_level != level + 1)
continue;
// Error when this config item is read-only due to an
// environment variable forcing its value
if(new_item->f & FLAG_ENV_VAR)
{
char *key = strdup(new_item->k);
free_config(&newconf);
if(requested_path != NULL)
free_config_path(requested_path);
return send_json_error_free(api, 400,
"bad_request",
"Config items set via environment variables cannot be changed via the API",
key, true);
}
// Check if this entry does already exist in the array
int idx = 0;
for(; idx < cJSON_GetArraySize(new_item->v.json); idx++)