Sfoglia il codice sorgente

Merge pull request #10905 from thalesmg/fix-enforce-binary-rootkey-config-v50

fix(config): enforce root key name to be a binary (raw config)
Thales Macedo Garitezi 2 anni fa
parent
commit
7740987a17

+ 3 - 2
apps/emqx/src/emqx_config.erl

@@ -299,14 +299,15 @@ get_raw(KeyPath, Default) -> do_get_raw(KeyPath, Default).
 put_raw(Config) ->
     maps:fold(
         fun(RootName, RootV, _) ->
-            ?MODULE:put_raw([RootName], RootV)
+            ?MODULE:put_raw([bin(RootName)], RootV)
         end,
         ok,
         hocon_maps:ensure_plain(Config)
     ).
 
 -spec put_raw(emqx_utils_maps:config_key_path(), term()) -> ok.
-put_raw(KeyPath, Config) ->
+put_raw(KeyPath0, Config) ->
+    KeyPath = [bin(K) || K <- KeyPath0],
     Putter = fun(Path, Map, Value) ->
         emqx_utils_maps:deep_force_put(Path, Map, Value)
     end,

+ 1 - 0
apps/emqx/test/emqx_authentication_SUITE.erl

@@ -297,6 +297,7 @@ t_update_config({init, Config}) ->
     ];
 t_update_config(Config) when is_list(Config) ->
     emqx_config_handler:add_handler([?CONF_ROOT], emqx_authentication),
+    ok = emqx_config_handler:add_handler([listeners, '?', '?', ?CONF_ROOT], emqx_authentication),
     ok = register_provider(?config("auth1"), ?MODULE),
     ok = register_provider(?config("auth2"), ?MODULE),
     Global = ?config(global),

+ 1 - 1
apps/emqx/test/emqx_crl_cache_SUITE.erl

@@ -279,7 +279,7 @@ does_module_exist(Mod) ->
 
 clear_listeners() ->
     emqx_config:put([listeners], #{}),
-    emqx_config:put_raw([listeners], #{}),
+    emqx_config:put_raw([<<"listeners">>], #{}),
     ok.
 
 assert_http_get(URL) ->