* src/ejabberd_auth.erl: Minor change in check_password/4

* src/mod_roster.erl: Workaround for PSI bug with roster

SVN Revision: 161
This commit is contained in:
Alexey Shchepin 2003-10-27 19:35:03 +00:00
parent f4d2844be6
commit e5609f565a
5 changed files with 59 additions and 29 deletions

View File

@ -1,5 +1,9 @@
2003-10-27 Alexey Shchepin <alexey@sevcom.net> 2003-10-27 Alexey Shchepin <alexey@sevcom.net>
* src/ejabberd_auth.erl: Minor change in check_password/4
* src/mod_roster.erl: Workaround for PSI bug with roster
* src/ejabberd_logger_h.erl: Added support for log rotation * src/ejabberd_logger_h.erl: Added support for log rotation
2003-10-24 Alexey Shchepin <alexey@sevcom.net> 2003-10-24 Alexey Shchepin <alexey@sevcom.net>

4
TODO
View File

@ -5,7 +5,6 @@ admin interface
node management node management
node restart/shutdown node restart/shutdown
statistics about memory usage statistics about memory usage
backup management
S2S: S2S:
rewrite S2S key validation rewrite S2S key validation
@ -13,11 +12,8 @@ S2S:
more correctly work with SRV DNS records (priority, weight, etc...) more correctly work with SRV DNS records (priority, weight, etc...)
TLS TLS
Privacy rules
make roster set to work in one transaction make roster set to work in one transaction
add traffic shapers to c2s connection before authentification add traffic shapers to c2s connection before authentification
add traffic shapers to s2s connections add traffic shapers to s2s connections
more traffic shapers more traffic shapers
SNMP SNMP
MUC: remove a lot of debugging output
iq:last

View File

@ -70,7 +70,7 @@ init([]) ->
%% {stop, Reason, Reply, State} | (terminate/2 is called) %% {stop, Reason, Reply, State} | (terminate/2 is called)
%% {stop, Reason, State} (terminate/2 is called) %% {stop, Reason, State} (terminate/2 is called)
%%---------------------------------------------------------------------- %%----------------------------------------------------------------------
handle_call(Request, From, State) -> handle_call(_Request, _From, State) ->
Reply = ok, Reply = ok,
{reply, Reply, State}. {reply, Reply, State}.
@ -80,11 +80,11 @@ handle_call(Request, From, State) ->
%% {noreply, State, Timeout} | %% {noreply, State, Timeout} |
%% {stop, Reason, State} (terminate/2 is called) %% {stop, Reason, State} (terminate/2 is called)
%%---------------------------------------------------------------------- %%----------------------------------------------------------------------
handle_cast(Msg, State) -> handle_cast(_Msg, State) ->
{noreply, State}. {noreply, State}.
code_change(OldVsn, State, Extra) -> code_change(_OldVsn, State, _Extra) ->
{ok, State}. {ok, State}.
%%---------------------------------------------------------------------- %%----------------------------------------------------------------------
@ -93,7 +93,7 @@ code_change(OldVsn, State, Extra) ->
%% {noreply, State, Timeout} | %% {noreply, State, Timeout} |
%% {stop, Reason, State} (terminate/2 is called) %% {stop, Reason, State} (terminate/2 is called)
%%---------------------------------------------------------------------- %%----------------------------------------------------------------------
handle_info(Info, State) -> handle_info(_Info, State) ->
{noreply, State}. {noreply, State}.
%%---------------------------------------------------------------------- %%----------------------------------------------------------------------
@ -101,7 +101,7 @@ handle_info(Info, State) ->
%% Purpose: Shutdown the server %% Purpose: Shutdown the server
%% Returns: any (ignored by gen_server) %% Returns: any (ignored by gen_server)
%%---------------------------------------------------------------------- %%----------------------------------------------------------------------
terminate(Reason, State) -> terminate(_Reason, _State) ->
ok. ok.
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
@ -119,14 +119,8 @@ check_password(User, Password) ->
check_password(User, Password, StreamID, Digest) -> check_password(User, Password, StreamID, Digest) ->
LUser = jlib:nodeprep(User), LUser = jlib:nodeprep(User),
F = fun() -> case catch mnesia:dirty_read({passwd, LUser}) of
case mnesia:read({passwd, LUser}) of [#passwd{password = Passwd}] ->
[E] ->
E#passwd.password
end
end,
case mnesia:transaction(F) of
{atomic, Passwd} ->
DigRes = if DigRes = if
Digest /= "" -> Digest /= "" ->
Digest == sha:sha(StreamID ++ Passwd); Digest == sha:sha(StreamID ++ Passwd);
@ -164,7 +158,7 @@ try_register(User, Password) ->
mnesia:write(#passwd{user = LUser, mnesia:write(#passwd{user = LUser,
password = Password}), password = Password}),
ok; ok;
[E] -> [_E] ->
exists exists
end end
end, end,

