diff --git a/ChangeLog b/ChangeLog index ee33d6557..763974dc2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,9 @@ * src/ejabberd_c2s.erl (handle_sync_event/4): Remove a remaining jlib:jid_remove_resource/1 call. + * src/ejabberd_auth_internal.erl: Replace jlib:*prep/1 by + exmpp_stringprep:*prep/1 and change the error handling. + 2008-10-09 Jean-Sébastien Pédron * src/ejabberd_c2s.erl: Fix handling of unauthenticated stanzas which diff --git a/src/ejabberd_auth_internal.erl b/src/ejabberd_auth_internal.erl index cec18b319..1abc9f77c 100644 --- a/src/ejabberd_auth_internal.erl +++ b/src/ejabberd_auth_internal.erl @@ -207,71 +207,96 @@ get_vh_registered_users_number(Server, _) -> get_vh_registered_users_number(Server). get_password(User, Server) -> - LUser = jlib:nodeprep(User), - LServer = jlib:nameprep(Server), - US = {LUser, LServer}, - case catch mnesia:dirty_read(passwd, US) of - [#passwd{password = Password}] -> - Password; + try + LUser = exmpp_stringprep:nodeprep(User), + LServer = exmpp_stringprep:nameprep(Server), + US = {LUser, LServer}, + case catch mnesia:dirty_read(passwd, US) of + [#passwd{password = Password}] -> + Password; + _ -> + false + end + catch _ -> false end. get_password_s(User, Server) -> - LUser = jlib:nodeprep(User), - LServer = jlib:nameprep(Server), - US = {LUser, LServer}, - case catch mnesia:dirty_read(passwd, US) of - [#passwd{password = Password}] -> - Password; + try + LUser = exmpp_stringprep:nodeprep(User), + LServer = exmpp_stringprep:nameprep(Server), + US = {LUser, LServer}, + case catch mnesia:dirty_read(passwd, US) of + [#passwd{password = Password}] -> + Password; + _ -> + [] + end + catch _ -> [] end. is_user_exists(User, Server) -> - LUser = jlib:nodeprep(User), - LServer = jlib:nameprep(Server), - US = {LUser, LServer}, - case catch mnesia:dirty_read({passwd, US}) of - [] -> - false; - [_] -> - true; + try + LUser = exmpp_stringprep:nodeprep(User), + LServer = exmpp_stringprep:nameprep(Server), + US = {LUser, LServer}, + case catch mnesia:dirty_read({passwd, US}) of + [] -> + false; + [_] -> + true; + _ -> + false + end + catch _ -> false end. remove_user(User, Server) -> - LUser = jlib:nodeprep(User), - LServer = jlib:nameprep(Server), - US = {LUser, LServer}, - F = fun() -> - mnesia:delete({passwd, US}) - end, - mnesia:transaction(F), - ejabberd_hooks:run(remove_user, LServer, [User, Server]). + try + LUser = exmpp_stringprep:nodeprep(User), + LServer = exmpp_stringprep:nameprep(Server), + US = {LUser, LServer}, + F = fun() -> + mnesia:delete({passwd, US}) + end, + mnesia:transaction(F), + ejabberd_hooks:run(remove_user, LServer, [User, Server]) + catch + _ -> + ok + end. remove_user(User, Server, Password) -> - LUser = jlib:nodeprep(User), - LServer = jlib:nameprep(Server), - US = {LUser, LServer}, - F = fun() -> - case mnesia:read({passwd, US}) of - [#passwd{password = Password}] -> - mnesia:delete({passwd, US}), - ok; - [_] -> - not_allowed; - _ -> - not_exists - end - end, - case mnesia:transaction(F) of - {atomic, ok} -> - ejabberd_hooks:run(remove_user, LServer, [User, Server]), - ok; - {atomic, Res} -> - Res; + try + LUser = exmpp_stringprep:nodeprep(User), + LServer = exmpp_stringprep:nameprep(Server), + US = {LUser, LServer}, + F = fun() -> + case mnesia:read({passwd, US}) of + [#passwd{password = Password}] -> + mnesia:delete({passwd, US}), + ok; + [_] -> + not_allowed; + _ -> + not_exists + end + end, + case mnesia:transaction(F) of + {atomic, ok} -> + ejabberd_hooks:run(remove_user, LServer, [User, Server]), + ok; + {atomic, Res} -> + Res; + _ -> + bad_request + end + catch _ -> bad_request end.