aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ejabberd_app.erl2
-rw-r--r--src/ejabberd_c2s.erl157
-rw-r--r--src/mod_privacy.erl5
-rw-r--r--src/mod_roster.erl14
-rw-r--r--src/stringprep/stringprep_drv.c1
5 files changed, 140 insertions, 39 deletions
diff --git a/src/ejabberd_app.erl b/src/ejabberd_app.erl
index c9ae60e49..535c9d7e0 100644
--- a/src/ejabberd_app.erl
+++ b/src/ejabberd_app.erl
@@ -50,7 +50,7 @@ init() ->
register(ejabberd, self()),
%erlang:system_flag(fullsweep_after, 0),
error_logger:logfile({open, ?LOG_PATH}),
- timer:apply_interval(3600000, ?MODULE, dump_ports, []),
+ %timer:apply_interval(3600000, ?MODULE, dump_ports, []),
ok = erl_ddll:load_driver(".", expat_erl),
Port = open_port({spawn, expat_erl}, [binary]),
loop(Port).
diff --git a/src/ejabberd_c2s.erl b/src/ejabberd_c2s.erl
index b18b02d6a..66e0eb146 100644
--- a/src/ejabberd_c2s.erl
+++ b/src/ejabberd_c2s.erl
@@ -499,9 +499,14 @@ session_established({xmlstreamelement, El}, StateData) ->
NewState =
case ToJID of
error ->
- Err = jlib:make_error_reply(El, ?ERR_JID_MALFORMED),
- send_element(StateData, Err),
- StateData;
+ case xml:get_attr_s("type", Attrs) of
+ "error" -> StateData;
+ "result" -> StateData;
+ _ ->
+ Err = jlib:make_error_reply(El, ?ERR_JID_MALFORMED),
+ send_element(StateData, Err),
+ StateData
+ end;
_ ->
case Name of
"presence" ->
@@ -627,7 +632,22 @@ handle_info({route, From, To, Packet}, StateName, StateData) ->
"unsubscribed" ->
{true, Attrs, StateData};
_ ->
- {true, Attrs, StateData}
+%-ifdef(PRIVACY_SUPPORT).
+ case catch mod_privacy:check_packet(
+ StateData#state.user,
+ StateData#state.privacy_list,
+ {From, To, Packet},
+ in) of
+ {'EXIT', _Reason} ->
+ {true, Attrs, StateData};
+ allow ->
+ {true, Attrs, StateData};
+ deny ->
+ {false, Attrs, StateData}
+ end
+%-elseif.
+% {true, Attrs, StateData}
+%-endif.
end;
"broadcast" ->
?DEBUG("broadcast~n~p~n", [Els]),
@@ -732,8 +752,8 @@ terminate(Reason, StateName, StateData) ->
Packet = {xmlelement, "presence", [{"type", "unavailable"}], []},
ejabberd_sm:unset_presence(StateData#state.user,
StateData#state.resource),
- presence_broadcast(From, StateData#state.pres_a, Packet),
- presence_broadcast(From, StateData#state.pres_i, Packet)
+ presence_broadcast(StateData, From, StateData#state.pres_a, Packet),
+ presence_broadcast(StateData, From, StateData#state.pres_i, Packet)
end,
(StateData#state.sockmod):close(StateData#state.socket),
ok.
@@ -842,8 +862,21 @@ process_presence_probe(From, To, StateData) ->
and ?SETS:is_element(LFrom, StateData#state.pres_a),
if
Cond1 ->
- ejabberd_router:route(To, From,
- StateData#state.pres_last);
+ Packet = StateData#state.pres_last,
+%-ifdef(PRIVACY_SUPPORT).
+ case catch mod_privacy:check_packet(
+ StateData#state.user,
+ StateData#state.privacy_list,
+ {To, From, Packet},
+ out) of
+ deny ->
+ ok;
+ _ ->
+%-endif.
+ ejabberd_router:route(To, From, Packet)
+%-ifdef(PRIVACY_SUPPORT).
+ end;
+%-endif.
Cond2 ->
ejabberd_router:route(To, From,
{xmlelement, "presence",
@@ -860,8 +893,8 @@ presence_update(From, Packet, StateData) ->
"unavailable" ->
ejabberd_sm:unset_presence(StateData#state.user,
StateData#state.resource),
- presence_broadcast(From, StateData#state.pres_a, Packet),
- presence_broadcast(From, StateData#state.pres_i, Packet),
+ presence_broadcast(StateData, From, StateData#state.pres_a, Packet),
+ presence_broadcast(StateData, From, StateData#state.pres_i, Packet),
StateData#state{pres_last = undefined,
pres_a = ?SETS:new(),
pres_i = ?SETS:new(),
@@ -870,9 +903,11 @@ presence_update(From, Packet, StateData) ->
NewState =
if
not StateData#state.pres_invis ->
- presence_broadcast(From, StateData#state.pres_a,
+ presence_broadcast(StateData, From,
+ StateData#state.pres_a,
Packet),
- presence_broadcast(From, StateData#state.pres_i,
+ presence_broadcast(StateData, From,
+ StateData#state.pres_i,
Packet),
S1 = StateData#state{pres_last = undefined,
pres_a = ?SETS:new(),
@@ -910,7 +945,8 @@ presence_update(From, Packet, StateData) ->
pres_invis = false
}, Packet);
true ->
- presence_broadcast_to_trusted(From,
+ presence_broadcast_to_trusted(StateData,
+ From,
StateData#state.pres_f,
StateData#state.pres_a,
Packet),
@@ -958,29 +994,69 @@ presence_track(From, To, Packet, StateData) ->
ejabberd_router:route(From, To, Packet),
StateData;
_ ->
- ejabberd_router:route(From, To, Packet),
+%-ifdef(PRIVACY_SUPPORT).
+ case catch mod_privacy:check_packet(
+ StateData#state.user,
+ StateData#state.privacy_list,
+ {From, To, Packet},
+ out) of
+ deny ->
+ ok;
+ _ ->
+%-endif.
+ ejabberd_router:route(From, To, Packet)
+%-ifdef(PRIVACY_SUPPORT).
+ end,
+%-endif.
I = remove_element(LTo, StateData#state.pres_i),
A = ?SETS:add_element(LTo, StateData#state.pres_a),
StateData#state{pres_i = I,
pres_a = A}
end.
-presence_broadcast(From, JIDSet, Packet) ->
+presence_broadcast(StateData, From, JIDSet, Packet) ->
lists:foreach(fun(JID) ->
- ejabberd_router:route(
- From, jlib:make_jid(JID), Packet)
- end, ?SETS:to_list(JIDSet)).
-
-presence_broadcast_to_trusted(From, T, A, Packet) ->
- lists:foreach(fun(JID) ->
- case ?SETS:is_element(JID, T) of
- true ->
- ejabberd_router:route(
- From, jlib:make_jid(JID), Packet);
+ FJID = jlib:make_jid(JID),
+%-ifdef(PRIVACY_SUPPORT).
+ case catch mod_privacy:check_packet(
+ StateData#state.user,
+ StateData#state.privacy_list,
+ {From, FJID, Packet},
+ out) of
+ deny ->
+ ok;
_ ->
- ok
+%-endif.
+ ejabberd_router:route(From, FJID, Packet)
+%-ifdef(PRIVACY_SUPPORT).
end
- end, ?SETS:to_list(A)).
+%-endif.
+ end, ?SETS:to_list(JIDSet)).
+
+presence_broadcast_to_trusted(StateData, From, T, A, Packet) ->
+ lists:foreach(
+ fun(JID) ->
+ case ?SETS:is_element(JID, T) of
+ true ->
+ FJID = jlib:make_jid(JID),
+%-ifdef(PRIVACY_SUPPORT).
+ case catch mod_privacy:check_packet(
+ StateData#state.user,
+ StateData#state.privacy_list,
+ {From, FJID, Packet},
+ out) of
+ deny ->
+ ok;
+ _ ->
+%-endif.
+ ejabberd_router:route(From, FJID, Packet)
+%-ifdef(PRIVACY_SUPPORT).
+ end;
+%-endif.
+ _ ->
+ ok
+ end
+ end, ?SETS:to_list(A)).
presence_broadcast_first(From, StateData, Packet) ->
@@ -999,14 +1075,27 @@ presence_broadcast_first(From, StateData, Packet) ->
StateData#state.pres_invis ->
StateData;
true ->
- As = ?SETS:fold(fun(JID, A) ->
- ejabberd_router:route(From,
- jlib:make_jid(JID),
- Packet),
- ?SETS:add_element(JID, A)
+ As = ?SETS:fold(
+ fun(JID, A) ->
+ FJID = jlib:make_jid(JID),
+%-ifdef(PRIVACY_SUPPORT).
+ case catch mod_privacy:check_packet(
+ StateData#state.user,
+ StateData#state.privacy_list,
+ {From, FJID, Packet},
+ out) of
+ deny ->
+ ok;
+ _ ->
+%-endif.
+ ejabberd_router:route(From, FJID, Packet)
+%-ifdef(PRIVACY_SUPPORT).
end,
- StateData#state.pres_a,
- StateData#state.pres_f),
+%-endif.
+ ?SETS:add_element(JID, A)
+ end,
+ StateData#state.pres_a,
+ StateData#state.pres_f),
StateData#state{pres_a = As}
end.
diff --git a/src/mod_privacy.erl b/src/mod_privacy.erl
index c0cec14c5..31e9f99fd 100644
--- a/src/mod_privacy.erl
+++ b/src/mod_privacy.erl
@@ -445,8 +445,9 @@ parse_items([{xmlelement, "item", Attrs, SubEls} | Els], Res) ->
error ->
false;
JID ->
- I1#listitem{type = jid,
- value = JID}
+ I1#listitem{
+ type = jid,
+ value = jlib:jid_tolower(JID)}
end;
"group" ->
I1#listitem{type = group,
diff --git a/src/mod_roster.erl b/src/mod_roster.erl
index 73e77b24b..47609feaa 100644
--- a/src/mod_roster.erl
+++ b/src/mod_roster.erl
@@ -568,7 +568,19 @@ get_jid_info(User, JID) ->
[#roster{subscription = Subscription, groups = Groups}] ->
{Subscription, Groups};
_ ->
- {none, []}
+ LRJID = jlib:jid_tolower(jlib:jid_remove_resource(JID)),
+ if
+ LRJID == LJID ->
+ {none, []};
+ true ->
+ case catch mnesia:dirty_read(roster, {LUser, LRJID}) of
+ [#roster{subscription = Subscription,
+ groups = Groups}] ->
+ {Subscription, Groups};
+ _ ->
+ {none, []}
+ end
+ end
end.
diff --git a/src/stringprep/stringprep_drv.c b/src/stringprep/stringprep_drv.c
index 43dd2b87a..13aba69bc 100644
--- a/src/stringprep/stringprep_drv.c
+++ b/src/stringprep/stringprep_drv.c
@@ -3,7 +3,6 @@
#include <stdio.h>
#include <erl_driver.h>
#include <ei.h>
-#include <iconv.h>
#include "uni_data.c"
#include "uni_norm.c"