mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Make mod_privilge properly handle roster iq
This commit is contained in:
parent
4843cd432f
commit
b50ea7ef1f
@ -274,7 +274,7 @@ component_send_packet({#iq{from = From,
|
|||||||
case {maps:find(Host, Permissions), get_iq_encapsulated_details(IQ)} of
|
case {maps:find(Host, Permissions), get_iq_encapsulated_details(IQ)} of
|
||||||
{{ok, Access}, {ok, EncapType, EncapNs, EncapFrom, EncIq}}
|
{{ok, Access}, {ok, EncapType, EncapNs, EncapFrom, EncIq}}
|
||||||
when (EncapType == Type) and ((EncapFrom == undefined) or (EncapFrom == To)) ->
|
when (EncapType == Type) and ((EncapFrom == undefined) or (EncapFrom == To)) ->
|
||||||
NsPermissions = proplists:get_value(iq, Access, none),
|
NsPermissions = proplists:get_value(iq, Access, []),
|
||||||
Permission =
|
Permission =
|
||||||
case lists:keyfind(EncapNs, 2, NsPermissions) of
|
case lists:keyfind(EncapNs, 2, NsPermissions) of
|
||||||
#privilege_namespace{type = AllowedType} ->
|
#privilege_namespace{type = AllowedType} ->
|
||||||
@ -306,6 +306,16 @@ component_send_packet({#iq{from = From,
|
|||||||
?INFO_MSG("IQ not forwarded: The FROM attribute in the encapsulated "
|
?INFO_MSG("IQ not forwarded: The FROM attribute in the encapsulated "
|
||||||
"IQ stanza and the TO in top-level IQ stanza do not match",
|
"IQ stanza and the TO in top-level IQ stanza do not match",
|
||||||
[]),
|
[]),
|
||||||
|
drop;
|
||||||
|
{_, {error, no_privileged_iq, _Err}} ->
|
||||||
|
?INFO_MSG("IQ not forwarded: Component tried to send not wrapped IQ stanza.",
|
||||||
|
[]),
|
||||||
|
drop;
|
||||||
|
{_, {error, roster_query, _Err}} ->
|
||||||
|
IQ;
|
||||||
|
{_, {error, Type, _Err}} ->
|
||||||
|
?INFO_MSG("IQ not forwarded: Component tried to send not valid IQ stanza: ~p.",
|
||||||
|
[Type]),
|
||||||
drop
|
drop
|
||||||
end,
|
end,
|
||||||
{Result, State};
|
{Result, State};
|
||||||
@ -557,8 +567,8 @@ forward_message(#message{to = To} = Msg) ->
|
|||||||
%% @format-begin
|
%% @format-begin
|
||||||
|
|
||||||
-spec get_iq_encapsulated_details(iq()) ->
|
-spec get_iq_encapsulated_details(iq()) ->
|
||||||
{ok, set | get, binary(), jid(), iq()} |
|
{ok, iq_type(), binary(), jid(), iq()} |
|
||||||
{error, Why :: atom(), any(), iq()}.
|
{error, Why :: atom(), stanza_error()}.
|
||||||
get_iq_encapsulated_details(#iq{sub_els = [IqSub]} = Msg) ->
|
get_iq_encapsulated_details(#iq{sub_els = [IqSub]} = Msg) ->
|
||||||
Lang = xmpp:get_lang(Msg),
|
Lang = xmpp:get_lang(Msg),
|
||||||
try xmpp:try_subtag(Msg, #privileged_iq{}) of
|
try xmpp:try_subtag(Msg, #privileged_iq{}) of
|
||||||
@ -568,9 +578,19 @@ get_iq_encapsulated_details(#iq{sub_els = [IqSub]} = Msg) ->
|
|||||||
Ns = xmpp:get_ns(Element),
|
Ns = xmpp:get_ns(Element),
|
||||||
{ok, EncapsulatedType, Ns, From, EncIq};
|
{ok, EncapsulatedType, Ns, From, EncIq};
|
||||||
_ ->
|
_ ->
|
||||||
Txt = ?T("No <privileged_iq/> element found"),
|
try xmpp:try_subtag(Msg, #roster_query{}) of
|
||||||
Err = xmpp:err_bad_request(Txt, Lang),
|
#roster_query{} ->
|
||||||
{error, no_privileged_iq, Err}
|
{error, roster_query, xmpp:err_bad_request()};
|
||||||
|
_ ->
|
||||||
|
Txt = ?T("No <privileged_iq/> element found"),
|
||||||
|
Err = xmpp:err_bad_request(Txt, Lang),
|
||||||
|
{error, no_privileged_iq, Err}
|
||||||
|
catch
|
||||||
|
_:{xmpp_codec, Why} ->
|
||||||
|
Txt = xmpp:io_format_error(Why),
|
||||||
|
Err = xmpp:err_bad_request(Txt, Lang),
|
||||||
|
{error, codec_error, Err}
|
||||||
|
end
|
||||||
catch
|
catch
|
||||||
_:{xmpp_codec, Why} ->
|
_:{xmpp_codec, Why} ->
|
||||||
Txt = xmpp:io_format_error(Why),
|
Txt = xmpp:io_format_error(Why),
|
||||||
|
Loading…
Reference in New Issue
Block a user