To access the most up-to-date ejabberd documentation, please visit docs.ejabberd.im »
SOLVED: Gentoo: Cannot create users when using mysql
Submitted by FuriousGeorge on Fri, 2008-01-18 08:49
[UPDATED]:
The nature of the problem seems to have made itself somewhat more clear, so I redid this post entirely.
ejabberd appears not to be able to use MySQL, at least not when set up as per the Official MySQL HowTo. I have enabled the mysql logs, and I see that ejabberd isnt communicating with the DB at any point.
Below is a pretty comprehensive (if I do say so myself) account of what I did to set everything up.
Step 1: Backup the /etc/jabber/directory and compile/install ejabberd
After install Gentoo says:
* For configuration instructions, please see /usr/share/doc/ejabberd-1.1.4-r1/html/guide.html * or the online version at http://www.process-one.net/en/projects/ejabberd/docs/guide_en.html * Please edit /etc/jabber/ssl.cnf and run /etc/jabber/self-cert.sh * Ejabberd may refuse to start without an SSL certificate
...this appears to be sound advice, so i restore my backup ssl.cnf, and build new .pems.
Step 2: Reinstall ssl certs...
SHA1 Fingerprint=BLAH:B3:34:B3:83:A7:BLAH
..also, make I make sure to:
thedude jabber # chmod +r /etc/jabber/ssl.pem
so that ejabberd can read it.
Step 3: What is the minimum it takes to get Authentication working in ejabberd.cfg?
Replace this line, {hosts, ["localhost"]}. with {hosts, ["FQDN.com"]}.
Replace every reference to './ssl.pem' file with '/etc/jabber/ssl.pem' or it wont work
Start ejabberd... Testing...
I can Add Users Users can log in Users can authorize with each other [borat]Great Success![/borat]
Step 4: Attempt to use Native MySQL support.
Compile the native Mysql driver as per the Using ejabberd with MySQL native driver tutorial, and copy them to where they need to go. which is /usr/lib/erlang/lib/ejabberd-1.1.4/ebin/.
Setup the ejabberd table schema:
# echo "show tables;" | mysql -D FQDN_XMPP -h localhost -p -u ejabberd Enter password: Tables_in_FQDN_XMPP last privacy_default_list privacy_list privacy_list_data private_storage rostergroups rosterusers spool users vcard vcard_search
Make changes to ejabberd.cfg
%%% Commented-out when seting up for mysql auth: %%% {auth_method, internal}.
Make following changes as per Native MySQL HowTo
* Change mod_last to mod_last_odbc to store the last seen date in MySQL.
* Change mod_offline to mod_offline_odbc to store offline messages in MySQL.
* Change mod_roster to mod_roster_odbc to store contact lists in MySQL.
* Change mod_vcard to mod_vcard_odbc to store user description in MySQL.
restart ejabbed
Attempting to register existing user in the db's users table via pidgin: Not Authorized
Attempting to register a new user not in db's users table: 409: Conflict
Attempting to add a user via ejabberdctl: User "foobarbaz@FQDN.com" already registered at node ejabberd@thedude
...So now it appears beyond much doubt that I know how to reproduce the problem.
[UPDATE]: In a related problem I had a few weeks ago, someone suggested i modify part of ejabberd_auth_odbc.erl, to look like this:
try_register(User, Server, Password) -> ?INFO_MSG("Lets 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", []), {atomic, exists} end end.
I tried that and my logs are still useless. I know the code was compiled because it failed until I removed a "'" that was in the wrong place. Where should I see this output?
[UPDATE]: I gave the mailing list a shot, and a fellow recommended do this:
Solved!
This was the result of an improperly configured hosts file, that prevented ejabberd from locating the SQL server