summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiří Klimeš <jklimes@redhat.com>2014-09-09 13:32:46 +0200
committerJiří Klimeš <jklimes@redhat.com>2014-09-12 12:49:16 +0200
commitb27669612e9cafa47714f57f42065227b2dd62d6 (patch)
treea1b48c17aaf42f3a7580b43c45023104dd95537b
parent6d659ab2cdaf9d728ffad46f023a35c038e7648d (diff)
downloadNetworkManager-b27669612e9cafa47714f57f42065227b2dd62d6.tar.gz
dhcp: fix dhclient abnormal exit due to SIGPIPE (bgo #735962)
DHCP client may be killed by SIGPIPE when attempting to write to a broken pipe. This can be observed, for example, when journald is restarted. Fix that by redirecting both stdout and stderr to /dev/null. The client logs into syslog anyway. When NetworkManager is run with '--debug' we duplicate syslog to stderr, so the messages goes to terminal as well. Testcase: - start a NetworkManager service by systemd - activate an DHCP ethernet connection - sudo systemctl restart systemd-journald.service - reactive the ethernet connection (nmcli con up <my-eth>) - DHCP client is killed by SIGPIPE right after its startup: <info> (enp0s25): DHCPv4 client pid 13959 exited with status -1 <warn> DHCP client died abnormally Another possible fix would be ignoring SIGPIPE in the DHCP client as it is not useful in most cases. E.g. systemd ignores SIGPIPE for its services, by default: http://cgit.freedesktop.org/systemd/systemd/commit/?id=353e12c2f4a9e96a47eb80b80d2ffb7bc1d44a1b https://bugzilla.gnome.org/show_bug.cgi?id=735962
-rw-r--r--src/dhcp-manager/nm-dhcp-dhclient.c10
-rw-r--r--src/dhcp-manager/nm-dhcp-dhcpcd.c3
2 files changed, 10 insertions, 3 deletions
diff --git a/src/dhcp-manager/nm-dhcp-dhclient.c b/src/dhcp-manager/nm-dhcp-dhclient.c
index 74b416a7bb..e4b37377bc 100644
--- a/src/dhcp-manager/nm-dhcp-dhclient.c
+++ b/src/dhcp-manager/nm-dhcp-dhclient.c
@@ -402,6 +402,11 @@ dhclient_start (NMDhcpClient *client,
g_ptr_array_add (argv, (gpointer) "-d");
+ /* Be quiet. dhclient logs to syslog anyway. And we duplicate the syslog
+ * to stderr in case of NM running with --debug.
+ */
+ g_ptr_array_add (argv, (gpointer) "-q");
+
if (release)
g_ptr_array_add (argv, (gpointer) "-r");
@@ -445,8 +450,9 @@ dhclient_start (NMDhcpClient *client,
nm_log_dbg (log_domain, "running: %s", cmd_str);
g_free (cmd_str);
- if (g_spawn_async (NULL, (char **) argv->pdata, NULL, G_SPAWN_DO_NOT_REAP_CHILD,
- &dhclient_child_setup, NULL, &pid, &error)) {
+ if (g_spawn_async (NULL, (char **) argv->pdata, NULL,
+ G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
+ &dhclient_child_setup, NULL, &pid, &error)) {
g_assert (pid > 0);
nm_log_info (log_domain, "dhclient started with pid %d", pid);
if (release == FALSE)
diff --git a/src/dhcp-manager/nm-dhcp-dhcpcd.c b/src/dhcp-manager/nm-dhcp-dhcpcd.c
index 98b54b10f4..a018c4cd42 100644
--- a/src/dhcp-manager/nm-dhcp-dhcpcd.c
+++ b/src/dhcp-manager/nm-dhcp-dhcpcd.c
@@ -141,7 +141,8 @@ ip4_start (NMDhcpClient *client,
nm_log_dbg (LOGD_DHCP4, "running: %s", cmd_str);
g_free (cmd_str);
- if (g_spawn_async (NULL, (char **) argv->pdata, NULL, G_SPAWN_DO_NOT_REAP_CHILD,
+ if (g_spawn_async (NULL, (char **) argv->pdata, NULL,
+ G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
&dhcpcd_child_setup, NULL, &pid, &error)) {
g_assert (pid > 0);
nm_log_info (LOGD_DHCP4, "dhcpcd started with pid %d", pid);