2004-12-12 22:00:34 +01:00
|
|
|
%%%----------------------------------------------------------------------
|
|
|
|
%%% File : ejabberd_auth_internal.erl
|
2007-12-24 12:41:41 +01:00
|
|
|
%%% Author : Alexey Shchepin <alexey@process-one.net>
|
2004-12-12 22:00:34 +01:00
|
|
|
%%% Purpose : Authentification via mnesia
|
2007-12-24 12:41:41 +01:00
|
|
|
%%% Created : 12 Dec 2004 by Alexey Shchepin <alexey@process-one.net>
|
|
|
|
%%%
|
|
|
|
%%%
|
2009-01-19 15:47:33 +01:00
|
|
|
%%% ejabberd, Copyright (C) 2002-2009 ProcessOne
|
2007-12-24 12:41:41 +01:00
|
|
|
%%%
|
|
|
|
%%% This program is free software; you can redistribute it and/or
|
|
|
|
%%% modify it under the terms of the GNU General Public License as
|
|
|
|
%%% published by the Free Software Foundation; either version 2 of the
|
|
|
|
%%% License, or (at your option) any later version.
|
|
|
|
%%%
|
|
|
|
%%% This program is distributed in the hope that it will be useful,
|
|
|
|
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
%%% General Public License for more details.
|
2009-01-19 15:47:33 +01:00
|
|
|
%%%
|
2007-12-24 12:41:41 +01:00
|
|
|
%%% You should have received a copy of the GNU General Public License
|
|
|
|
%%% along with this program; if not, write to the Free Software
|
|
|
|
%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
|
|
%%% 02111-1307 USA
|
|
|
|
%%%
|
2004-12-12 22:00:34 +01:00
|
|
|
%%%----------------------------------------------------------------------
|
|
|
|
|
|
|
|
-module(ejabberd_auth_internal).
|
2007-12-24 12:41:41 +01:00
|
|
|
-author('alexey@process-one.net').
|
2004-12-12 22:00:34 +01:00
|
|
|
|
|
|
|
%% External exports
|
2005-07-13 05:24:13 +02:00
|
|
|
-export([start/1,
|
2005-04-17 20:08:34 +02:00
|
|
|
set_password/3,
|
|
|
|
check_password/3,
|
|
|
|
check_password/5,
|
|
|
|
try_register/3,
|
2004-12-12 22:00:34 +01:00
|
|
|
dirty_get_registered_users/0,
|
2005-04-17 20:08:34 +02:00
|
|
|
get_vh_registered_users/1,
|
2007-11-16 14:58:00 +01:00
|
|
|
get_vh_registered_users/2,
|
|
|
|
get_vh_registered_users_number/1,
|
|
|
|
get_vh_registered_users_number/2,
|
2005-04-17 20:08:34 +02:00
|
|
|
get_password/2,
|
|
|
|
get_password_s/2,
|
|
|
|
is_user_exists/2,
|
2004-12-12 22:00:34 +01:00
|
|
|
remove_user/2,
|
2005-04-17 20:08:34 +02:00
|
|
|
remove_user/3,
|
2004-12-12 22:00:34 +01:00
|
|
|
plain_password_required/0
|
|
|
|
]).
|
|
|
|
|
2005-04-17 20:08:34 +02:00
|
|
|
-include("ejabberd.hrl").
|
|
|
|
|
|
|
|
-record(passwd, {us, password}).
|
2004-12-12 22:00:34 +01:00
|
|
|
|
|
|
|
%%%----------------------------------------------------------------------
|
|
|
|
%%% API
|
|
|
|
%%%----------------------------------------------------------------------
|
2009-02-05 12:13:01 +01:00
|
|
|
|
|
|
|
%% @spec (Host) -> ok
|
|
|
|
%% Host = string()
|
|
|
|
|
2008-10-13 12:11:19 +02:00
|
|
|
start(_Host) ->
|
2005-04-17 20:08:34 +02:00
|
|
|
mnesia:create_table(passwd, [{disc_copies, [node()]},
|
|
|
|
{attributes, record_info(fields, passwd)}]),
|
|
|
|
update_table(),
|
2004-12-12 22:00:34 +01:00
|
|
|
ok.
|
|
|
|
|
2009-02-05 12:13:01 +01:00
|
|
|
%% @spec () -> bool()
|
|
|
|
|
2004-12-12 22:00:34 +01:00
|
|
|
plain_password_required() ->
|
|
|
|
false.
|
|
|
|
|
2009-02-05 12:13:01 +01:00
|
|
|
%% @spec (User, Server, Password) -> bool()
|
|
|
|
%% User = string()
|
|
|
|
%% Server = string()
|
|
|
|
%% Password = string()
|
|
|
|
|
2005-04-17 20:08:34 +02:00
|
|
|
check_password(User, Server, Password) ->
|
2008-07-09 11:16:03 +02:00
|
|
|
LUser = exmpp_stringprep:nodeprep(User),
|
|
|
|
LServer = exmpp_stringprep:nameprep(Server),
|
2005-04-17 20:08:34 +02:00
|
|
|
US = {LUser, LServer},
|
|
|
|
case catch mnesia:dirty_read({passwd, US}) of
|
2004-12-12 22:00:34 +01:00
|
|
|
[#passwd{password = Password}] ->
|
2008-02-11 19:19:42 +01:00
|
|
|
Password /= "";
|
2004-12-12 22:00:34 +01:00
|
|
|
_ ->
|
|
|
|
false
|
|
|
|
end.
|
|
|
|
|
2009-04-22 13:44:03 +02:00
|
|
|
%% @spec (User, Server, Password, Digest, DigestGen) -> bool()
|
2009-02-05 12:13:01 +01:00
|
|
|
%% User = string()
|
|
|
|
%% Server = string()
|
|
|
|
%% Password = string()
|
|
|
|
%% Digest = string()
|
2009-04-22 13:44:03 +02:00
|
|
|
%% DigestGen = function()
|
2009-02-05 12:13:01 +01:00
|
|
|
|
2009-04-22 13:44:03 +02:00
|
|
|
check_password(User, Server, Password, Digest, DigestGen) ->
|
2008-07-09 11:16:03 +02:00
|
|
|
LUser = exmpp_stringprep:nodeprep(User),
|
|
|
|
LServer = exmpp_stringprep:nameprep(Server),
|
2005-04-17 20:08:34 +02:00
|
|
|
US = {LUser, LServer},
|
|
|
|
case catch mnesia:dirty_read({passwd, US}) of
|
2004-12-12 22:00:34 +01:00
|
|
|
[#passwd{password = Passwd}] ->
|
|
|
|
DigRes = if
|
|
|
|
Digest /= "" ->
|
2009-04-22 13:44:03 +02:00
|
|
|
Digest == DigestGen(Passwd);
|
2004-12-12 22:00:34 +01:00
|
|
|
true ->
|
|
|
|
false
|
|
|
|
end,
|
|
|
|
if DigRes ->
|
|
|
|
true;
|
|
|
|
true ->
|
|
|
|
(Passwd == Password) and (Password /= "")
|
|
|
|
end;
|
|
|
|
_ ->
|
|
|
|
false
|
|
|
|
end.
|
|
|
|
|
2009-02-05 12:13:01 +01:00
|
|
|
%% @spec (User, Server, Password) -> ok | {error, invalid_jid}
|
|
|
|
%% User = string()
|
|
|
|
%% Server = string()
|
|
|
|
%% Password = string()
|
|
|
|
|
2005-04-17 20:08:34 +02:00
|
|
|
set_password(User, Server, Password) ->
|
2008-07-09 11:16:03 +02:00
|
|
|
LUser = exmpp_stringprep:nodeprep(User),
|
|
|
|
LServer = exmpp_stringprep:nameprep(Server),
|
2005-04-17 20:08:34 +02:00
|
|
|
US = {LUser, LServer},
|
|
|
|
if
|
|
|
|
(LUser == error) or (LServer == error) ->
|
|
|
|
{error, invalid_jid};
|
|
|
|
true ->
|
2004-12-12 22:00:34 +01:00
|
|
|
F = fun() ->
|
2005-04-17 20:08:34 +02:00
|
|
|
mnesia:write(#passwd{us = US,
|
2004-12-12 22:00:34 +01:00
|
|
|
password = Password})
|
|
|
|
end,
|
2008-09-16 16:39:57 +02:00
|
|
|
{atomic, ok} = mnesia:transaction(F),
|
|
|
|
ok
|
2004-12-12 22:00:34 +01:00
|
|
|
end.
|
|
|
|
|
2009-01-19 11:14:04 +01:00
|
|
|
%% @spec (User, Server, Password) -> {atomic, ok} | {atomic, exists} | {error, invalid_jid} | {aborted, Reason}
|
2009-02-05 12:13:01 +01:00
|
|
|
%% User = string()
|
|
|
|
%% Server = string()
|
|
|
|
%% Password = string()
|
|
|
|
|
2005-04-17 20:08:34 +02:00
|
|
|
try_register(User, Server, Password) ->
|
2008-07-09 11:16:03 +02:00
|
|
|
LUser = exmpp_stringprep:nodeprep(User),
|
|
|
|
LServer = exmpp_stringprep:nameprep(Server),
|
2005-04-17 20:08:34 +02:00
|
|
|
US = {LUser, LServer},
|
|
|
|
if
|
|
|
|
(LUser == error) or (LServer == error) ->
|
|
|
|
{error, invalid_jid};
|
|
|
|
true ->
|
2004-12-12 22:00:34 +01:00
|
|
|
F = fun() ->
|
2005-04-17 20:08:34 +02:00
|
|
|
case mnesia:read({passwd, US}) of
|
2004-12-12 22:00:34 +01:00
|
|
|
[] ->
|
2005-04-17 20:08:34 +02:00
|
|
|
mnesia:write(#passwd{us = US,
|
2004-12-12 22:00:34 +01:00
|
|
|
password = Password}),
|
|
|
|
ok;
|
|
|
|
[_E] ->
|
|
|
|
exists
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
mnesia:transaction(F)
|
|
|
|
end.
|
|
|
|
|
2009-02-05 12:13:01 +01:00
|
|
|
%% @spec () -> [{LUser, LServer}]
|
|
|
|
%% LUser = string()
|
|
|
|
%% LServer = string()
|
|
|
|
%% @doc Get all registered users in Mnesia.
|
|
|
|
|
2004-12-12 22:00:34 +01:00
|
|
|
dirty_get_registered_users() ->
|
|
|
|
mnesia:dirty_all_keys(passwd).
|
|
|
|
|
2009-02-05 12:13:01 +01:00
|
|
|
%% @spec (Server) -> [{LUser, LServer}]
|
|
|
|
%% Server = string()
|
|
|
|
%% LUser = string()
|
|
|
|
%% LServer = string()
|
|
|
|
|
2005-04-17 20:08:34 +02:00
|
|
|
get_vh_registered_users(Server) ->
|
2008-07-09 11:16:03 +02:00
|
|
|
LServer = exmpp_stringprep:nameprep(Server),
|
2005-04-17 20:08:34 +02:00
|
|
|
mnesia:dirty_select(
|
|
|
|
passwd,
|
2007-11-16 14:58:00 +01:00
|
|
|
[{#passwd{us = '$1', _ = '_'},
|
|
|
|
[{'==', {element, 2, '$1'}, LServer}],
|
2005-04-17 20:08:34 +02:00
|
|
|
['$1']}]).
|
|
|
|
|
2009-02-05 12:13:01 +01:00
|
|
|
%% @spec (Server, Opts) -> [{LUser, LServer}]
|
|
|
|
%% Server = string()
|
|
|
|
%% Opts = [{Opt, Val}]
|
|
|
|
%% Opt = atom()
|
|
|
|
%% Val = term()
|
|
|
|
%% LUser = string()
|
|
|
|
%% LServer = string()
|
|
|
|
%% @doc Return the registered users for the specified host.
|
|
|
|
%%
|
|
|
|
%% `Opts' can be one of the following:
|
|
|
|
%% <ul>
|
|
|
|
%% <li>`[{from, integer()}, {to, integer()}]'</li>
|
|
|
|
%% <li>`[{limit, integer()}, {offset, integer()}]'</li>
|
|
|
|
%% <li>`[{prefix, string()}]'</li>
|
|
|
|
%% <li>`[{prefix, string()}, {from, integer()}, {to, integer()}]'</li>
|
|
|
|
%% <li>`[{prefix, string()}, {limit, integer()}, {offset, integer()}]'</li>
|
|
|
|
%% </ul>
|
|
|
|
|
2007-11-16 14:58:00 +01:00
|
|
|
get_vh_registered_users(Server, [{from, Start}, {to, End}])
|
|
|
|
when is_integer(Start) and is_integer(End) ->
|
|
|
|
get_vh_registered_users(Server, [{limit, End-Start+1}, {offset, Start}]);
|
|
|
|
|
|
|
|
get_vh_registered_users(Server, [{limit, Limit}, {offset, Offset}])
|
|
|
|
when is_integer(Limit) and is_integer(Offset) ->
|
|
|
|
case get_vh_registered_users(Server) of
|
|
|
|
[] ->
|
|
|
|
[];
|
|
|
|
Users ->
|
|
|
|
Set = lists:keysort(1, Users),
|
|
|
|
L = length(Set),
|
|
|
|
Start = if Offset < 1 -> 1;
|
|
|
|
Offset > L -> L;
|
|
|
|
true -> Offset
|
|
|
|
end,
|
|
|
|
lists:sublist(Set, Start, Limit)
|
|
|
|
end;
|
|
|
|
|
|
|
|
get_vh_registered_users(Server, [{prefix, Prefix}])
|
|
|
|
when is_list(Prefix) ->
|
|
|
|
Set = [{U,S} || {U, S} <- get_vh_registered_users(Server), lists:prefix(Prefix, U)],
|
|
|
|
lists:keysort(1, Set);
|
|
|
|
|
|
|
|
get_vh_registered_users(Server, [{prefix, Prefix}, {from, Start}, {to, End}])
|
|
|
|
when is_list(Prefix) and is_integer(Start) and is_integer(End) ->
|
|
|
|
get_vh_registered_users(Server, [{prefix, Prefix}, {limit, End-Start+1}, {offset, Start}]);
|
|
|
|
|
|
|
|
get_vh_registered_users(Server, [{prefix, Prefix}, {limit, Limit}, {offset, Offset}])
|
|
|
|
when is_list(Prefix) and is_integer(Limit) and is_integer(Offset) ->
|
|
|
|
case [{U,S} || {U, S} <- get_vh_registered_users(Server), lists:prefix(Prefix, U)] of
|
|
|
|
[] ->
|
|
|
|
[];
|
|
|
|
Users ->
|
|
|
|
Set = lists:keysort(1, Users),
|
|
|
|
L = length(Set),
|
|
|
|
Start = if Offset < 1 -> 1;
|
|
|
|
Offset > L -> L;
|
|
|
|
true -> Offset
|
|
|
|
end,
|
|
|
|
lists:sublist(Set, Start, Limit)
|
|
|
|
end;
|
|
|
|
|
|
|
|
get_vh_registered_users(Server, _) ->
|
|
|
|
get_vh_registered_users(Server).
|
|
|
|
|
2009-02-05 12:13:01 +01:00
|
|
|
%% @spec (Server) -> Users_Number
|
|
|
|
%% Server = string()
|
|
|
|
%% Users_Number = integer()
|
|
|
|
|
2007-11-16 14:58:00 +01:00
|
|
|
get_vh_registered_users_number(Server) ->
|
|
|
|
Set = get_vh_registered_users(Server),
|
|
|
|
length(Set).
|
|
|
|
|
2009-02-05 12:13:01 +01:00
|
|
|
%% @spec (Server, [{prefix, Prefix}]) -> Users_Number
|
|
|
|
%% Server = string()
|
|
|
|
%% Prefix = string()
|
|
|
|
%% Users_Number = integer()
|
|
|
|
|
2007-11-16 14:58:00 +01:00
|
|
|
get_vh_registered_users_number(Server, [{prefix, Prefix}]) when is_list(Prefix) ->
|
|
|
|
Set = [{U, S} || {U, S} <- get_vh_registered_users(Server), lists:prefix(Prefix, U)],
|
|
|
|
length(Set);
|
|
|
|
|
|
|
|
get_vh_registered_users_number(Server, _) ->
|
|
|
|
get_vh_registered_users_number(Server).
|
|
|
|
|
2009-02-05 12:13:01 +01:00
|
|
|
%% @spec (User, Server) -> Password | false
|
|
|
|
%% User = string()
|
|
|
|
%% Server = string()
|
|
|
|
%% Password = string()
|
|
|
|
|
2005-04-17 20:08:34 +02:00
|
|
|
get_password(User, Server) ->
|
2008-10-10 16:37:26 +02:00
|
|
|
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
|
2004-12-12 22:00:34 +01:00
|
|
|
_ ->
|
|
|
|
false
|
|
|
|
end.
|
|
|
|
|
2009-02-05 12:13:01 +01:00
|
|
|
%% @spec (User, Server) -> Password | nil()
|
|
|
|
%% User = string()
|
|
|
|
%% Server = string()
|
|
|
|
%% Password = string()
|
|
|
|
|
2005-04-17 20:08:34 +02:00
|
|
|
get_password_s(User, Server) ->
|
2008-10-10 16:37:26 +02:00
|
|
|
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
|
2004-12-12 22:00:34 +01:00
|
|
|
_ ->
|
|
|
|
[]
|
|
|
|
end.
|
|
|
|
|
2009-02-05 12:13:01 +01:00
|
|
|
%% @spec (User, Server) -> bool()
|
|
|
|
%% User = string()
|
|
|
|
%% Server = string()
|
|
|
|
|
2009-03-04 19:34:02 +01:00
|
|
|
%% @spec (User, Server) -> true | false | {error, Error}
|
2005-04-17 20:08:34 +02:00
|
|
|
is_user_exists(User, Server) ->
|
2008-10-10 16:37:26 +02:00
|
|
|
try
|
|
|
|
LUser = exmpp_stringprep:nodeprep(User),
|
|
|
|
LServer = exmpp_stringprep:nameprep(Server),
|
|
|
|
US = {LUser, LServer},
|
|
|
|
case catch mnesia:dirty_read({passwd, US}) of
|
|
|
|
[] ->
|
|
|
|
false;
|
|
|
|
[_] ->
|
|
|
|
true;
|
2009-03-04 19:34:02 +01:00
|
|
|
Other ->
|
|
|
|
{error, Other}
|
2008-10-10 16:37:26 +02:00
|
|
|
end
|
|
|
|
catch
|
2004-12-12 22:00:34 +01:00
|
|
|
_ ->
|
|
|
|
false
|
|
|
|
end.
|
|
|
|
|
2009-01-19 11:14:04 +01:00
|
|
|
%% @spec (User, Server) -> ok
|
2009-02-05 12:13:01 +01:00
|
|
|
%% User = string()
|
|
|
|
%% Server = string()
|
2009-01-19 12:59:40 +01:00
|
|
|
%% @doc Remove user.
|
2009-01-19 11:14:04 +01:00
|
|
|
%% Note: it returns ok even if there was some problem removing the user.
|
2009-02-05 12:13:01 +01:00
|
|
|
|
2005-04-17 20:08:34 +02:00
|
|
|
remove_user(User, Server) ->
|
2008-10-10 16:37:26 +02:00
|
|
|
try
|
|
|
|
LUser = exmpp_stringprep:nodeprep(User),
|
|
|
|
LServer = exmpp_stringprep:nameprep(Server),
|
|
|
|
US = {LUser, LServer},
|
|
|
|
F = fun() ->
|
|
|
|
mnesia:delete({passwd, US})
|
|
|
|
end,
|
|
|
|
mnesia:transaction(F),
|
2009-01-19 11:14:04 +01:00
|
|
|
ok
|
2008-10-10 16:37:26 +02:00
|
|
|
catch
|
|
|
|
_ ->
|
|
|
|
ok
|
|
|
|
end.
|
2004-12-12 22:00:34 +01:00
|
|
|
|
2009-01-19 11:14:04 +01:00
|
|
|
%% @spec (User, Server, Password) -> ok | not_exists | not_allowed | bad_request
|
2009-02-05 12:13:01 +01:00
|
|
|
%% User = string()
|
|
|
|
%% Server = string()
|
|
|
|
%% Password = string()
|
2009-01-19 12:59:40 +01:00
|
|
|
%% @doc Remove user if the provided password is correct.
|
2009-02-05 12:13:01 +01:00
|
|
|
|
2005-04-17 20:08:34 +02:00
|
|
|
remove_user(User, Server, Password) ->
|
2008-10-10 16:37:26 +02:00
|
|
|
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} ->
|
|
|
|
ok;
|
|
|
|
{atomic, Res} ->
|
|
|
|
Res;
|
|
|
|
_ ->
|
|
|
|
bad_request
|
|
|
|
end
|
|
|
|
catch
|
2004-12-12 22:00:34 +01:00
|
|
|
_ ->
|
|
|
|
bad_request
|
|
|
|
end.
|
2005-04-17 20:08:34 +02:00
|
|
|
|
2009-02-05 12:13:01 +01:00
|
|
|
%% @spec () -> term()
|
2005-04-17 20:08:34 +02:00
|
|
|
|
|
|
|
update_table() ->
|
|
|
|
Fields = record_info(fields, passwd),
|
|
|
|
case mnesia:table_info(passwd, attributes) of
|
|
|
|
Fields ->
|
2009-02-05 12:13:01 +01:00
|
|
|
% No conversion is needed when the table comes from an exmpp-less
|
|
|
|
% Ejabberd because ejabberd_auth* modules use string() and not
|
|
|
|
% binary().
|
2005-04-17 20:08:34 +02:00
|
|
|
ok;
|
|
|
|
[user, password] ->
|
|
|
|
?INFO_MSG("Converting passwd table from "
|
|
|
|
"{user, password} format", []),
|
|
|
|
Host = ?MYNAME,
|
|
|
|
{atomic, ok} = mnesia:create_table(
|
|
|
|
ejabberd_auth_internal_tmp_table,
|
|
|
|
[{disc_only_copies, [node()]},
|
|
|
|
{type, bag},
|
|
|
|
{local_content, true},
|
|
|
|
{record_name, passwd},
|
|
|
|
{attributes, record_info(fields, passwd)}]),
|
|
|
|
mnesia:transform_table(passwd, ignore, Fields),
|
|
|
|
F1 = fun() ->
|
|
|
|
mnesia:write_lock_table(ejabberd_auth_internal_tmp_table),
|
|
|
|
mnesia:foldl(
|
|
|
|
fun(#passwd{us = U} = R, _) ->
|
|
|
|
mnesia:dirty_write(
|
|
|
|
ejabberd_auth_internal_tmp_table,
|
|
|
|
R#passwd{us = {U, Host}})
|
|
|
|
end, ok, passwd)
|
|
|
|
end,
|
|
|
|
mnesia:transaction(F1),
|
|
|
|
mnesia:clear_table(passwd),
|
|
|
|
F2 = fun() ->
|
|
|
|
mnesia:write_lock_table(passwd),
|
|
|
|
mnesia:foldl(
|
|
|
|
fun(R, _) ->
|
|
|
|
mnesia:dirty_write(R)
|
|
|
|
end, ok, ejabberd_auth_internal_tmp_table)
|
|
|
|
end,
|
|
|
|
mnesia:transaction(F2),
|
|
|
|
mnesia:delete_table(ejabberd_auth_internal_tmp_table);
|
|
|
|
_ ->
|
|
|
|
?INFO_MSG("Recreating passwd table", []),
|
|
|
|
mnesia:transform_table(passwd, ignore, Fields)
|
|
|
|
end.
|
|
|
|
|
|
|
|
|
|
|
|
|