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]};
|
{A, compile(who, Who), Access, [compile(topic, Topic) || Topic <- TopicFilters]};
|
||||||
|
|
||||||
compile(Rule) ->
|
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) ->
|
compile(who, all) ->
|
||||||
all;
|
all;
|
||||||
|
|
|
@ -60,10 +60,12 @@ load_rules_from_file(AclFile) ->
|
||||||
ets:insert(?ACL_RULE_TAB, {all_rules, Terms}),
|
ets:insert(?ACL_RULE_TAB, {all_rules, Terms}),
|
||||||
ok;
|
ok;
|
||||||
{error, Reason} ->
|
{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}
|
{error, Reason}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
filter(_PubSub, {error, _}) ->
|
||||||
|
false;
|
||||||
filter(_PubSub, {allow, all}) ->
|
filter(_PubSub, {allow, all}) ->
|
||||||
true;
|
true;
|
||||||
filter(_PubSub, {deny, all}) ->
|
filter(_PubSub, {deny, all}) ->
|
||||||
|
|
|
@ -355,7 +355,8 @@ compile_rule(_) ->
|
||||||
{deny, all, subscribe, [ [<<"$SYS">>, '#'], ['#'] ]} =
|
{deny, all, subscribe, [ [<<"$SYS">>, '#'], ['#'] ]} =
|
||||||
compile({deny, all, subscribe, ["$SYS/#", "#"]}),
|
compile({deny, all, subscribe, ["$SYS/#", "#"]}),
|
||||||
{allow, all} = compile({allow, all}),
|
{allow, all} = compile({allow, all}),
|
||||||
{deny, all} = compile({deny, all}).
|
{deny, all} = compile({deny, all}),
|
||||||
|
{error, bad_rule} = compile({test, malformed}).
|
||||||
|
|
||||||
match_rule(_) ->
|
match_rule(_) ->
|
||||||
User = #{client_id => <<"testClient">>, username => <<"TestUser">>, peername => {{127,0,0,1}, 2948}},
|
User = #{client_id => <<"testClient">>, username => <<"TestUser">>, peername => {{127,0,0,1}, 2948}},
|
||||||
|
|
Loading…
Reference in New Issue