Skip to content

Commit ba3bd49

Browse files
committed
Use runtime value of rpc.acl_file
1 parent 000e768 commit ba3bd49

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/mgos_rpc.c

+3-8
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252

5353
#define HTTP_URI_PREFIX "/rpc"
5454

55-
static char *s_acl_file = NULL;
5655
static struct mg_rpc *s_global_mg_rpc;
5756

5857
extern const char *mg_build_id;
@@ -403,7 +402,8 @@ static bool mgos_rpc_req_prehandler(struct mg_rpc_request_info *ri,
403402
const char *auth_domain = NULL;
404403
const char *auth_file = NULL;
405404

406-
if (s_acl_file != NULL) {
405+
const char *acl_file = mgos_sys_config_get_rpc_acl_file();
406+
if (acl_file != NULL) {
407407
/* acl_file is set: then, by default, deny everything */
408408
acl_entry = mg_mk_str("-*");
409409

@@ -412,7 +412,7 @@ static bool mgos_rpc_req_prehandler(struct mg_rpc_request_info *ri,
412412
};
413413

414414
size_t size;
415-
acl_data = cs_read_file(s_acl_file, &size);
415+
acl_data = cs_read_file(acl_file, &size);
416416
int walk_res = json_walk(acl_data, size, acl_parse_cb, &ctx);
417417

418418
if (walk_res < 0) {
@@ -560,11 +560,6 @@ bool mgos_rpc_common_init(void) {
560560
mg_rpc_add_list_handler(c);
561561
s_global_mg_rpc = c;
562562

563-
/* We make a copy so that ACL file changes only apply on reboot. */
564-
if (mgos_sys_config_get_rpc_acl_file() != NULL) {
565-
s_acl_file = strdup(mgos_sys_config_get_rpc_acl_file());
566-
}
567-
568563
#if MGOS_ENABLE_SYS_SERVICE
569564
if (mgos_sys_config_get_rpc_service_sys_enable()) {
570565
mg_rpc_add_handler(c, "Sys.Reboot", "{delay_ms: %d}",

0 commit comments

Comments
 (0)