Преглед изворни кода

Merge pull request #4087 from zmstone/fix-auth-ldap

fix(auth_ldap): do not load plugin when no params configured
Zaiming Shi пре 5 година
родитељ
комит
e96d03dc1b

+ 13 - 0
.github/workflows/build_packages.yaml

@@ -93,6 +93,19 @@ jobs:
         unzip _packages/emqx/$pkg_name
         gsed -i '/emqx_telemetry/d' ./emqx/data/loaded_plugins
         ./emqx/bin/emqx start || cat emqx/log/erlang.log.1
+        ready='no'
+        for i in {1..10}; do
+          if curl -fs 127.0.0.1:18083 > /dev/null; then
+            ready='yes'
+            break
+          fi
+          sleep 1
+        done
+        if [ "$ready" != "yes" ]; then
+          echo "Timed out waiting for emqx to be ready"
+          cat emqx/log/erlang.log.1
+          exit 1
+        fi
         ./emqx/bin/emqx_ctl status
         ./emqx/bin/emqx stop
         rm -rf emqx

+ 1 - 0
apps/emqx_auth_ldap/src/emqx_auth_ldap_app.erl

@@ -60,6 +60,7 @@ load_acl_hook(DeviceDn) ->
 
 if_enabled(Cfgs, Fun) ->
     case get_env(Cfgs) of
+        {ok, []} -> ok;
         {ok, InitArgs} -> Fun(InitArgs)
     end.
 

+ 8 - 0
apps/emqx_auth_pgsql/src/emqx_auth_pgsql_cli.erl

@@ -56,6 +56,11 @@ pgvar(Sql, Params) ->
 %% PostgreSQL Connect/Query
 %%--------------------------------------------------------------------
 
+%% Due to a bug in epgsql the caluse for `econnrefused` is not recognised by
+%% dialyzer, result in this error:
+%% The pattern {'error', Reason = 'econnrefused'} can never match the type ...
+%% https://github.com/epgsql/epgsql/issues/246
+-dialyzer([{nowarn_function, [connect/1]}]).
 connect(Opts) ->
     Host     = proplists:get_value(host, Opts),
     Username = proplists:get_value(username, Opts),
@@ -64,6 +69,9 @@ connect(Opts) ->
         {ok, C} ->
             conn_post(C),
             {ok, C};
+        {error, Reason = econnrefused} ->
+            ?LOG(error, "[Postgres] Can't connect to Postgres server: Connection refused."),
+            {error, Reason};
         {error, Reason = invalid_authorization_specification} ->
             ?LOG(error, "[Postgres] Can't connect to Postgres server: Invalid authorization specification."),
             {error, Reason};

+ 7 - 7
apps/emqx_coap/src/emqx_coap_ps_resource.erl

@@ -259,13 +259,13 @@ handle_received_create(TopicPrefix, MaxAge, Payload) ->
             {error, bad_request}
     end.
 
-%% http_uri:decode/1 is deprecated in OTP-23
-%% its equivalent uri_string:percent_decode however is not available before OTP 23
--if(?OTP_RELEASE >= 23).
-percent_decode(Topic) -> uri_string:percent_decode(Topic).
--else.
-percent_decode(Topic) -> http_uri:decode(Topic).
--endif.
+%% @private Copy from http_uri.erl which has been deprecated since OTP-23
+percent_decode(<<$%, Hex:2/binary, Rest/bits>>) ->
+    <<(binary_to_integer(Hex, 16)), (percent_decode(Rest))/binary>>;
+percent_decode(<<First:1/binary, Rest/bits>>) ->
+    <<First/binary, (percent_decode(Rest))/binary>>;
+percent_decode(<<>>) ->
+    <<>>.
 
 %% When topic is timeout, server should return nocontent here,
 %% but gen_coap only receive return value of #coap_content from coap_get, so temporarily we can't give the Code 2.07 {ok, nocontent} out.TBC!!!