1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
From: Michael Biebl <biebl@debian.org>
Date: Sat, 12 Apr 2014 12:38:09 +0200
Subject: Don't setup Sleep Monitor if not booted with systemd
NetworkManager uses systemd for suspend/resume support. It listens for
the PrepareForSleep and Resume D-Bus signal sent by logind/systemd and
deactivates the interfaces on sleep and reactivates them on resume.
With a standalone logind we don't get a Resume signal and
NetworkManager remains in sleep mode where the devices are unmanaged.
As a workaround, skip the Sleep Monitor setup if not booted with
systemd.
Closes: #742933
---
configure.ac | 3 ++-
src/Makefile.am | 2 ++
src/nm-sleep-monitor-systemd.c | 5 +++++
3 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 6da6415..b550ab1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -467,8 +467,9 @@ fi
case $with_suspend_resume in
upower) ;;
systemd)
+ # Link against libsystemd-daemon for sd_booted()
PKG_CHECK_MODULES(SYSTEMD_INHIBIT, [libsystemd >= 209],,
- [PKG_CHECK_MODULES(SYSTEMD_INHIBIT, [libsystemd-login >= 183])])
+ [PKG_CHECK_MODULES(SYSTEMD_INHIBIT, [libsystemd-login >= 183 libsystemd-daemon])])
AC_DEFINE([SUSPEND_RESUME_SYSTEMD], 1, [Define to 1 to use systemd suspend api])
;;
consolekit)
diff --git a/src/Makefile.am b/src/Makefile.am
index 7e85831..ca35e1d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -437,6 +437,7 @@ AM_CPPFLAGS += \
$(SELINUX_CFLAGS) \
$(LIBAUDIT_CFLAGS) \
$(SYSTEMD_LOGIN_CFLAGS) \
+ $(SYSTEMD_INHIBIT_CFLAGS) \
$(SYSTEMD_JOURNAL_CFLAGS) \
$(SYSTEMD_NM_CFLAGS_PATHS) \
\
@@ -470,6 +471,7 @@ libNetworkManager_la_LIBADD = \
$(GUDEV_LIBS) \
$(LIBNL_LIBS) \
$(SYSTEMD_LOGIN_LIBS) \
+ $(SYSTEMD_INHIBIT_LIBS) \
$(SYSTEMD_JOURNAL_LIBS) \
$(LIBNDP_LIBS) \
$(LIBDL) \
diff --git a/src/nm-sleep-monitor-systemd.c b/src/nm-sleep-monitor-systemd.c
index 12db56b..f1baa4e 100644
--- a/src/nm-sleep-monitor-systemd.c
+++ b/src/nm-sleep-monitor-systemd.c
@@ -23,6 +23,7 @@
#include <string.h>
#include <sys/stat.h>
#include <gio/gunixfdlist.h>
+#include <systemd/sd-daemon.h>
#include "nm-default.h"
#include "nm-core-internal.h"
@@ -204,6 +205,10 @@ on_proxy_acquired (GObject *object,
static void
nm_sleep_monitor_init (NMSleepMonitor *self)
{
+ if (!sd_booted()) {
+ nm_log_warn (LOGD_SUSPEND, "Skipping Sleep Monitor setup, system not booted with systemd");
+ return;
+ }
self->inhibit_fd = -1;
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START |
|