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
This commit is contained in:
Didier Raboud 2016-06-10 17:56:23 -04:00 committed by Thomas Haller
parent 16c368b8eb
commit f90abce4d5
3 changed files with 16 additions and 10 deletions

View file

@ -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

View file

@ -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)
###########################################################

View file

@ -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