ports/158357: Strange behaviour of epmd launched with ejabberd
Maxim Ignatenko
gelraen.ua at gmail.com
Mon Jun 27 21:50:09 UTC 2011
>Number: 158357
>Category: ports
>Synopsis: Strange behaviour of epmd launched with ejabberd
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Mon Jun 27 21:50:09 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator: Maxim Ignatenko
>Release: FreeBSD 7.3-STABLE
>Organization:
>Environment:
>Description:
After upgrading ejabberd from 2.1.3 to 2.1.8 `ejabberdctl` suddenly refused to work, saying "nodedown", while ejabberd itself started and works as usual. With Holger at ejabberd at conference.jabber.ru we've tracked down roots of the problem:
1) FreeBSD's /bin/sh initializes exported variable with empty value if it was not previously set:
$ printenv | grep FOO
$ export FOO
$ printenv | grep FOO
_=FOO
FOO=
2) `ejabberdctl` script exports unset variable ERL_EPMD_ADDRESS
3) `epmd` treats ERL_EPMD_ADDRESS='' as ERL_EPMD_ADDRESS='127.0.0.1' and listens only on localhost
4) `erl` called by `ejabberdctl` firts gets local hostname, tries to resolve it via gethostbyname and connects to `epmd` on that IP. But if you don't have local hostname as alias in /etc/hosts or /usr/local/etc/ejabberd/inetrc it will fail, since DNS record usually does not point to 127.0.0.1.
>How-To-Repeat:
Install ejabberd, set "ejabberd_nodename" to "ejabberd@$(hostname -s)", start ejabberd and execute "ejabberdctl --node ejabberd@(hostname -s) status"
>Fix:
Possible patch (not tested) for rc-script attached. Running epmd `only` on 127.0.0.1 is good for security, but clustering requires `epmd` to listen on address accessible from other nodes. Also, pkg-message should mention that `ejabberdctl` will not work with nodename other than "ejabberd at localhost", if Erlang does not resolve local machine's short hostname to address on which `epmd` is able to accept connections. In case of single node most preferred way to achieve this is to leave `epmd` listening on 127.0.0.1 and add $(hostname -s) as alias for 127.0.0.1 in /usr/local/etc/ejabberd/inetrc
Patch attached with submission follows:
--- ejabberd.in.orig 2011-06-28 00:37:21.636314615 +0300
+++ ejabberd.in 2011-06-28 00:39:23.156814051 +0300
@@ -15,6 +15,7 @@
#
ejabberd_enable=${ejabberd_enable-"NO"}
ejabberd_node=${ejabberd_node-"ejabberd at localhost"}
+ejabberd_epmd_address=${ejabberd_epmd_address-"127.0.0.1"}
. /etc/rc.subr
@@ -50,7 +51,7 @@
ejabberd_start()
{
echo "Starting $name."
- su $EJABBERDUSER -c "$EJABBERDCTL --node $ejabberd_node start"
+ su $EJABBERDUSER -c "env ERL_EPMD_ADDRESS=\"${ejabberd_epmd_address}\" $EJABBERDCTL --node $ejabberd_node start"
}
ejabberd_stop()
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list