Changeset

11842:c20ff585e966

prosody2ejabberd: Check for iteration count at position 6 In some data dumps, presumably from newer ejabberd versions, position 5 is the string "sha", and the iteration count follows it.
author Matthew Wild <mwild1@gmail.com>
date Thu, 07 Oct 2021 13:02:28 +0100
parents 11841:94534717ffca
children 11843:d2a939e21671
files tools/ejabberd2prosody.lua
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/tools/ejabberd2prosody.lua	Thu Oct 07 11:16:46 2021 +0100
+++ b/tools/ejabberd2prosody.lua	Thu Oct 07 13:02:28 2021 +0100
@@ -85,7 +85,13 @@
 		data.stored_key = hex(unb64(password[2]));
 		data.server_key = hex(unb64(password[3]));
 		data.salt = unb64(password[4]);
-		data.iteration_count = tonumber(password[5]);
+		if type(password[6]) == "number" then
+			assert(password[5] == "sha", "unexpected passwd entry hash: "..tostring(password[5]));
+			data.iteration_count = password[6];
+		else
+			assert(type(password[5]) == "number", "unexpected passwd entry in source data");
+			data.iteration_count = password[5];
+		end
 	end
 	local ret, err = dm.store(node, host, "accounts", data);
 	print("["..(err or "success").."] accounts: "..node.."@"..host);