Skip to content

Commit

Permalink
Use new access_rules_validator in couple places
Browse files Browse the repository at this point in the history
  • Loading branch information
prefiks committed Jun 21, 2016
1 parent 804190e commit 52d4560
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/ejabberd_commands.erl
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ is_admin(Name, Auth, Extra) ->
end,
AdminAccess = ejabberd_config:get_option(
commands_admin_access,
fun(A) when is_atom(A) -> A end,
fun(V) -> V end,
none),
case acl:access_matches(AdminAccess, ACLInfo, Server) of
allow ->
Expand All @@ -773,8 +773,7 @@ is_admin(Name, Auth, Extra) ->
deny -> false
end.

opt_type(commands_admin_access) ->
fun(A) when is_atom(A) -> A end;
opt_type(commands_admin_access) -> fun acl:access_rules_validator/1;
opt_type(commands) ->
fun(V) when is_list(V) -> V end;
opt_type(_) -> [commands, commands_admin_access].
5 changes: 2 additions & 3 deletions src/mod_http_api.erl
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ check_permissions2(_Request, Call, open) ->
{allowed, Call, noauth};
check_permissions2(#request{ip={IP, _Port}}, Call, _Policy) ->
Access = gen_mod:get_module_opt(global, ?MODULE, admin_ip_access,
mod_opt_type(admin_ip_access),
fun(V) -> V end,
none),
Res = acl:match_rule(global, Access, IP),
case Res of
Expand Down Expand Up @@ -502,6 +502,5 @@ log(Call, Args, {Addr, Port}) ->
log(Call, Args, IP) ->
?INFO_MSG("API call ~s ~p (~p)", [Call, Args, IP]).

mod_opt_type(admin_ip_access) ->
fun(Access) when is_atom(Access) -> Access end;
mod_opt_type(admin_ip_access) -> fun acl:access_rules_validator/1;
mod_opt_type(_) -> [admin_ip_access].

0 comments on commit 52d4560

Please sign in to comment.