Ensure --auth is provided, so ejabberd_ctl checks AccessCommands (#159)
This commit is contained in:
parent
9374ed0ffc
commit
7429577b7a
|
@ -88,8 +88,9 @@ maybe_post_request(<<$<,_/binary>> = Data, Host, ClientIp) ->
|
||||||
maybe_post_request(Data, Host, _ClientIp) ->
|
maybe_post_request(Data, Host, _ClientIp) ->
|
||||||
?INFO_MSG("Data: ~p", [Data]),
|
?INFO_MSG("Data: ~p", [Data]),
|
||||||
Args = split_line(unicode:characters_to_list(Data, utf8)),
|
Args = split_line(unicode:characters_to_list(Data, utf8)),
|
||||||
|
Args2 = ensure_auth_is_provided(Args),
|
||||||
AccessCommands = get_option_access(Host),
|
AccessCommands = get_option_access(Host),
|
||||||
case ejabberd_ctl:process2(Args, AccessCommands) of
|
case ejabberd_ctl:process2(Args2, AccessCommands) of
|
||||||
{"", ?STATUS_SUCCESS} ->
|
{"", ?STATUS_SUCCESS} ->
|
||||||
{200, [], integer_to_list(?STATUS_SUCCESS)};
|
{200, [], integer_to_list(?STATUS_SUCCESS)};
|
||||||
{String, ?STATUS_SUCCESS} ->
|
{String, ?STATUS_SUCCESS} ->
|
||||||
|
@ -100,6 +101,11 @@ maybe_post_request(Data, Host, _ClientIp) ->
|
||||||
{200, [], String}
|
{200, [], String}
|
||||||
end.
|
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.
|
%% This function throws an error if the module is not started in that VHost.
|
||||||
try_get_option(Host, OptionName, DefaultValue) ->
|
try_get_option(Host, OptionName, DefaultValue) ->
|
||||||
case gen_mod:is_loaded(Host, ?MODULE) of
|
case gen_mod:is_loaded(Host, ?MODULE) of
|
||||||
|
|
Loading…
Reference in New Issue