mirror of
https://github.com/processone/ejabberd
synced 2025-10-03 01:39:35 +02:00
Fix mnesia to sql exporter after changes to auth tables
Conversion functions used by ej2sql module was not updated after change that did allow storing multiple passwords per user, which made us skip passwords that were updated to new format, this fixes this problem. This fixes issue #4391
This commit is contained in:
parent
b4a917db09
commit
591e15f0f6
1 changed files with 13 additions and 9 deletions
|
@ -406,40 +406,44 @@ which_users_exists(LServer, LUsers) ->
|
|||
|
||||
export(_Server) ->
|
||||
[{passwd,
|
||||
fun(Host, #passwd{us = {LUser, LServer}, password = Password})
|
||||
fun(Host, #passwd{us = {LUser, LServer, plain}, password = Password})
|
||||
when LServer == Host,
|
||||
is_binary(Password) ->
|
||||
[?SQL("delete from users where username=%(LUser)s and %(LServer)H;"),
|
||||
[?SQL("delete from users where username=%(LUser)s and type=1 and %(LServer)H;"),
|
||||
?SQL_INSERT(
|
||||
"users",
|
||||
["username=%(LUser)s",
|
||||
"server_host=%(LServer)s",
|
||||
"type=1",
|
||||
"password=%(Password)s"])];
|
||||
(Host, {passwd, {LUser, LServer},
|
||||
{scram, StoredKey1, ServerKey, Salt, IterationCount}})
|
||||
(Host, {passwd, {LUser, LServer, _},
|
||||
{scram, StoredKey, ServerKey, Salt, IterationCount}})
|
||||
when LServer == Host ->
|
||||
Hash = sha,
|
||||
StoredKey = scram_hash_encode(Hash, StoredKey1),
|
||||
[?SQL("delete from users where username=%(LUser)s and %(LServer)H;"),
|
||||
Type = hash_to_num(Hash),
|
||||
[?SQL("delete from users where username=%(LUser)s and type=%(Type)d and %(LServer)H;"),
|
||||
?SQL_INSERT(
|
||||
"users",
|
||||
["username=%(LUser)s",
|
||||
"server_host=%(LServer)s",
|
||||
"type=%(Type)d",
|
||||
"password=%(StoredKey)s",
|
||||
"serverkey=%(ServerKey)s",
|
||||
"salt=%(Salt)s",
|
||||
"iterationcount=%(IterationCount)d"])];
|
||||
(Host, #passwd{us = {LUser, LServer}, password = #scram{} = Scram})
|
||||
(Host, #passwd{us = {LUser, LServer, _}, password = #scram{} = Scram})
|
||||
when LServer == Host ->
|
||||
StoredKey = scram_hash_encode(Scram#scram.hash, Scram#scram.storedkey),
|
||||
StoredKey = Scram#scram.storedkey,
|
||||
ServerKey = Scram#scram.serverkey,
|
||||
Salt = Scram#scram.salt,
|
||||
IterationCount = Scram#scram.iterationcount,
|
||||
[?SQL("delete from users where username=%(LUser)s and %(LServer)H;"),
|
||||
Type = hash_to_num(Scram#scram.hash),
|
||||
[?SQL("delete from users where username=%(LUser)s and type=%(Type)d and %(LServer)H;"),
|
||||
?SQL_INSERT(
|
||||
"users",
|
||||
["username=%(LUser)s",
|
||||
"server_host=%(LServer)s",
|
||||
"type=%(Type)d",
|
||||
"password=%(StoredKey)s",
|
||||
"serverkey=%(ServerKey)s",
|
||||
"salt=%(Salt)s",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue