From 814d38ee1a111caf81e066d290fec455d13dcc9b Mon Sep 17 00:00:00 2001 From: Matt Lewandowsky Date: Wed, 11 Sep 2013 05:12:32 -0700 Subject: Fix syslog defines config.h defines HAVE_SYSLOG_H whereas the sources are looking for NO_SYSLOG to be undefined. As the logic of "if feature is available" makes more sense than "if feature is not unavailable", I opted for the config.h define. --- erts/epmd/src/epmd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'erts/epmd/src/epmd.c') diff --git a/erts/epmd/src/epmd.c b/erts/epmd/src/epmd.c index 94bb74c876..2d55b37ff3 100644 --- a/erts/epmd/src/epmd.c +++ b/erts/epmd/src/epmd.c @@ -286,7 +286,7 @@ static void run_daemon(EpmdVars *g) /* fork to make sure first child is not a process group leader */ if (( child_pid = fork()) < 0) { -#ifndef NO_SYSLOG +#ifdef HAVE_SYSLOG_H syslog(LOG_ERR,"erlang mapper daemon cant fork %m"); #endif epmd_cleanup_exit(g,1); @@ -312,7 +312,7 @@ static void run_daemon(EpmdVars *g) if ((child_pid = fork()) < 0) { -#ifndef NO_SYSLOG +#ifdef HAVE_SYSLOG_H syslog(LOG_ERR,"erlang mapper daemon cant fork 2'nd time %m"); #endif epmd_cleanup_exit(g,1); @@ -483,7 +483,7 @@ static void dbg_gen_printf(int onsyslog,int perr,int from_level, if (g->is_daemon) { -#ifndef NO_SYSLOG +#ifdef HAVE_SYSLOG_H if (onsyslog) { erts_vsnprintf(buf, DEBUG_BUFFER_SIZE, format, args); -- cgit v1.2.3 From b7c95eabf6017ddb352fb8ce2b3749af108ebf29 Mon Sep 17 00:00:00 2001 From: "Matwey V. Kornilov" Date: Tue, 17 Dec 2013 18:16:56 +0400 Subject: Add systemd socket activation for epmd. Check for systemd libraries and headers in confgiure. Add -systemd option enabling waiting for sockets from systemd. --- erts/epmd/src/epmd.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'erts/epmd/src/epmd.c') diff --git a/erts/epmd/src/epmd.c b/erts/epmd/src/epmd.c index 2d55b37ff3..fc58882907 100644 --- a/erts/epmd/src/epmd.c +++ b/erts/epmd/src/epmd.c @@ -175,6 +175,9 @@ int main(int argc, char** argv) g->nodes.reg = g->nodes.unreg = g->nodes.unreg_tail = NULL; g->nodes.unreg_count = 0; g->active_conn = 0; +#ifdef HAVE_SYSTEMD_SD_DAEMON_H + g->is_systemd = 0; +#endif for (i = 0; i < MAX_LISTEN_SOCKETS; i++) g->listenfd[i] = -1; @@ -248,8 +251,12 @@ int main(int argc, char** argv) else usage(g); epmd_cleanup_exit(g,0); - } - else +#ifdef HAVE_SYSTEMD_SD_DAEMON_H + } else if (strcmp(argv[0], "-systemd") == 0) { + g->is_systemd = 1; + argv++; argc--; +#endif + } else usage(g); } dbg_printf(g,1,"epmd running - daemon = %d",g->is_daemon); @@ -454,6 +461,11 @@ static void usage(EpmdVars *g) fprintf(stderr, " Forcibly unregisters a name with epmd\n"); fprintf(stderr, " (only allowed if -relaxed_command_check was given when \n"); fprintf(stderr, " epmd was started).\n"); +#ifdef HAVE_SYSTEMD_SD_DAEMON_H + fprintf(stderr, " -systemd\n"); + fprintf(stderr, " Wait for socket from systemd. The option makes sense\n"); + fprintf(stderr, " when started from .socket unit.\n"); +#endif epmd_cleanup_exit(g,1); } -- cgit v1.2.3 From 200fbe924466720bd2a8c5eb05b05d67b0a2414c Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Thu, 14 Mar 2013 15:42:19 +0100 Subject: Added support for ENEA OSE This port has support for both non-smp and smp. It contains a new way to do io checking in which erts_poll_wait receives the payload of the polled entity. This has implications for all linked-in drivers. --- erts/epmd/src/epmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'erts/epmd/src/epmd.c') diff --git a/erts/epmd/src/epmd.c b/erts/epmd/src/epmd.c index 2d55b37ff3..5d5c3a1c3c 100644 --- a/erts/epmd/src/epmd.c +++ b/erts/epmd/src/epmd.c @@ -389,7 +389,7 @@ static void run_daemon(EpmdVars *g) } #endif -#if defined(VXWORKS) +#if defined(VXWORKS) || defined(__OSE__) static void run_daemon(EpmdVars *g) { run(g); -- cgit v1.2.3 From e444e9a2ac6a2d70a34d95c97c4af0d39aac232d Mon Sep 17 00:00:00 2001 From: Jay True Date: Wed, 26 Feb 2014 22:29:00 +0800 Subject: ensure argv large enough for all possible args --- erts/epmd/src/epmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'erts/epmd/src/epmd.c') diff --git a/erts/epmd/src/epmd.c b/erts/epmd/src/epmd.c index 2d55b37ff3..eb32a08e0b 100644 --- a/erts/epmd/src/epmd.c +++ b/erts/epmd/src/epmd.c @@ -52,7 +52,7 @@ static int epmd_main(int, char **, int); int epmd_dbg(int level,int port) /* Utility to debug epmd... */ { - char* argv[MAX_DEBUG+2]; + char* argv[MAX_DEBUG+4]; char ibuff[100]; int argc = 0; -- cgit v1.2.3 From e2c11e89563f0c11794c91193b29bce00ca9c740 Mon Sep 17 00:00:00 2001 From: Rick Reed Date: Tue, 22 May 2012 12:28:09 -0700 Subject: Add missing error string to syslog logging in epmd --- erts/epmd/src/epmd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'erts/epmd/src/epmd.c') diff --git a/erts/epmd/src/epmd.c b/erts/epmd/src/epmd.c index 5d5c3a1c3c..5dd4a2cc2e 100644 --- a/erts/epmd/src/epmd.c +++ b/erts/epmd/src/epmd.c @@ -486,7 +486,11 @@ static void dbg_gen_printf(int onsyslog,int perr,int from_level, #ifdef HAVE_SYSLOG_H if (onsyslog) { - erts_vsnprintf(buf, DEBUG_BUFFER_SIZE, format, args); + int len; + len = erts_vsnprintf(buf, DEBUG_BUFFER_SIZE, format, args); + if (perr != 0 && len < sizeof(buf)) { + erts_snprintf(buf+len, sizeof(buf)-len, ": %s", strerror(perr)); + } syslog(LOG_ERR,"epmd: %s",buf); } #endif -- cgit v1.2.3 From 6ace9a5b381fcd6e6efb4d45edeb70f566e24f93 Mon Sep 17 00:00:00 2001 From: Chris Dituri Date: Fri, 15 Aug 2014 22:38:26 -0500 Subject: epmd: pedantic spelling fix in comments Correct spelling errors in the run_daemon() comments which describe the redirection of stdin, stdout, and stderr to /dev/null for safety reasons. --- erts/epmd/src/epmd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'erts/epmd/src/epmd.c') diff --git a/erts/epmd/src/epmd.c b/erts/epmd/src/epmd.c index 9630e0cdf0..0823dcaa4e 100644 --- a/erts/epmd/src/epmd.c +++ b/erts/epmd/src/epmd.c @@ -345,7 +345,7 @@ static void run_daemon(EpmdVars *g) inform it of that the log is closed. */ closelog(); - /* These chouldn't be needed but for safety... */ + /* These shouldn't be needed but for safety... */ open("/dev/null", O_RDONLY); /* Order is important! */ open("/dev/null", O_WRONLY); @@ -386,7 +386,7 @@ static void run_daemon(EpmdVars *g) close(1); close(2); - /* These chouldn't be needed but for safety... */ + /* These shouldn't be needed but for safety... */ open("nul", O_RDONLY); open("nul", O_WRONLY); -- cgit v1.2.3 From 59740d8fee66f3326b30ac25882b52ffada4bac2 Mon Sep 17 00:00:00 2001 From: Peter Lemenkov Date: Fri, 6 Jun 2014 15:29:49 +0400 Subject: epmd: Added systemd notify support to EPMD Signed-off-by: Peter Lemenkov --- erts/epmd/src/epmd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'erts/epmd/src/epmd.c') diff --git a/erts/epmd/src/epmd.c b/erts/epmd/src/epmd.c index 9630e0cdf0..dff9bc64de 100644 --- a/erts/epmd/src/epmd.c +++ b/erts/epmd/src/epmd.c @@ -593,9 +593,11 @@ void epmd_cleanup_exit(EpmdVars *g, int exitval) for(i=0; g->argv[i] != NULL; ++i) free(g->argv[i]); free(g->argv); - } - - + } +#ifdef HAVE_SYSTEMD_SD_DAEMON_H + sd_notifyf(0, "STATUS=Exited.\n" + "ERRNO=%i", exitval); +#endif // HAVE_SYSTEMD_SD_DAEMON_H exit(exitval); } -- cgit v1.2.3 From 5db2345baa3bb9c835f91aafac3dde6e595debc7 Mon Sep 17 00:00:00 2001 From: Peter Lemenkov Date: Sun, 2 Nov 2014 18:06:21 +0300 Subject: epmd: Unify systemd autoconf macros usage Don't use both HAVE_SYSTEMD_DAEMON and HAVE_SYSTEMD_SD_DAEMON - use only the former one and remove the latter one entirely. Signed-off-by: Peter Lemenkov --- erts/epmd/src/epmd.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'erts/epmd/src/epmd.c') diff --git a/erts/epmd/src/epmd.c b/erts/epmd/src/epmd.c index dff9bc64de..9699491526 100644 --- a/erts/epmd/src/epmd.c +++ b/erts/epmd/src/epmd.c @@ -175,9 +175,9 @@ int main(int argc, char** argv) g->nodes.reg = g->nodes.unreg = g->nodes.unreg_tail = NULL; g->nodes.unreg_count = 0; g->active_conn = 0; -#ifdef HAVE_SYSTEMD_SD_DAEMON_H +#ifdef HAVE_SYSTEMD_DAEMON g->is_systemd = 0; -#endif +#endif /* HAVE_SYSTEMD_DAEMON */ for (i = 0; i < MAX_LISTEN_SOCKETS; i++) g->listenfd[i] = -1; @@ -251,11 +251,11 @@ int main(int argc, char** argv) else usage(g); epmd_cleanup_exit(g,0); -#ifdef HAVE_SYSTEMD_SD_DAEMON_H +#ifdef HAVE_SYSTEMD_DAEMON } else if (strcmp(argv[0], "-systemd") == 0) { g->is_systemd = 1; argv++; argc--; -#endif +#endif /* HAVE_SYSTEMD_DAEMON */ } else usage(g); } @@ -461,11 +461,11 @@ static void usage(EpmdVars *g) fprintf(stderr, " Forcibly unregisters a name with epmd\n"); fprintf(stderr, " (only allowed if -relaxed_command_check was given when \n"); fprintf(stderr, " epmd was started).\n"); -#ifdef HAVE_SYSTEMD_SD_DAEMON_H +#ifdef HAVE_SYSTEMD_DAEMON fprintf(stderr, " -systemd\n"); fprintf(stderr, " Wait for socket from systemd. The option makes sense\n"); fprintf(stderr, " when started from .socket unit.\n"); -#endif +#endif /* HAVE_SYSTEMD_DAEMON */ epmd_cleanup_exit(g,1); } @@ -594,10 +594,10 @@ void epmd_cleanup_exit(EpmdVars *g, int exitval) free(g->argv[i]); free(g->argv); } -#ifdef HAVE_SYSTEMD_SD_DAEMON_H +#ifdef HAVE_SYSTEMD_DAEMON sd_notifyf(0, "STATUS=Exited.\n" "ERRNO=%i", exitval); -#endif // HAVE_SYSTEMD_SD_DAEMON_H +#endif /* HAVE_SYSTEMD_DAEMON */ exit(exitval); } -- cgit v1.2.3 From eb15bb261a09c7e87707da042887ccfd7ef58417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Tue, 16 Jun 2015 10:12:52 +0200 Subject: Revert "Add missing error string to syslog logging in epmd" This reverts commit e2c11e89563f0c11794c91193b29bce00ca9c740. --- erts/epmd/src/epmd.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'erts/epmd/src/epmd.c') diff --git a/erts/epmd/src/epmd.c b/erts/epmd/src/epmd.c index 447aae47aa..2fd9845d1a 100644 --- a/erts/epmd/src/epmd.c +++ b/erts/epmd/src/epmd.c @@ -498,11 +498,7 @@ static void dbg_gen_printf(int onsyslog,int perr,int from_level, #ifdef HAVE_SYSLOG_H if (onsyslog) { - int len; - len = erts_vsnprintf(buf, DEBUG_BUFFER_SIZE, format, args); - if (perr != 0 && len < sizeof(buf)) { - erts_snprintf(buf+len, sizeof(buf)-len, ": %s", strerror(perr)); - } + erts_vsnprintf(buf, DEBUG_BUFFER_SIZE, format, args); syslog(LOG_ERR,"epmd: %s",buf); } #endif -- cgit v1.2.3 From 738c34d4bb8f1a3811acd00af8c6c12107f8315b Mon Sep 17 00:00:00 2001 From: Bruce Yinhe Date: Thu, 18 Jun 2015 11:31:02 +0200 Subject: Change license text to APLv2 --- erts/epmd/src/epmd.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'erts/epmd/src/epmd.c') diff --git a/erts/epmd/src/epmd.c b/erts/epmd/src/epmd.c index 2fd9845d1a..132bda725c 100644 --- a/erts/epmd/src/epmd.c +++ b/erts/epmd/src/epmd.c @@ -4,16 +4,17 @@ * * Copyright Ericsson AB 1998-2013. All Rights Reserved. * - * The contents of this file are subject to the Erlang Public License, - * Version 1.1, (the "License"); you may not use this file except in - * compliance with the License. You should have received a copy of the - * Erlang Public License along with this software. If not, it can be - * retrieved online at http://www.erlang.org/. + * 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 * - * Software distributed under the License is distributed on an "AS IS" - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - * the License for the specific language governing rights and limitations - * under the License. + * 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. * * %CopyrightEnd% */ -- cgit v1.2.3 From c431a065ba515d27830f01c852f70940efb3003b Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Thu, 2 Jul 2015 11:13:32 +0200 Subject: ose: Remove all code related to the OSE port The OSE port is no longer supported and this commit removed it and any changes related to it. The things that were general improvements have been left in the code. --- erts/epmd/src/epmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'erts/epmd/src/epmd.c') diff --git a/erts/epmd/src/epmd.c b/erts/epmd/src/epmd.c index 132bda725c..7c373509be 100644 --- a/erts/epmd/src/epmd.c +++ b/erts/epmd/src/epmd.c @@ -397,7 +397,7 @@ static void run_daemon(EpmdVars *g) } #endif -#if defined(VXWORKS) || defined(__OSE__) +#if defined(VXWORKS) static void run_daemon(EpmdVars *g) { run(g); -- cgit v1.2.3 From cb62ace6eac881e2b42880c6f645afbc56295ee0 Mon Sep 17 00:00:00 2001 From: Henrik Nord Date: Wed, 4 Nov 2015 16:04:54 +0100 Subject: add missing time.h --- erts/epmd/src/epmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'erts/epmd/src/epmd.c') diff --git a/erts/epmd/src/epmd.c b/erts/epmd/src/epmd.c index 132bda725c..63ec18d939 100644 --- a/erts/epmd/src/epmd.c +++ b/erts/epmd/src/epmd.c @@ -29,7 +29,7 @@ #ifdef HAVE_STDLIB_H # include #endif - +#include /* forward declarations */ static void usage(EpmdVars *); -- cgit v1.2.3 From 40695d080b0dc0665b01803768ffc74ed2eca207 Mon Sep 17 00:00:00 2001 From: Michael Santos Date: Sun, 18 Oct 2015 16:20:37 -0400 Subject: epmd: support IPv6 node registration Allow IPv6 nodes to register with and query epmd. On systems with IPv6 support: * epmd listens on both the IPv4 and IPv6 ANY or loopback sockets * the epmd cli client connects to epmd over the IPv6 loopback * distributed nodes started with "-proto_dist inet6_tcp" will register with epmd over IPv6 To work on IPv6 capable systems that have IPv6 support disabled, epmd ignores errors opening the socket if the protocol is not supported. Similarly, the epmd client will fall back to IPv4 if the IPv6 socket is not available. Update the minimum supported version of Windows to Windows Vista to support IPv6. --- erts/epmd/src/epmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'erts/epmd/src/epmd.c') diff --git a/erts/epmd/src/epmd.c b/erts/epmd/src/epmd.c index 63ec18d939..5513cb2d7e 100644 --- a/erts/epmd/src/epmd.c +++ b/erts/epmd/src/epmd.c @@ -343,7 +343,7 @@ static void run_daemon(EpmdVars *g) for (fd = 0; fd < g->max_conn ; fd++) /* close all files ... */ close(fd); /* Syslog on linux will try to write to whatever if we dont - inform it of that the log is closed. */ + inform it that the log is closed. */ closelog(); /* These shouldn't be needed but for safety... */ -- cgit v1.2.3 From 6664eed554974336909d3ffe03f20349cc4c38fd Mon Sep 17 00:00:00 2001 From: Henrik Nord Date: Tue, 15 Mar 2016 15:19:56 +0100 Subject: update copyright-year --- erts/epmd/src/epmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'erts/epmd/src/epmd.c') diff --git a/erts/epmd/src/epmd.c b/erts/epmd/src/epmd.c index 324ae6ac40..b36f4ccd40 100644 --- a/erts/epmd/src/epmd.c +++ b/erts/epmd/src/epmd.c @@ -2,7 +2,7 @@ /* * %CopyrightBegin% * - * Copyright Ericsson AB 1998-2013. All Rights Reserved. + * Copyright Ericsson AB 1998-2016. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. -- cgit v1.2.3 From 16b921ad1c847ba0754adc10d2d45b17973dcd19 Mon Sep 17 00:00:00 2001 From: Alexey Lebedeff Date: Tue, 29 Mar 2016 20:30:22 +0300 Subject: Don't send unasked for systemd notifications Suppose we have some erlang system that uses systemd unit with Type=notify - so this should send startup confirmation itself. But if systemd-enabled epmd will be started as a first step of that system startup, empd startup confirmation will be misinterpeted by systemd. And our erlang service will be considered 'ready' to early. Also this will interefere with systemd MAINPID detection: systemd will be monitoring `epmd` process instead of `beam` one. For example, rabbitmq works around this issue by starting epmd using separate short-lived beam process, with NOTIFY_SOCKET environment variable reset - only in this way we could be sure that epmd will not interfere with rabbit startup sequence. This patch disables indiscriminate confirmation sending, and does it only when it was explicitly asked to do so. --- erts/epmd/src/epmd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'erts/epmd/src/epmd.c') diff --git a/erts/epmd/src/epmd.c b/erts/epmd/src/epmd.c index 5513cb2d7e..4740ce8534 100644 --- a/erts/epmd/src/epmd.c +++ b/erts/epmd/src/epmd.c @@ -592,8 +592,10 @@ void epmd_cleanup_exit(EpmdVars *g, int exitval) free(g->argv); } #ifdef HAVE_SYSTEMD_DAEMON - sd_notifyf(0, "STATUS=Exited.\n" - "ERRNO=%i", exitval); + if (g->is_systemd){ + sd_notifyf(0, "STATUS=Exited.\n" + "ERRNO=%i", exitval); + } #endif /* HAVE_SYSTEMD_DAEMON */ exit(exitval); } -- cgit v1.2.3