0

I am trying to migrate from another XMPP server to ejabberd via XEP-0227 formatted dump. The old server used, and the ejabberd will use PAM for user authentication. Therefore, there is no password data in the <user/> entries in the dump.

<server-data xmlns="urn:xmpp:pie:0">
  <host jid="localhost">
    <user name="watcher">
    ...
    </user>
  ...
  </host>
</server-data>

When I try to import data from the dump, I get the error:

2018-05-05 19:05:30.888 [error] <0.605.0>@ejabberd_piefxis:stop:539 Failed to create user 'watcher': invalid_password

Supplying fake password does not look like a good proposition to me. Is there some trick to make it work, or am I completely off the track? Or is a change in the code in ejabberd_piefxis necessary?

The version is 18.01-2, default on Ubuntu Bionic.

Nisse Engström
  • 208
  • 2
  • 5
crosser
  • 113
  • 4

1 Answers1

1

Supplying fake password does not look like a good proposition to me.

You can supply a fake password, so the process continues correctly, and later delete the content of the 'passwd' mnesia table (using WebAdmin, for example). Or...

Or is a change in the code in ejabberd_piefxis necessary?

... you can apply this small patch, that bypass account creation when it fails with an empty password. If you are able to try that patch, please comment if it works, to consider including it in ejabberd.

diff --git a/src/ejabberd_piefxis.erl b/src/ejabberd_piefxis.erl
index c73c8b3a4..afb0e1a05 100644
--- a/src/ejabberd_piefxis.erl
+++ b/src/ejabberd_piefxis.erl
@@ -404,6 +404,8 @@ process_user(#xmlel{name = <<"user">>, attrs = Attrs, children = Els},
             case ejabberd_auth:try_register(LUser, LServer, Pass) of
                 ok ->
                     process_user_els(Els, State#state{user = LUser});
+                {error, invalid_password} when (Password == <<>>) ->
+                    process_user_els(Els, State#state{user = LUser});
                 {error, Err} ->
                     stop("Failed to create user '~s': ~p", [Name, Err])
             end
Badlop
  • 580
  • 3
  • 5
  • thanks, it seems to work. I am now getting `Failed to write privacy: 'bad-request'` and it is very likely that I generated bad `` element. It's frustrating that the failed request is not logged, so I cannot identify it, but that would be another feature request. Shall I submit pull request with your diff or will you take care of it yourself? – crosser May 07 '18 at 19:37
  • Committed. For the failed request, you can try to increase loglevel to 5. – Badlop May 08 '18 at 16:19
  • Thanks @badlop! Setting log level to 5 was the first thing that I did :) My complaint is that diagnostic in ejabberd_piefxis.erl:492 does not contain `text` from #stanza_error, and also the offending IQ is not included in the diagnostic. Anyway I think that it is an error in ejabberd_piefxis, I opened a ticket https://github.com/processone/ejabberd/issues/2412 – crosser May 10 '18 at 21:10