SOLVED: ejabberd 1.1.3 on gentoo using mysql: cant add users or authenticate.

UPDATE: Somehow I fixed this, see the last post for vague details. What follows is the original thread.

I've successfully installed ejabberd, and the native mysql drivers. I've also installed a database schema for ejabberd, as per the tutorial mysql tutorial, and adjusted my ejabberd.cnf accordingly. I've restarted the server, and now I would like to add a few users.

If I try to do this from the command line, the results are as follows:

# ejabberdctl ejabberd@thedude register brian FQDN.com password
User "brian@FQDN.com" already registered at node ejabberd@thedude

# ejabberdctl ejabberd@thedude register AnyNameITry FQDN.com password
User "AnyNameITry@FQDN.com" already registered at node ejabberd@thedude

Similarly, in Pidgin, I'm told "409: Conflict" for any user I would like to add.

Not surprisingly, I don't know the passwords for any of the accounts that 'already exist', so I cannot log into the web-interface to add a user that way.

I have no idea what is going on, but i have a suspicion that despite copying the .beam files i compiled to the dir with the other .beam files in /usr/lib/erlang/lib/ejabberd-1.1.3/ebin/ , my sql tables are being ignored.

one reason for my suspicion is that it seems not to matter if I have a row in the ejabberd.users table like this:

mysql> select * from ejabberd.users;
+-------------------+----------+
| username          | password |
+-------------------+----------+
| brian@FQDN.com    | password |
+-------------------+----------+

...or not.

the logs are unfortunately totally useless:

=INFO REPORT==== 2008-01-13 14:12:20 ===
I(<0.204.0>:ejabberd_listener:90): (#Port<0.345>) Accepted connection {{67,84,2,140},51129} -> {{67,18,17,245},5222}                      

...as they just annoyingly repeat this over and over again like a poorly trained parrot ;)

it appears that ejabberd is running:

# /etc/init.d/ejabberd status
* status:  started

# ejabberdctl ejabberd@thedude status
Node ejabberd@thedude is started. Status: started
ejabberd is running

# ps ax|grep ejabberd
4571 pts/2    Sl     0:01 /usr/lib/erlang/erts-5.5.5/bin/beam -- -root /usr/lib/erlang -progname erl -- -home /var/run/jabber -pa /usr/lib/erlang/lib/ejabberd-1.1.3/ebin -sname ejabberd -s ejabberd -ejabberd config "/etc/jabber/ejabberd.cfg" log_path "/var/log/jabber/ejabberd.log" -kernel inetrc "/etc/jabber/inetrc" -sasl sasl_error_logger {file,"/var/log/jabber/sasl.log"} -mnesia dir "/var/spool/jabber" -noshell -noshell -noinput

my configuration is as follows:

# cat /etc/conf.d/ejabberd

EJABBERD_NODE="ejabberd@`hostname -s`"
ERL_FULLSWEEP_AFTER=0

#cat /etc/jabber/ejabberd.cnf

% $Id: ejabberd.cfg.example 577 2006-06-07 08:38:37Z mremond $

{acl, admin, {user, "brian", "FQDN.com"}}.

{access, configure, [{allow, admins}]}.

{acl, local, {user_regexp, ""}}.

{access, pubsub_createnode, [{allow, all}]}.

{access, configure, [{allow, admin}]}.

{access, register, [{allow, all}]}.

{welcome_message,
{"Welcome!",
  "Welcome to Jabber Service.  "
  "For information about Jabber visit http://jabber.org"}}.

{access, announce, [{allow, admin}]}.
{access, c2s, [{deny, blocked},
       {allow, all}]}.

{shaper, normal, {maxrate, 1000}}.
{shaper, fast, {maxrate, 50000}}.

{access, c2s_shaper, [{none, admin},
      {normal, all}]}.
{access, s2s_shaper, [{fast, all}]}.
{access, muc_admin, [{allow, admin}]}.
{access, muc, [{allow, all}]}.
{access, local, [{allow, local}]}.

%ATTEMPTING TO USE MYSQL FOR AUTHENTICATION
{auth_method, odbc}.
{odbc_server, {mysql, "localhost", "ejabberd", "ejabberd", "march81"}}.

{hosts, ["FQDN.com"]}.

{max_user_sessions, 10}.

{host_config, "FQDN.com", [{auth_method, [odbc]}]}.

{language, "en"}.

{listen,
[{5222, ejabberd_c2s,     [{access, c2s}, {shaper, c2s_shaper},
    {max_stanza_size, 65536},
    starttls, {certfile, "/etc/jabber/ssl.pem"}]},
  {5223, ejabberd_c2s,     [{access, c2s},
    {max_stanza_size, 65536},
    tls, {certfile, "/etc/jabber/ssl.pem"}]},
  {5269, ejabberd_s2s_in,  [{shaper, s2s_shaper},
    {max_stanza_size, 131072}
   ]},
  {5280, ejabberd_http,    [http_poll, web_admin]},
  {8888, ejabberd_service, [{access, all},
    {hosts, ["icq.localhost", "sms.localhost"],
     [{password, "secret"}]}]}
]}.

