core: unblock signals for child processes we spawn out of NM (rh #739836)
Commit 217c5bf6ac
fixed processing of unix
signals: signals are blocked in all threads and a dedicated thread handles the
signals using sigwait().
However, the commit forgot that child processes inherit signal mask as well.
That is why we have to unblock signals for child processes we spawn from NM, so
that they can receive signals.
This commit is contained in:
@@ -735,6 +735,7 @@ src/Makefile
|
|||||||
src/tests/Makefile
|
src/tests/Makefile
|
||||||
src/generated/Makefile
|
src/generated/Makefile
|
||||||
src/logging/Makefile
|
src/logging/Makefile
|
||||||
|
src/posix-signals/Makefile
|
||||||
src/dns-manager/Makefile
|
src/dns-manager/Makefile
|
||||||
src/vpn-manager/Makefile
|
src/vpn-manager/Makefile
|
||||||
src/dhcp-manager/Makefile
|
src/dhcp-manager/Makefile
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
SUBDIRS= \
|
SUBDIRS= \
|
||||||
generated \
|
generated \
|
||||||
logging \
|
logging \
|
||||||
|
posix-signals \
|
||||||
dns-manager \
|
dns-manager \
|
||||||
vpn-manager \
|
vpn-manager \
|
||||||
dhcp-manager \
|
dhcp-manager \
|
||||||
@@ -27,6 +28,7 @@ INCLUDES = -I${top_srcdir} \
|
|||||||
-I${top_srcdir}/src/generated \
|
-I${top_srcdir}/src/generated \
|
||||||
-I${top_builddir}/src/generated \
|
-I${top_builddir}/src/generated \
|
||||||
-I${top_srcdir}/src/logging \
|
-I${top_srcdir}/src/logging \
|
||||||
|
-I${top_srcdir}/src/posix-signals \
|
||||||
-I${top_srcdir}/src/dns-manager \
|
-I${top_srcdir}/src/dns-manager \
|
||||||
-I${top_srcdir}/src/vpn-manager \
|
-I${top_srcdir}/src/vpn-manager \
|
||||||
-I${top_srcdir}/src/dhcp-manager \
|
-I${top_srcdir}/src/dhcp-manager \
|
||||||
@@ -304,6 +306,7 @@ endif
|
|||||||
NetworkManager_LDADD = \
|
NetworkManager_LDADD = \
|
||||||
./generated/libnm-generated.la \
|
./generated/libnm-generated.la \
|
||||||
./logging/libnm-logging.la \
|
./logging/libnm-logging.la \
|
||||||
|
./posix-signals/libnm-posix-signals.la \
|
||||||
./dns-manager/libdns-manager.la \
|
./dns-manager/libdns-manager.la \
|
||||||
./vpn-manager/libvpn-manager.la \
|
./vpn-manager/libvpn-manager.la \
|
||||||
./dhcp-manager/libdhcp-manager.la \
|
./dhcp-manager/libdhcp-manager.la \
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2004 - 2011 Red Hat, Inc.
|
* Copyright (C) 2004 - 2012 Red Hat, Inc.
|
||||||
* Copyright (C) 2005 - 2008 Novell, Inc.
|
* Copyright (C) 2005 - 2008 Novell, Inc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -41,6 +41,7 @@
|
|||||||
#include "nm-setting-wireless.h"
|
#include "nm-setting-wireless.h"
|
||||||
#include "nm-setting-wireless-security.h"
|
#include "nm-setting-wireless-security.h"
|
||||||
#include "nm-manager-auth.h"
|
#include "nm-manager-auth.h"
|
||||||
|
#include "nm-posix-signals.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* nm_ethernet_address_is_valid
|
* nm_ethernet_address_is_valid
|
||||||
@@ -94,7 +95,7 @@ nm_spawn_process (const char *args)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_spawn_sync ("/", argv, NULL, 0, NULL, NULL, NULL, NULL, &status, &error)) {
|
if (!g_spawn_sync ("/", argv, NULL, 0, nm_unblock_posix_signals, NULL, NULL, NULL, &status, &error)) {
|
||||||
nm_log_warn (LOGD_CORE, "could not spawn process '%s': %s", args, error->message);
|
nm_log_warn (LOGD_CORE, "could not spawn process '%s': %s", args, error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
}
|
}
|
||||||
|
@@ -7,6 +7,7 @@ INCLUDES = \
|
|||||||
-I${top_srcdir}/src/generated \
|
-I${top_srcdir}/src/generated \
|
||||||
-I${top_builddir}/src/generated \
|
-I${top_builddir}/src/generated \
|
||||||
-I${top_srcdir}/src/logging \
|
-I${top_srcdir}/src/logging \
|
||||||
|
-I${top_srcdir}/src/posix-signals \
|
||||||
-I${top_srcdir}/libnm-util \
|
-I${top_srcdir}/libnm-util \
|
||||||
-I${top_builddir}/libnm-util \
|
-I${top_builddir}/libnm-util \
|
||||||
-I${top_srcdir}/src
|
-I${top_srcdir}/src
|
||||||
@@ -33,6 +34,7 @@ libdhcp_dhclient_la_CPPFLAGS = \
|
|||||||
|
|
||||||
libdhcp_dhclient_la_LIBADD = \
|
libdhcp_dhclient_la_LIBADD = \
|
||||||
$(top_builddir)/src/logging/libnm-logging.la \
|
$(top_builddir)/src/logging/libnm-logging.la \
|
||||||
|
$(top_builddir)/src/posix-signals/libnm-posix-signals.la \
|
||||||
$(top_builddir)/libnm-util/libnm-util.la \
|
$(top_builddir)/libnm-util/libnm-util.la \
|
||||||
$(DBUS_LIBS) \
|
$(DBUS_LIBS) \
|
||||||
$(GLIB_LIBS)
|
$(GLIB_LIBS)
|
||||||
@@ -58,6 +60,7 @@ libdhcp_manager_la_CPPFLAGS = \
|
|||||||
|
|
||||||
libdhcp_manager_la_LIBADD = \
|
libdhcp_manager_la_LIBADD = \
|
||||||
$(top_builddir)/src/logging/libnm-logging.la \
|
$(top_builddir)/src/logging/libnm-logging.la \
|
||||||
|
$(top_builddir)/src/posix-signals/libnm-posix-signals.la \
|
||||||
$(builddir)/libdhcp-dhclient.la \
|
$(builddir)/libdhcp-dhclient.la \
|
||||||
$(DBUS_LIBS) \
|
$(DBUS_LIBS) \
|
||||||
$(GLIB_LIBS)
|
$(GLIB_LIBS)
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2005 - 2010 Red Hat, Inc.
|
* Copyright (C) 2005 - 2012 Red Hat, Inc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _XOPEN_SOURCE
|
#define _XOPEN_SOURCE
|
||||||
@@ -40,6 +40,7 @@
|
|||||||
#include "nm-utils.h"
|
#include "nm-utils.h"
|
||||||
#include "nm-logging.h"
|
#include "nm-logging.h"
|
||||||
#include "nm-dhcp-dhclient-utils.h"
|
#include "nm-dhcp-dhclient-utils.h"
|
||||||
|
#include "nm-posix-signals.h"
|
||||||
|
|
||||||
G_DEFINE_TYPE (NMDHCPDhclient, nm_dhcp_dhclient, NM_TYPE_DHCP_CLIENT)
|
G_DEFINE_TYPE (NMDHCPDhclient, nm_dhcp_dhclient, NM_TYPE_DHCP_CLIENT)
|
||||||
|
|
||||||
@@ -407,6 +408,12 @@ dhclient_child_setup (gpointer user_data G_GNUC_UNUSED)
|
|||||||
/* We are in the child process at this point */
|
/* We are in the child process at this point */
|
||||||
pid_t pid = getpid ();
|
pid_t pid = getpid ();
|
||||||
setpgid (pid, pid);
|
setpgid (pid, pid);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We blocked signals in main(). We need to restore original signal
|
||||||
|
* mask for dhclient here so that it can receive signals.
|
||||||
|
*/
|
||||||
|
nm_unblock_posix_signals (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GPid
|
static GPid
|
||||||
|
@@ -35,6 +35,7 @@
|
|||||||
#include "nm-dhcp-dhcpcd.h"
|
#include "nm-dhcp-dhcpcd.h"
|
||||||
#include "nm-utils.h"
|
#include "nm-utils.h"
|
||||||
#include "nm-logging.h"
|
#include "nm-logging.h"
|
||||||
|
#include "nm-posix-signals.h"
|
||||||
|
|
||||||
G_DEFINE_TYPE (NMDHCPDhcpcd, nm_dhcp_dhcpcd, NM_TYPE_DHCP_CLIENT)
|
G_DEFINE_TYPE (NMDHCPDhcpcd, nm_dhcp_dhcpcd, NM_TYPE_DHCP_CLIENT)
|
||||||
|
|
||||||
@@ -83,6 +84,12 @@ dhcpcd_child_setup (gpointer user_data G_GNUC_UNUSED)
|
|||||||
/* We are in the child process at this point */
|
/* We are in the child process at this point */
|
||||||
pid_t pid = getpid ();
|
pid_t pid = getpid ();
|
||||||
setpgid (pid, pid);
|
setpgid (pid, pid);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We blocked signals in main(). We need to restore original signal
|
||||||
|
* mask for dhcpcd here so that it can receive signals.
|
||||||
|
*/
|
||||||
|
nm_unblock_posix_signals (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GPid
|
static GPid
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
INCLUDES = \
|
INCLUDES = \
|
||||||
-I${top_srcdir}/src/logging \
|
-I${top_srcdir}/src/logging \
|
||||||
|
-I${top_srcdir}/src/posix-signals \
|
||||||
-I${top_srcdir}/libnm-util \
|
-I${top_srcdir}/libnm-util \
|
||||||
-I${top_builddir}/libnm-util \
|
-I${top_builddir}/libnm-util \
|
||||||
-I${top_srcdir}/src \
|
-I${top_srcdir}/src \
|
||||||
@@ -28,6 +29,7 @@ libdns_manager_la_CPPFLAGS = \
|
|||||||
|
|
||||||
libdns_manager_la_LIBADD = \
|
libdns_manager_la_LIBADD = \
|
||||||
$(top_builddir)/src/logging/libnm-logging.la \
|
$(top_builddir)/src/logging/libnm-logging.la \
|
||||||
|
$(top_builddir)/src/posix-signals/libnm-posix-signals.la \
|
||||||
$(LIBNL_LIBS) \
|
$(LIBNL_LIBS) \
|
||||||
$(DBUS_LIBS) \
|
$(DBUS_LIBS) \
|
||||||
$(GLIB_LIBS)
|
$(GLIB_LIBS)
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2004 - 2005 Colin Walters <walters@redhat.com>
|
* Copyright (C) 2004 - 2005 Colin Walters <walters@redhat.com>
|
||||||
* Copyright (C) 2004 - 2011 Red Hat, Inc.
|
* Copyright (C) 2004 - 2012 Red Hat, Inc.
|
||||||
* Copyright (C) 2005 - 2008 Novell, Inc.
|
* Copyright (C) 2005 - 2008 Novell, Inc.
|
||||||
* and others
|
* and others
|
||||||
*/
|
*/
|
||||||
@@ -42,6 +42,7 @@
|
|||||||
#include "nm-logging.h"
|
#include "nm-logging.h"
|
||||||
#include "backends/nm-backend.h"
|
#include "backends/nm-backend.h"
|
||||||
#include "NetworkManagerUtils.h"
|
#include "NetworkManagerUtils.h"
|
||||||
|
#include "nm-posix-signals.h"
|
||||||
|
|
||||||
#include "nm-dns-plugin.h"
|
#include "nm-dns-plugin.h"
|
||||||
#include "nm-dns-dnsmasq.h"
|
#include "nm-dns-dnsmasq.h"
|
||||||
@@ -218,6 +219,12 @@ netconfig_child_setup (gpointer user_data G_GNUC_UNUSED)
|
|||||||
{
|
{
|
||||||
pid_t pid = getpid ();
|
pid_t pid = getpid ();
|
||||||
setpgid (pid, pid);
|
setpgid (pid, pid);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We blocked signals in main(). We need to restore original signal
|
||||||
|
* mask for netconfig here so that it can receive signals.
|
||||||
|
*/
|
||||||
|
nm_unblock_posix_signals (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GPid
|
static GPid
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010 Red Hat, Inc.
|
* Copyright (C) 2010 - 2012 Red Hat, Inc.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include "nm-dns-plugin.h"
|
#include "nm-dns-plugin.h"
|
||||||
#include "nm-logging.h"
|
#include "nm-logging.h"
|
||||||
|
#include "nm-posix-signals.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gboolean disposed;
|
gboolean disposed;
|
||||||
@@ -141,6 +142,12 @@ child_setup (gpointer user_data G_GNUC_UNUSED)
|
|||||||
/* We are in the child process at this point */
|
/* We are in the child process at this point */
|
||||||
pid_t pid = getpid ();
|
pid_t pid = getpid ();
|
||||||
setpgid (pid, pid);
|
setpgid (pid, pid);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We blocked signals in main(). We need to restore original signal
|
||||||
|
* mask for DNS plugin here so that it can receive signals.
|
||||||
|
*/
|
||||||
|
nm_unblock_posix_signals (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
GPid
|
GPid
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
INCLUDES = \
|
INCLUDES = \
|
||||||
-I${top_srcdir}/libnm-util \
|
-I${top_srcdir}/libnm-util \
|
||||||
-I${top_srcdir}/src/logging \
|
-I${top_srcdir}/src/logging \
|
||||||
|
-I${top_srcdir}/src/posix-signals \
|
||||||
-I${top_srcdir}/src \
|
-I${top_srcdir}/src \
|
||||||
-I${top_srcdir}/include
|
-I${top_srcdir}/include
|
||||||
|
|
||||||
@@ -16,4 +17,5 @@ libdnsmasq_manager_la_CPPFLAGS = \
|
|||||||
|
|
||||||
libdnsmasq_manager_la_LIBADD = \
|
libdnsmasq_manager_la_LIBADD = \
|
||||||
$(top_builddir)/src/logging/libnm-logging.la \
|
$(top_builddir)/src/logging/libnm-logging.la \
|
||||||
|
$(top_builddir)/src/posix-signals/libnm-posix-signals.la \
|
||||||
$(GLIB_LIBS)
|
$(GLIB_LIBS)
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008 - 2010 Red Hat, Inc.
|
* Copyright (C) 2008 - 2012 Red Hat, Inc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
@@ -30,6 +30,7 @@
|
|||||||
#include "nm-dnsmasq-manager.h"
|
#include "nm-dnsmasq-manager.h"
|
||||||
#include "nm-logging.h"
|
#include "nm-logging.h"
|
||||||
#include "nm-glib-compat.h"
|
#include "nm-glib-compat.h"
|
||||||
|
#include "nm-posix-signals.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *iface;
|
char *iface;
|
||||||
@@ -356,6 +357,12 @@ dm_child_setup (gpointer user_data G_GNUC_UNUSED)
|
|||||||
/* We are in the child process at this point */
|
/* We are in the child process at this point */
|
||||||
pid_t pid = getpid ();
|
pid_t pid = getpid ();
|
||||||
setpgid (pid, pid);
|
setpgid (pid, pid);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We blocked signals in main(). We need to restore original signal
|
||||||
|
* mask for dnsmasq here so that it can receive signals.
|
||||||
|
*/
|
||||||
|
nm_unblock_posix_signals (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -54,6 +54,7 @@
|
|||||||
#include "nm-logging.h"
|
#include "nm-logging.h"
|
||||||
#include "nm-policy-hosts.h"
|
#include "nm-policy-hosts.h"
|
||||||
#include "nm-config.h"
|
#include "nm-config.h"
|
||||||
|
#include "nm-posix-signals.h"
|
||||||
|
|
||||||
#if !defined(NM_DIST_VERSION)
|
#if !defined(NM_DIST_VERSION)
|
||||||
# define NM_DIST_VERSION VERSION
|
# define NM_DIST_VERSION VERSION
|
||||||
@@ -135,6 +136,7 @@ static gboolean
|
|||||||
setup_signals (void)
|
setup_signals (void)
|
||||||
{
|
{
|
||||||
pthread_t signal_thread_id;
|
pthread_t signal_thread_id;
|
||||||
|
sigset_t old_sig_mask;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
sigemptyset (&signal_set);
|
sigemptyset (&signal_set);
|
||||||
@@ -151,11 +153,13 @@ setup_signals (void)
|
|||||||
sigaddset (&signal_set, SIGUSR1);
|
sigaddset (&signal_set, SIGUSR1);
|
||||||
|
|
||||||
/* Block all signals of interest. */
|
/* Block all signals of interest. */
|
||||||
status = pthread_sigmask (SIG_BLOCK, &signal_set, NULL);
|
status = pthread_sigmask (SIG_BLOCK, &signal_set, &old_sig_mask);
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
fprintf (stderr, _("Failed to set signal mask: %d"), status);
|
fprintf (stderr, _("Failed to set signal mask: %d"), status);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
/* Save original mask so that we could use it for child processes. */
|
||||||
|
nm_save_original_signal_mask (old_sig_mask);
|
||||||
|
|
||||||
/* Create the signal handling thread. */
|
/* Create the signal handling thread. */
|
||||||
status = pthread_create (&signal_thread_id, NULL, signal_handling_thread, NULL);
|
status = pthread_create (&signal_thread_id, NULL, signal_handling_thread, NULL);
|
||||||
|
@@ -36,6 +36,7 @@
|
|||||||
#include "nm-device.h"
|
#include "nm-device.h"
|
||||||
#include "nm-active-connection.h"
|
#include "nm-active-connection.h"
|
||||||
#include "nm-settings-connection.h"
|
#include "nm-settings-connection.h"
|
||||||
|
#include "nm-posix-signals.h"
|
||||||
|
|
||||||
|
|
||||||
G_DEFINE_TYPE (NMActRequest, nm_act_request, NM_TYPE_ACTIVE_CONNECTION)
|
G_DEFINE_TYPE (NMActRequest, nm_act_request, NM_TYPE_ACTIVE_CONNECTION)
|
||||||
@@ -261,6 +262,8 @@ share_child_setup (gpointer user_data G_GNUC_UNUSED)
|
|||||||
/* We are in the child process at this point */
|
/* We are in the child process at this point */
|
||||||
pid_t pid = getpid ();
|
pid_t pid = getpid ();
|
||||||
setpgid (pid, pid);
|
setpgid (pid, pid);
|
||||||
|
|
||||||
|
nm_unblock_posix_signals (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -62,6 +62,7 @@
|
|||||||
#include "nm-enum-types.h"
|
#include "nm-enum-types.h"
|
||||||
#include "nm-settings-connection.h"
|
#include "nm-settings-connection.h"
|
||||||
#include "nm-connection-provider.h"
|
#include "nm-connection-provider.h"
|
||||||
|
#include "nm-posix-signals.h"
|
||||||
|
|
||||||
static void impl_device_disconnect (NMDevice *device, DBusGMethodInvocation *context);
|
static void impl_device_disconnect (NMDevice *device, DBusGMethodInvocation *context);
|
||||||
|
|
||||||
@@ -1379,6 +1380,12 @@ aipd_child_setup (gpointer user_data G_GNUC_UNUSED)
|
|||||||
*/
|
*/
|
||||||
pid_t pid = getpid ();
|
pid_t pid = getpid ();
|
||||||
setpgid (pid, pid);
|
setpgid (pid, pid);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We blocked signals in main(). We need to restore original signal
|
||||||
|
* mask for avahi-autoipd here so that it can receive signals.
|
||||||
|
*/
|
||||||
|
nm_unblock_posix_signals (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static NMActStageReturn
|
static NMActStageReturn
|
||||||
@@ -2600,6 +2607,8 @@ share_child_setup (gpointer user_data G_GNUC_UNUSED)
|
|||||||
/* We are in the child process at this point */
|
/* We are in the child process at this point */
|
||||||
pid_t pid = getpid ();
|
pid_t pid = getpid ();
|
||||||
setpgid (pid, pid);
|
setpgid (pid, pid);
|
||||||
|
|
||||||
|
nm_unblock_posix_signals (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
15
src/posix-signals/Makefile.am
Normal file
15
src/posix-signals/Makefile.am
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
noinst_LTLIBRARIES = libnm-posix-signals.la
|
||||||
|
|
||||||
|
libnm_posix_signals_la_SOURCES = \
|
||||||
|
nm-posix-signals.c \
|
||||||
|
nm-posix-signals.h
|
||||||
|
|
||||||
|
libnm_posix_signals_la_CPPFLAGS = \
|
||||||
|
$(GLIB_CFLAGS) \
|
||||||
|
-DLIBEXECDIR=\"$(libexecdir)\" \
|
||||||
|
-DG_DISABLE_DEPRECATED
|
||||||
|
|
||||||
|
libnm_posix_signals_la_LIBADD = \
|
||||||
|
-ldl \
|
||||||
|
$(GLIB_LIBS)
|
||||||
|
|
62
src/posix-signals/nm-posix-signals.c
Normal file
62
src/posix-signals/nm-posix-signals.c
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||||
|
/* NetworkManager -- Network link manager
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Red Hat, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
|
#include "nm-posix-signals.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* Stores the original signal mask of NetworkManager process */
|
||||||
|
static sigset_t nm_original_signal_mask;
|
||||||
|
|
||||||
|
void
|
||||||
|
nm_save_original_signal_mask (sigset_t sig_mask)
|
||||||
|
{
|
||||||
|
nm_original_signal_mask = sig_mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
const sigset_t *
|
||||||
|
nm_get_original_signal_mask (void)
|
||||||
|
{
|
||||||
|
return &nm_original_signal_mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Unblock signals.
|
||||||
|
* If a signal set is passed, those signals are unblocked. If user_data is NULL
|
||||||
|
* the process' signal mask is set to the saved original mask.
|
||||||
|
* Note: This function can be used in g_spawn_* as GSpawnChildSetupFunc()
|
||||||
|
* callback.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
nm_unblock_posix_signals (gpointer user_data)
|
||||||
|
{
|
||||||
|
sigset_t *user_sigset = (sigset_t *) user_data;
|
||||||
|
|
||||||
|
if (user_sigset != NULL) {
|
||||||
|
pthread_sigmask (SIG_UNBLOCK, user_sigset, NULL);
|
||||||
|
} else {
|
||||||
|
const sigset_t *orig_sig_mask = nm_get_original_signal_mask ();
|
||||||
|
pthread_sigmask (SIG_SETMASK, orig_sig_mask, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
36
src/posix-signals/nm-posix-signals.h
Normal file
36
src/posix-signals/nm-posix-signals.h
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||||
|
/* NetworkManager -- Network link manager
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Red Hat, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NM_POSIX_SIGNALS_H
|
||||||
|
#define NM_POSIX_SIGNALS_H
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This function can be used in g_spawn_* as GSpawnChildSetupFunc()
|
||||||
|
* callback.
|
||||||
|
*/
|
||||||
|
void nm_unblock_posix_signals (gpointer user_data);
|
||||||
|
|
||||||
|
void nm_save_original_signal_mask (sigset_t sig_mask);
|
||||||
|
const sigset_t *nm_get_original_signal_mask (void);
|
||||||
|
|
||||||
|
#endif /* NM_POSIX_SIGNALS_H */
|
@@ -7,7 +7,8 @@ INCLUDES = \
|
|||||||
-I${top_srcdir}/src \
|
-I${top_srcdir}/src \
|
||||||
-I${top_srcdir}/src/generated \
|
-I${top_srcdir}/src/generated \
|
||||||
-I${top_builddir}/src/generated \
|
-I${top_builddir}/src/generated \
|
||||||
-I${top_srcdir}/src/logging
|
-I${top_srcdir}/src/logging \
|
||||||
|
-I${top_srcdir}/src/posix-signals
|
||||||
|
|
||||||
noinst_LTLIBRARIES = libppp-manager.la
|
noinst_LTLIBRARIES = libppp-manager.la
|
||||||
|
|
||||||
@@ -33,6 +34,7 @@ libppp_manager_la_CPPFLAGS = \
|
|||||||
libppp_manager_la_LIBADD = \
|
libppp_manager_la_LIBADD = \
|
||||||
$(top_builddir)/src/generated/libnm-generated.la \
|
$(top_builddir)/src/generated/libnm-generated.la \
|
||||||
$(top_builddir)/src/logging/libnm-logging.la \
|
$(top_builddir)/src/logging/libnm-logging.la \
|
||||||
|
$(top_builddir)/src/posix-signals/libnm-posix-signals.la \
|
||||||
$(DBUS_LIBS) \
|
$(DBUS_LIBS) \
|
||||||
$(GLIB_LIBS)
|
$(GLIB_LIBS)
|
||||||
|
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008 Novell, Inc.
|
* Copyright (C) 2008 Novell, Inc.
|
||||||
* Copyright (C) 2008 - 2011 Red Hat, Inc.
|
* Copyright (C) 2008 - 2012 Red Hat, Inc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
@@ -53,6 +53,7 @@
|
|||||||
#include "nm-dbus-manager.h"
|
#include "nm-dbus-manager.h"
|
||||||
#include "nm-logging.h"
|
#include "nm-logging.h"
|
||||||
#include "nm-marshal.h"
|
#include "nm-marshal.h"
|
||||||
|
#include "nm-posix-signals.h"
|
||||||
|
|
||||||
static void impl_ppp_manager_need_secrets (NMPPPManager *manager,
|
static void impl_ppp_manager_need_secrets (NMPPPManager *manager,
|
||||||
DBusGMethodInvocation *context);
|
DBusGMethodInvocation *context);
|
||||||
@@ -959,6 +960,12 @@ pppd_child_setup (gpointer user_data G_GNUC_UNUSED)
|
|||||||
/* We are in the child process at this point */
|
/* We are in the child process at this point */
|
||||||
pid_t pid = getpid ();
|
pid_t pid = getpid ();
|
||||||
setpgid (pid, pid);
|
setpgid (pid, pid);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We blocked signals in main(). We need to restore original signal
|
||||||
|
* mask for pppd here so that it can receive signals.
|
||||||
|
*/
|
||||||
|
nm_unblock_posix_signals (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -25,6 +25,7 @@ libifcfg_rh_io_la_SOURCES = \
|
|||||||
INCLUDES = \
|
INCLUDES = \
|
||||||
-I$(top_srcdir)/src/wifi \
|
-I$(top_srcdir)/src/wifi \
|
||||||
-I$(top_srcdir)/src/settings \
|
-I$(top_srcdir)/src/settings \
|
||||||
|
-I$(top_srcdir)/src/posix-signals \
|
||||||
-I$(top_srcdir)/include \
|
-I$(top_srcdir)/include \
|
||||||
-I$(top_builddir)/include \
|
-I$(top_builddir)/include \
|
||||||
-I$(top_srcdir)/libnm-glib \
|
-I$(top_srcdir)/libnm-glib \
|
||||||
@@ -40,6 +41,7 @@ libifcfg_rh_io_la_CPPFLAGS = \
|
|||||||
|
|
||||||
libifcfg_rh_io_la_LIBADD = \
|
libifcfg_rh_io_la_LIBADD = \
|
||||||
$(top_builddir)/src/wifi/libwifi-utils.la \
|
$(top_builddir)/src/wifi/libwifi-utils.la \
|
||||||
|
$(top_builddir)/src/posix-signals/libnm-posix-signals.la \
|
||||||
$(top_builddir)/libnm-util/libnm-util.la \
|
$(top_builddir)/libnm-util/libnm-util.la \
|
||||||
$(GLIB_LIBS) \
|
$(GLIB_LIBS) \
|
||||||
$(NSS_LIBS)
|
$(NSS_LIBS)
|
||||||
|
@@ -48,6 +48,7 @@
|
|||||||
#include <nm-utils.h>
|
#include <nm-utils.h>
|
||||||
|
|
||||||
#include "wifi-utils.h"
|
#include "wifi-utils.h"
|
||||||
|
#include "nm-posix-signals.h"
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "shvar.h"
|
#include "shvar.h"
|
||||||
@@ -208,6 +209,12 @@ iscsiadm_child_setup (gpointer user_data G_GNUC_UNUSED)
|
|||||||
*/
|
*/
|
||||||
pid_t pid = getpid ();
|
pid_t pid = getpid ();
|
||||||
setpgid (pid, pid);
|
setpgid (pid, pid);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We blocked signals in main(). We need to restore original signal
|
||||||
|
* mask for iscsiadm here so that it can receive signals.
|
||||||
|
*/
|
||||||
|
nm_unblock_posix_signals (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
|
@@ -7,6 +7,7 @@ INCLUDES = \
|
|||||||
-I${top_srcdir}/src/generated \
|
-I${top_srcdir}/src/generated \
|
||||||
-I${top_builddir}/src/generated \
|
-I${top_builddir}/src/generated \
|
||||||
-I${top_srcdir}/src/logging \
|
-I${top_srcdir}/src/logging \
|
||||||
|
-I${top_srcdir}/src/posix-signals \
|
||||||
-I${top_srcdir}/src \
|
-I${top_srcdir}/src \
|
||||||
-I${top_srcdir}/src/dns-manager \
|
-I${top_srcdir}/src/dns-manager \
|
||||||
-DVPN_NAME_FILES_DIR=\""$(sysconfdir)/NetworkManager/VPN"\"
|
-DVPN_NAME_FILES_DIR=\""$(sysconfdir)/NetworkManager/VPN"\"
|
||||||
@@ -31,6 +32,7 @@ libvpn_manager_la_CPPFLAGS = \
|
|||||||
libvpn_manager_la_LIBADD = \
|
libvpn_manager_la_LIBADD = \
|
||||||
$(top_builddir)/src/generated/libnm-generated.la \
|
$(top_builddir)/src/generated/libnm-generated.la \
|
||||||
$(top_builddir)/src/logging/libnm-logging.la \
|
$(top_builddir)/src/logging/libnm-logging.la \
|
||||||
|
$(top_builddir)/src/posix-signals/libnm-posix-signals.la \
|
||||||
$(top_builddir)/libnm-util/libnm-util.la \
|
$(top_builddir)/libnm-util/libnm-util.la \
|
||||||
$(LIBNL_LIBS) \
|
$(LIBNL_LIBS) \
|
||||||
$(DBUS_LIBS) \
|
$(DBUS_LIBS) \
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2005 - 2011 Red Hat, Inc.
|
* Copyright (C) 2005 - 2012 Red Hat, Inc.
|
||||||
* Copyright (C) 2005 - 2008 Novell, Inc.
|
* Copyright (C) 2005 - 2008 Novell, Inc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -31,6 +31,7 @@
|
|||||||
#include "nm-vpn-service.h"
|
#include "nm-vpn-service.h"
|
||||||
#include "nm-dbus-manager.h"
|
#include "nm-dbus-manager.h"
|
||||||
#include "nm-logging.h"
|
#include "nm-logging.h"
|
||||||
|
#include "nm-posix-signals.h"
|
||||||
#include "nm-vpn-manager.h"
|
#include "nm-vpn-manager.h"
|
||||||
#include "nm-glib-compat.h"
|
#include "nm-glib-compat.h"
|
||||||
|
|
||||||
@@ -168,6 +169,12 @@ nm_vpn_service_child_setup (gpointer user_data G_GNUC_UNUSED)
|
|||||||
/* We are in the child process at this point */
|
/* We are in the child process at this point */
|
||||||
pid_t pid = getpid ();
|
pid_t pid = getpid ();
|
||||||
setpgid (pid, pid);
|
setpgid (pid, pid);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We blocked signals in main(). We need to restore original signal
|
||||||
|
* mask for VPN service here so that it can receive signals.
|
||||||
|
*/
|
||||||
|
nm_unblock_posix_signals (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Reference in New Issue
Block a user