ejabberd: is there a way to configure a different “cookie” than “ejabberd”?
Question
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
Solution
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.