summaryrefslogtreecommitdiff
path: root/debian/patches/Don-t-setup-Sleep-Monitor-if-not-booted-with-systemd.patch
blob: 7840dc7410aec47724b4f8d0cdeaf09fc1f9e9e6 (plain)
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 381b621..13cf1b3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -384,8 +384,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_MSG_ERROR(--with-suspend-resume must be one of [upower, systemd])
diff --git a/src/Makefile.am b/src/Makefile.am
index 7339058..7614cad 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -421,6 +421,7 @@ AM_CPPFLAGS += \
 	$(LIBNDP_CFLAGS) \
 	$(LIBSOUP_CFLAGS) \
 	$(SYSTEMD_LOGIN_CFLAGS) \
+	$(SYSTEMD_INHIBIT_CFLAGS) \
 	$(SYSTEMD_DHCP_CFLAGS) \
 	\
 	-DBINDIR=\"$(bindir)\" \
@@ -459,6 +460,7 @@ libNetworkManager_la_LIBADD = \
 	$(GUDEV_LIBS) \
 	$(LIBNL_LIBS) \
 	$(SYSTEMD_LOGIN_LIBS) \
+	$(SYSTEMD_INHIBIT_LIBS) \
 	$(LIBNDP_LIBS) \
 	$(LIBDL) \
 	$(LIBM)
diff --git a/src/nm-sleep-monitor-systemd.c b/src/nm-sleep-monitor-systemd.c
index c0bc65e..0c97335 100644
--- a/src/nm-sleep-monitor-systemd.c
+++ b/src/nm-sleep-monitor-systemd.c
@@ -25,6 +25,7 @@
 #include <glib/gi18n.h>
 #include <gio/gio.h>
 #include <gio/gunixfdlist.h>
+#include <systemd/sd-daemon.h>
 
 #include "nm-logging.h"
 #include "nm-dbus-manager.h"
@@ -193,6 +194,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 |