Fix crash in emqx_acl_internal:filter/2
This commit is contained in:
parent
35e699e54e
commit
ec2e289776
|
@ -47,7 +47,8 @@ compile({A, Who, Access, TopicFilters}) when ?ALLOW_DENY(A), ?PUBSUB(Access) ->
|
|||
{A, compile(who, Who), Access, [compile(topic, Topic) || Topic <- TopicFilters]};
|
||||
|
||||
compile(Rule) ->
|
||||
emqx_logger:error("[ACCESS_RULE] Malformed rule: ~p", [Rule]).
|
||||
emqx_logger:error("[ACCESS_RULE] Malformed rule: ~p", [Rule]),
|
||||
{error, bad_rule}.
|
||||
|
||||
compile(who, all) ->
|
||||
all;
|
||||
|
|
|
@ -60,10 +60,12 @@ load_rules_from_file(AclFile) ->
|
|||
ets:insert(?ACL_RULE_TAB, {all_rules, Terms}),
|
||||
ok;
|
||||
{error, Reason} ->
|
||||
emqx_logger:error("[ACL_INTERNAL] Consult failed: ~p", [Reason]),
|
||||
emqx_logger:error("[ACL_INTERNAL] Failed to read ~s: ~p", [AclFile, Reason]),
|
||||
{error, Reason}
|
||||
end.
|
||||
|
||||
|
||||
filter(_PubSub, {error, _}) ->
|
||||
false;
|
||||
filter(_PubSub, {allow, all}) ->
|
||||
true;
|
||||
filter(_PubSub, {deny, all}) ->
|
||||
|
|
|
@ -355,7 +355,8 @@ compile_rule(_) ->
|
|||
{deny, all, subscribe, [ [<<"$SYS">>, '#'], ['#'] ]} =
|
||||
compile({deny, all, subscribe, ["$SYS/#", "#"]}),
|
||||
{allow, all} = compile({allow, all}),
|
||||
{deny, all} = compile({deny, all}).
|
||||
{deny, all} = compile({deny, all}),
|
||||
{error, bad_rule} = compile({test, malformed}).
|
||||
|
||||
match_rule(_) ->
|
||||
User = #{client_id => <<"testClient">>, username => <<"TestUser">>, peername => {{127,0,0,1}, 2948}},
|
||||
|
|
Loading…
Reference in New Issue