summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDidier Raboud <odyx@debian.org>2016-06-10 17:56:23 -0400
committerThomas Haller <thaller@redhat.com>2016-06-17 12:21:20 +0200
commitf90abce4d55c37955dcef8b50867bbfec33ad06b (patch)
treea62ae13c7333ae2940c24f62d92782daf115549b
parent16c368b8eb03bef225208dcfc3b0e62e8f1ce650 (diff)
downloadNetworkManager-f90abce4d55c37955dcef8b50867bbfec33ad06b.tar.gz
wwan: check at runtime whether to start ModemManager
This makes NetworkManager use runtime detection to manage the ModemManager lifecycle when not run by systemd. Under systemd, we expect the ModemManager service to be started by systemd, under non-systemd, we use the dbus activation feature to start ModemManager. [thaller@redhat.com: original patch heavily modified to check for available libsystemd library] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=770871 https://mail.gnome.org/archives/networkmanager-list/2016-June/msg00086.html
-rw-r--r--configure.ac4
-rw-r--r--src/devices/wwan/Makefile.am2
-rw-r--r--src/devices/wwan/nm-modem-manager.c20
3 files changed, 16 insertions, 10 deletions
diff --git a/configure.ac b/configure.ac
index c8d72d3cca..e93975b15c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -375,6 +375,10 @@ elif test "$hostname_persist" = slackware; then
AC_DEFINE(HOSTNAME_PERSIST_SLACKWARE, 1, [Enable Slackware hostname persist method])
fi
+PKG_CHECK_MODULES(LIBSYSTEMD, [libsystemd >= 209],
+ [AC_DEFINE([HAVE_LIBSYSTEMD], 1, [Define to 1 if libsystemd is available])],
+ [AC_DEFINE([HAVE_LIBSYSTEMD], 0, [Define to 1 if libsystemd is available])])
+
AC_ARG_WITH(systemd-journal, AS_HELP_STRING([--with-systemd-journal=yes|no], [Use systemd journal for logging]))
have_systemd_journal=no
if test "$with_systemd_journal" != "no"; then
diff --git a/src/devices/wwan/Makefile.am b/src/devices/wwan/Makefile.am
index 1777eb3639..95e8ec8d60 100644
--- a/src/devices/wwan/Makefile.am
+++ b/src/devices/wwan/Makefile.am
@@ -16,6 +16,7 @@ AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\""NetworkManager-wwan"\" \
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
$(GLIB_CFLAGS) \
+ $(LIBSYSTEMD_CFLAGS) \
$(MM_GLIB_CFLAGS)
BUILT_SOURCES = $(null)
@@ -49,6 +50,7 @@ libnm_wwan_la_LDFLAGS = \
libnm_wwan_la_LIBADD = \
$(top_builddir)/introspection/libnmdbus.la \
$(GLIB_LIBS) \
+ $(LIBSYSTEMD_LIBS) \
$(MM_GLIB_LIBS)
###########################################################
diff --git a/src/devices/wwan/nm-modem-manager.c b/src/devices/wwan/nm-modem-manager.c
index e26321b0a4..b159d1f8d2 100644
--- a/src/devices/wwan/nm-modem-manager.c
+++ b/src/devices/wwan/nm-modem-manager.c
@@ -31,6 +31,12 @@
#include "nm-modem.h"
#include "nm-modem-broadband.h"
+#if HAVE_LIBSYSTEMD
+#include <systemd/sd-daemon.h>
+#else
+#define sd_booted() FALSE
+#endif
+
#define MODEM_POKE_INTERVAL 120
G_DEFINE_TYPE (NMModemManager, nm_modem_manager, G_TYPE_OBJECT)
@@ -199,10 +205,9 @@ modem_manager_name_owner_changed (MMManager *modem_manager,
if (!name_owner) {
nm_log_info (LOGD_MB, "ModemManager disappeared from bus");
-#if !HAVE_SYSTEMD
/* If not managed by systemd, schedule relaunch */
- schedule_modem_manager_relaunch (self, 0);
-#endif
+ if (!sd_booted ())
+ schedule_modem_manager_relaunch (self, 0);
return;
}
@@ -223,8 +228,6 @@ modem_manager_name_owner_changed (MMManager *modem_manager,
*/
}
-#if !HAVE_SYSTEMD
-
static void
modem_manager_poke_cb (GDBusConnection *connection,
GAsyncResult *res,
@@ -273,8 +276,6 @@ modem_manager_poke (NMModemManager *self)
g_object_ref (self)); /* user_data */
}
-#endif /* HAVE_SYSTEMD */
-
static void
modem_manager_check_name_owner (NMModemManager *self)
{
@@ -288,10 +289,9 @@ modem_manager_check_name_owner (NMModemManager *self)
return;
}
-#if !HAVE_SYSTEMD
/* If the lifecycle is not managed by systemd, poke */
- modem_manager_poke (self);
-#endif
+ if (!sd_booted ())
+ modem_manager_poke (self);
}
static void