views:

130

answers:

2

I am building an ejabberd module. I require this module to perform RPC calls to another node on the same LAN (sname). From what I understand, ejabberd configures it owns "cookie" which, of course, will differ from the cookie I use for my other nodes.

Is there a way to force ejabberd to use another cookie?

EDIT: ejabberd starts its daemon under the "ejabberd" username.

EDIT: even when creating /home/ejabberd/.erlang.cookie (username: ejabberd, group: ejabberd) with an appropriate cookie it still does not work.

EDIT: one way to go around the problem (which isn't so nice) is to copy (with the proper permissions) the intended .erlang.cookie file to /var/lib/ejabberd

A: 

From the documentation, the answer seems to be to write the cookie to the file ~/.erlang.cookie.

legoscia
If only it was this easy... ejabberd creates its own cookie in /var/lib/ejabberd everytime it starts it seems... and it is different from the one located in ~
jldupont
Right, I looked at the binary installer, which doesn't seem to do any such tricks...
legoscia
+1  A: 

The ejabberdctl script sets the home directory so that the cookie file lives at /var/lib/ejabberd/.erlang.cookie. Erlang itself checks the permissions of the file, so they must be correct.

You have a few options to force the use of a particular cookie:

  • Change the contents of the file - ejabberd won't alter it.
  • Change the ejabberdctl script so that it passes -setcookie 'SomeCookieValue' to erl.
  • Change ejabberdctl to set a different home directory.

The cookie file will be created if it doesn't exist, but won't be changed behind your back if it does exist. Using a common cookie is required to build ejabberd clusters or to integrate with ejabberd via erlang distribution.

archaelus