{s2s_use_starttls, true}.
{s2s_certfile, "/etc/jabber/ssl.pem"}.

{outgoing_s2s_port, 5269}.

{modules,
[
  {mod_register,   [{access, register}]},
  {mod_roster_odbc,     []},
  {mod_privacy,    []},
  {mod_adhoc,      []},
  {mod_configure,  []}, % Depends on mod_adhoc
  {mod_configure2, []},
  {mod_disco,      []},
  {mod_stats,      []},
  {mod_vcard_odbc,      []},
  {mod_offline_odbc,    []},
  {mod_announce,   [{access, announce}]}, % Depends on mod_adhoc
  {mod_echo,       [{host, "echo.localhost"}]},
  {mod_private,    []},
  {mod_irc,        []},
  {mod_muc,        [{access, muc},
    {access_create, muc},
    {access_admin, muc_admin}]},
  {mod_pubsub,     [{access_createnode, pubsub_createnode}]},
  {mod_time,       []},
  {mod_last_odbc,       []},
  {mod_version,    []}
]}.

% Local Variables:
% mode: erlang
% End:

the database schema installed by the sqldump looks like this:

mysql> show tables;
+----------------------+
| Tables_in_ejabberd   |
+----------------------+
| last                 |
| privacy_default_list |
| privacy_list         |
| privacy_list_data    |
| private_storage      |
| rostergroups         |
| rosterusers          |
| spool                |
| users                |
| vcard                |
| vcard_search         |
+----------------------+
11 rows in set (0.00 sec)

...all those tables are empty

Maybe if there were some way to turn up the verbosity of the logging I could figure out something to do on my own.

Any help is much appreciated,
FG

Debugging odbc auth account creation

It seems you use Gentoo's ejabberd 1.1.3 package, and you spend several hours trying to figure what's going on here. Since I don't know where the problem is, and after several days nobody else answered, I propose you to spend another hour or so, to at least know the nature of the problem.

  1. Backup and remove all the ejabberd files. So you start with it from scratch.
  2. Get ejabberd source code from SVN
  3. Compile ejabberd. Quite probably you already have most of the dependencies.
  4. Configure ejabberd: you just need to put your FQDN.
  5. Start ejabberd and check that it works correctly. The accounts you create are stored in a Mnesia table.
  6. As everything works correctly, now let's complicate it. Get the mysql module again (or copy its beam files). Configure ejabberd to use that authentication method.
  7. Start ejabberd. Now there are no accounts. Try to create one. If it works correctly, all we get happy. If fails with the old message 'account exists', then let's debug it.

To increase the level of debugging in ejabberd, you can use the option debug_level in ejabberd.cfg

If those debug messages don't help you much to find the problem, put back the default debug_level and let's add your custom messages in the code. The file to edit is ejabberd_auth_odbc.erl and the function is try_register/3 (around line 116). You can add as many log messages as you want, but I think this example covers all the possibilities:

try_register(User, Server, Password) ->
    ?INFO_MSG("Let's start with the function try_register with ~n User: ~p, Server: ~p, Password: ~p", [User, Server, Password]),
    case jlib:nodeprep(User) of
	error ->
            ?INFO_MSG("Error: invalid JID; with user: ~p", [User]),
	    {error, invalid_jid};
	LUser ->
            ?INFO_MSG("OK, nodeprep returns LUser: ~p", [LUser]),
	    Username = ejabberd_odbc:escape(LUser),
	    Pass = ejabberd_odbc:escape(Password),
	    LServer = jlib:nameprep(Server),
            ?INFO_MSG("So, let's call add_user with ~n LServer: ~p, Username: ~p, Pass: ~p", [LServer, Username, Pass]),
	    case catch odbc_queries:add_user(LServer, Username, Pass) of
		{updated, 1} ->
                    ?INFO_MSG("Success creating the account!!", []),
		    {atomic, ok};
		E ->
                    ?INFO_MSG("Error creating the account :(  Maybe the account already exists ~n Result: ~p", [E]),
		    {atomic, exists}
	    end
    end.

installationg from source produces strange errors

UPDATE: Fixed somehow!

Installing from SVN somehow led to this:

# ejabberdctl register admin FQDN.com march81
RPC failed on the node ejabberd@localhost: nodedown

=ERROR REPORT==== 14-Jan-2008::02:04:02 ===
Error in process <0.34.0> on node 'ejabberdctl@thedude' with exit value: {badarg,[{erlang,list_to_existing_atom,["ejabberd@thedude"]},{dist_util,recv_challenge,1},{dist_util,handshake_we_started,1}]}

Commands to start an ejabberd node: (etc)

...so I unmasked my distro's 1.1.4 package and installed that this time. I did it from scratch, essentially following Badlop's instructions (just generally being methodical), and for whatever reason it worked this time.

I wish I could say what is was, the upgrade, the new cfgs, or karma, but I can't.

I did get some problems with my ssl.pem files not being found, so I used the full path i ejabberd.cfg, and had to change their perms so they were readable to the jabber user on my system.

I need to give this a rest for a few hours and try to add other domains.

Syndicate content