Ensure --auth is provided, so ejabberd_ctl checks AccessCommands (#159)

This commit is contained in:
Badlop 2016-04-15 13:35:46 +02:00
parent 9374ed0ffc
commit 7429577b7a
1 changed files with 7 additions and 1 deletions

View File

@ -88,8 +88,9 @@ maybe_post_request(<<$<,_/binary>> = Data, Host, ClientIp) ->
maybe_post_request(Data, Host, _ClientIp) ->
?INFO_MSG("Data: ~p", [Data]),
Args = split_line(unicode:characters_to_list(Data, utf8)),
Args2 = ensure_auth_is_provided(Args),
AccessCommands = get_option_access(Host),
case ejabberd_ctl:process2(Args, AccessCommands) of
case ejabberd_ctl:process2(Args2, AccessCommands) of
{"", ?STATUS_SUCCESS} ->
{200, [], integer_to_list(?STATUS_SUCCESS)};
{String, ?STATUS_SUCCESS} ->
@ -100,6 +101,11 @@ maybe_post_request(Data, Host, _ClientIp) ->
{200, [], String}
end.
ensure_auth_is_provided(["--auth", _, _, _ | _] = Args) ->
Args;
ensure_auth_is_provided(Args) ->
["--auth", "", "", "" | Args].
%% This function throws an error if the module is not started in that VHost.
try_get_option(Host, OptionName, DefaultValue) ->
case gen_mod:is_loaded(Host, ?MODULE) of