Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/processone/ejabberd.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Chmielowski <pchmielowski@process-one.net>2017-01-20 12:19:09 +0300
committerPaweł Chmielowski <pchmielowski@process-one.net>2017-01-20 12:19:09 +0300
commit1f025675071c322fbc2356149170c969e759dbe3 (patch)
treeff03077c22d25659e838990fa0e8459195337340 /src/mod_http_api.erl
parent4f5d54f0622e0869f096d0a0324f4fce5264a8f4 (diff)
Make shim for mod_http_api admin_ip_access more robust
Diffstat (limited to 'src/mod_http_api.erl')
-rw-r--r--src/mod_http_api.erl42
1 files changed, 22 insertions, 20 deletions
diff --git a/src/mod_http_api.erl b/src/mod_http_api.erl
index e1f9e5b60..d962aaefe 100644
--- a/src/mod_http_api.erl
+++ b/src/mod_http_api.erl
@@ -539,26 +539,28 @@ permission_addon() ->
fun(V) -> V end,
none),
Rules = acl:resolve_access(Access, global),
- R = lists:filtermap(
- fun({V, AclRules}) when V == all; V == [all]; V == [allow]; V == allow ->
- {true, {[{allow, AclRules}], {[<<"*">>], []}}};
- ({List, AclRules}) when is_list(List) ->
- {true, {[{allow, AclRules}], {List, []}}};
- (_) ->
- false
- end, Rules),
- case R of
- [] ->
- none;
- _ ->
- {_, Res} = lists:foldl(
- fun({R2, L2}, {Idx, Acc}) ->
- {Idx+1, [{<<"'mod_http_api admin_ip_access' option compatibility shim ",
- (integer_to_binary(Idx))/binary>>,
- {[?MODULE], [{access, R2}], L2}} | Acc]}
- end, {1, []}, R),
- Res
- end.
+ R = case Rules of
+ all ->
+ [{[{allow, all}], {all, []}}];
+ none ->
+ [];
+ _ ->
+ lists:filtermap(
+ fun({V, AclRules}) when V == all; V == [all]; V == [allow]; V == allow ->
+ {true, {[{allow, AclRules}], {all, []}}};
+ ({List, AclRules}) when is_list(List) ->
+ {true, {[{allow, AclRules}], {List, []}}};
+ (_) ->
+ false
+ end, Rules)
+ end,
+ {_, Res} = lists:foldl(
+ fun({R2, L2}, {Idx, Acc}) ->
+ {Idx+1, [{<<"'mod_http_api admin_ip_access' option compatibility shim ",
+ (integer_to_binary(Idx))/binary>>,
+ {[?MODULE], [{access, R2}], L2}} | Acc]}
+ end, {1, []}, R),
+ Res.
mod_opt_type(admin_ip_access) -> fun acl:access_rules_validator/1;
mod_opt_type(_) -> [admin_ip_access].