Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

epmd: require explicitly adding loopback address (see also #1075) #1422

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions erts/doc/src/epmd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

</legalnotice>

<title>epmd</title>
<prepared>Claes Wikstr&ouml;m</prepared>
<prepared>Claes Wikstr&ouml;m</prepared>
<responsible></responsible>
<docno>1</docno>
<approved></approved>
Expand Down Expand Up @@ -113,12 +113,12 @@
<taglist>
<tag><c><![CDATA[-address List]]></c></tag>
<item>
<p>Lets this instance of <c>epmd</c> listen only on the
comma-separated list of IP addresses and on the loopback address
(which is implicitly added to the list if it has not been
specified). This can also be set using environment variable
<c><![CDATA[ERL_EPMD_ADDRESS]]></c>; see section <seealso
marker="#environment_variables">Environment Variables</seealso>.</p>
<p>Let this instance of <c>epmd</c> listen only on the
comma-separated list of IP addresses. The list of IP addresses should
include the loopback address. This can also be set
using the <c><![CDATA[ERL_EPMD_ADDRESS]]></c> environment variable. See
the section <seealso marker="#environment_variables">Environment
variables</seealso> below.</p>
</item>
<tag><c><![CDATA[-port No]]></c></tag>
<item>
Expand Down Expand Up @@ -258,12 +258,12 @@
<taglist>
<tag><c><![CDATA[ERL_EPMD_ADDRESS]]></c></tag>
<item>
<p>Can be set to a comma-separated
list of IP addresses, in which case the <c>epmd</c> daemon
will listen only on the specified address(es) and on the
loopback address (which is implicitly added to the list if it
has not been specified). The default behavior is to listen on
all available IP addresses.</p>
<p>This environment variable may be set to a comma-separated
list of IP addresses, in which case the <c>epmd</c> daemon
will listen only on the specified address(es). The list of
IP addresses should include the loopback address.
The default behaviour is to listen on
all available IP addresses.</p>
</item>
<tag><c><![CDATA[ERL_EPMD_PORT]]></c></tag>
<item>
Expand Down
36 changes: 3 additions & 33 deletions erts/epmd/src/epmd_srv.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ void run(EpmdVars *g)
int i;
int opt;
unsigned short sport = g->port;
int bound = 0;

node_init(g);
g->conn = conn_init(g);
Expand Down Expand Up @@ -252,14 +251,6 @@ void run(EpmdVars *g)
char *tmp = NULL;
char *token = NULL;

/* Always listen on the loopback. */
SET_ADDR(iserv_addr[num_sockets],htonl(INADDR_LOOPBACK),sport);
num_sockets++;
#if defined(EPMD6)
SET_ADDR6(iserv_addr[num_sockets],in6addr_loopback,sport);
num_sockets++;
#endif

if ((tmp = strdup(g->addresses)) == NULL)
{
dbg_perror(g,"cannot allocate memory");
Expand All @@ -273,7 +264,6 @@ void run(EpmdVars *g)
struct in_addr addr;
#if defined(EPMD6)
struct in6_addr addr6;
struct sockaddr_storage *sa = &iserv_addr[num_sockets];

if (inet_pton(AF_INET6,token,&addr6) == 1)
{
Expand All @@ -296,15 +286,6 @@ void run(EpmdVars *g)
epmd_cleanup_exit(g,1);
}

#if defined(EPMD6)
if (sa->ss_family == AF_INET6 && IN6_IS_ADDR_LOOPBACK(&addr6))
continue;

if (sa->ss_family == AF_INET)
#endif
if (IS_ADDR_LOOPBACK(addr))
continue;

num_sockets++;

if (num_sockets >= MAX_LISTEN_SOCKETS)
Expand Down Expand Up @@ -366,16 +347,10 @@ void run(EpmdVars *g)

if ((listensock[i] = socket(sa->sa_family,SOCK_STREAM,0)) < 0)
{
switch (errno) {
case EAFNOSUPPORT:
case EPROTONOSUPPORT:
continue;
default:
dbg_perror(g,"error opening stream socket");
epmd_cleanup_exit(g,1);
}
dbg_perror(g,"error opening stream socket");
epmd_cleanup_exit(g,1);
}
g->listenfd[bound++] = listensock[i];
g->listenfd[i] = listensock[i];

#if HAVE_DECL_IPV6_V6ONLY
opt = 1;
Expand Down Expand Up @@ -440,11 +415,6 @@ void run(EpmdVars *g)
}
select_fd_set(g, listensock[i]);
}
if (bound == 0) {
dbg_perror(g,"unable to bind any address");
epmd_cleanup_exit(g,1);
}
num_sockets = bound;
#ifdef HAVE_SYSTEMD_DAEMON
}
if (g->is_systemd) {
Expand Down