View File

@ -64,7 +64,7 @@ handle_call(_Request, State) ->
%%---------------------------------------------------------------------- %%----------------------------------------------------------------------
handle_info({'EXIT', _Fd, _Reason}, _State) -> handle_info({'EXIT', _Fd, _Reason}, _State) ->
remove_handler; remove_handler;
handle_info({emulator, GL, reopen}, State) -> handle_info({emulator, _GL, reopen}, State) ->
file:close(State#state.fd), file:close(State#state.fd),
case file:open(State#state.file, [append]) of case file:open(State#state.file, [append]) of
{ok, Fd} -> {ok, Fd} ->

View File

@ -44,8 +44,28 @@ start(Opts) ->
gen_iq_handler:add_iq_handler(ejabberd_sm, ?NS_ROSTER, gen_iq_handler:add_iq_handler(ejabberd_sm, ?NS_ROSTER,
?MODULE, process_iq, IQDisc). ?MODULE, process_iq, IQDisc).
-define(PSI_ROSTER_WORKAROUND, true).
-ifdef(PSI_ROSTER_WORKAROUND).
process_iq(From, To, IQ) -> process_iq(From, To, IQ) ->
{iq, ID, Type, XMLNS, SubEl} = IQ, {iq, ID, _Type, XMLNS, SubEl} = IQ,
#jid{lserver = LServer} = From,
case ?MYNAME of
LServer ->
ResIQ = process_local_iq(From, To, IQ),
ejabberd_router:route(From, From,
jlib:iq_to_xml(ResIQ)),
ignore;
_ ->
{iq, ID, error, XMLNS,
[SubEl, ?ERR_ITEM_NOT_FOUND]}
end.
-else.
process_iq(From, To, IQ) ->
{iq, ID, _Type, XMLNS, SubEl} = IQ,
#jid{lserver = LServer} = From, #jid{lserver = LServer} = From,
case ?MYNAME of case ?MYNAME of
LServer -> LServer ->
@ -55,6 +75,7 @@ process_iq(From, To, IQ) ->
[SubEl, ?ERR_ITEM_NOT_FOUND]} [SubEl, ?ERR_ITEM_NOT_FOUND]}
end. end.
-endif.
process_local_iq(From, To, {iq, _, Type, _, _} = IQ) -> process_local_iq(From, To, {iq, _, Type, _, _} = IQ) ->
case Type of case Type of
@ -66,7 +87,7 @@ process_local_iq(From, To, {iq, _, Type, _, _} = IQ) ->
process_iq_get(From, To, {iq, ID, Type, XMLNS, SubEl}) -> process_iq_get(From, _To, {iq, ID, _Type, XMLNS, SubEl}) ->
#jid{luser = LUser} = From, #jid{luser = LUser} = From,
F = fun() -> F = fun() ->
mnesia:index_read(roster, LUser, #roster.user) mnesia:index_read(roster, LUser, #roster.user)
@ -118,12 +139,12 @@ item_to_xml(Item) ->
{xmlelement, "item", Attrs, SubEls}. {xmlelement, "item", Attrs, SubEls}.
process_iq_set(From, To, {iq, ID, Type, XMLNS, SubEl}) -> process_iq_set(From, To, {iq, ID, _Type, XMLNS, SubEl}) ->
{xmlelement, Name, Attrs, Els} = SubEl, {xmlelement, _Name, _Attrs, Els} = SubEl,
lists:foreach(fun(El) -> process_item_set(From, To, El) end, Els), lists:foreach(fun(El) -> process_item_set(From, To, El) end, Els),
{iq, ID, result, XMLNS, []}. {iq, ID, result, XMLNS, []}.
process_item_set(From, To, {xmlelement, Name, Attrs, Els} = XItem) -> process_item_set(From, To, {xmlelement, _Name, Attrs, Els}) ->
JID1 = jlib:string_to_jid(xml:get_attr_s("jid", Attrs)), JID1 = jlib:string_to_jid(xml:get_attr_s("jid", Attrs)),
#jid{user = User, luser = LUser} = From, #jid{user = User, luser = LUser} = From,
case JID1 of case JID1 of
@ -197,7 +218,7 @@ process_item_set(From, To, {xmlelement, Name, Attrs, Els} = XItem) ->
ok ok
end end
end; end;
process_item_set(From, To, _) -> process_item_set(_From, _To, _) ->
ok. ok.
process_item_attrs(Item, [{Attr, Val} | Attrs]) -> process_item_attrs(Item, [{Attr, Val} | Attrs]) ->
@ -264,6 +285,20 @@ push_item(User, From, Item) ->
end, ejabberd_sm:get_user_resources(User)). end, ejabberd_sm:get_user_resources(User)).
% TODO: don't push to those who not load roster % TODO: don't push to those who not load roster
-ifdef(PSI_ROSTER_WORKAROUND).
push_item(User, Resource, From, Item) ->
ResIQ = {iq, "", set, ?NS_ROSTER,
[{xmlelement, "query",
[{"xmlns", ?NS_ROSTER}],
[item_to_xml(Item)]}]},
ejabberd_router ! {route,
jlib:make_jid(User, ?MYNAME, Resource),
jlib:make_jid(User, ?MYNAME, Resource),
jlib:iq_to_xml(ResIQ)}.
-else.
push_item(User, Resource, From, Item) -> push_item(User, Resource, From, Item) ->
ResIQ = {iq, "", set, ?NS_ROSTER, ResIQ = {iq, "", set, ?NS_ROSTER,
[{xmlelement, "query", [{xmlelement, "query",
@ -274,6 +309,7 @@ push_item(User, Resource, From, Item) ->
jlib:make_jid(User, ?MYNAME, Resource), jlib:make_jid(User, ?MYNAME, Resource),
jlib:iq_to_xml(ResIQ)}. jlib:iq_to_xml(ResIQ)}.
-endif.
get_subscription_lists(User) -> get_subscription_lists(User) ->
LUser = jlib:nodeprep(User), LUser = jlib:nodeprep(User),
@ -322,7 +358,7 @@ in_subscription(User, From, Type) ->
From#jid.resource}, From#jid.resource},
NewItem = #roster{uj = {LUser, LFrom}, NewItem = #roster{uj = {LUser, LFrom},
user = LUser, user = LUser,
jid = From}, jid = JID},
mnesia:write(NewItem), mnesia:write(NewItem),
true true
end; end;
@ -485,14 +521,14 @@ remove_user(User) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
set_items(User, SubEl) -> set_items(User, SubEl) ->
{xmlelement, Name, Attrs, Els} = SubEl, {xmlelement, _Name, _Attrs, Els} = SubEl,
LUser = jlib:nodeprep(User), LUser = jlib:nodeprep(User),
F = fun() -> F = fun() ->
lists:foreach(fun(El) -> process_item_set_t(LUser, El) end, Els) lists:foreach(fun(El) -> process_item_set_t(LUser, El) end, Els)
end, end,
mnesia:transaction(F). mnesia:transaction(F).
process_item_set_t(LUser, {xmlelement, Name, Attrs, Els} = XItem) -> process_item_set_t(LUser, {xmlelement, _Name, Attrs, Els}) ->
JID1 = jlib:string_to_jid(xml:get_attr_s("jid", Attrs)), JID1 = jlib:string_to_jid(xml:get_attr_s("jid", Attrs)),
case JID1 of case JID1 of
error -> error ->
@ -512,7 +548,7 @@ process_item_set_t(LUser, {xmlelement, Name, Attrs, Els} = XItem) ->
mnesia:write(Item2) mnesia:write(Item2)
end end
end; end;
process_item_set_t(LUser, _) -> process_item_set_t(_LUser, _) ->
ok. ok.
process_item_attrs_ws(Item, [{Attr, Val} | Attrs]) -> process_item_attrs_ws(Item, [{Attr, Val} | Attrs]) ->