mod_http_upload_quota: Fix process name lookup

Fix mod_http_upload_quota's process name lookup for the case where a
slot is requested by a JID whose domain part is not the virtual host the
mod_http_upload_quota process is running on.
This commit is contained in:
Holger Weiss 2018-07-10 21:19:15 +02:00
parent d03432a956
commit c5dd1bdd9d
2 changed files with 5 additions and 6 deletions

View File

@ -584,7 +584,7 @@ create_slot(#state{service_url = undefined,
UserStr = make_user_string(JID, JIDinURL), UserStr = make_user_string(JID, JIDinURL),
UserDir = <<DocRoot/binary, $/, UserStr/binary>>, UserDir = <<DocRoot/binary, $/, UserStr/binary>>,
case ejabberd_hooks:run_fold(http_upload_slot_request, ServerHost, allow, case ejabberd_hooks:run_fold(http_upload_slot_request, ServerHost, allow,
[JID, UserDir, Size, Lang]) of [ServerHost, JID, UserDir, Size, Lang]) of
allow -> allow ->
RandStr = p1_rand:get_alphanum_string(SecretLength), RandStr = p1_rand:get_alphanum_string(SecretLength),
FileStr = make_file_string(File), FileStr = make_file_string(File),

View File

@ -49,7 +49,7 @@
code_change/3]). code_change/3]).
%% ejabberd_hooks callback. %% ejabberd_hooks callback.
-export([handle_slot_request/5]). -export([handle_slot_request/6]).
-include("jid.hrl"). -include("jid.hrl").
-include("logger.hrl"). -include("logger.hrl").
@ -229,14 +229,13 @@ code_change(_OldVsn, #state{server_host = ServerHost} = State, _Extra) ->
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% ejabberd_hooks callback. %% ejabberd_hooks callback.
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
-spec handle_slot_request(allow | deny, jid(), binary(), -spec handle_slot_request(allow | deny, binary(), jid(), binary(),
non_neg_integer(), binary()) -> allow | deny. non_neg_integer(), binary()) -> allow | deny.
handle_slot_request(allow, #jid{lserver = ServerHost} = JID, Path, Size, handle_slot_request(allow, ServerHost, JID, Path, Size, _Lang) ->
_Lang) ->
Proc = mod_http_upload:get_proc_name(ServerHost, ?MODULE), Proc = mod_http_upload:get_proc_name(ServerHost, ?MODULE),
gen_server:cast(Proc, {handle_slot_request, JID, Path, Size}), gen_server:cast(Proc, {handle_slot_request, JID, Path, Size}),
allow; allow;
handle_slot_request(Acc, _JID, _Path, _Size, _Lang) -> Acc. handle_slot_request(Acc, _ServerHost, _JID, _Path, _Size, _Lang) -> Acc.
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% Internal functions. %% Internal functions.