--- NetworkManager-1.2.2/configure.ac.systemd 2016-05-17 22:29:49.567521947 +0200 +++ NetworkManager-1.2.2/configure.ac 2016-05-17 23:14:31.594510933 +0200 @@ -435,7 +435,7 @@ AS_IF([test -z "$use_consolekit"], [use_ # output session_tracking= if test "$use_systemd_logind" = "yes" -o "$use_systemd_logind" = "auto"; then - PKG_CHECK_MODULES(SYSTEMD_LOGIN, [libsystemd], [have_systemd_logind=yes], [PKG_CHECK_MODULES(SYSTEMD_LOGIN, [libsystemd-login], [have_systemd_logind=yes], [have_systemd_logind=no])]) + PKG_CHECK_MODULES(SYSTEMD_LOGIN, [libsystemd], [have_systemd_logind=yes], [PKG_CHECK_MODULES(SYSTEMD_LOGIN, [libsystemd-daemon libsystemd-login], [have_systemd_logind=yes], [have_systemd_logind=no])]) else have_systemd_logind=no fi @@ -447,12 +447,13 @@ if test "$have_systemd_logind" = "yes"; session_tracking="$session_tracking, systemd-logind" fi if test "$use_consolekit" = "yes"; then - AC_DEFINE([SESSION_TRACKING_CONSOLEKIT], 1, [Define to 1 if ConsoleKit is available]) - AC_DEFINE([CKDB_PATH], "/var/run/ConsoleKit/database", [Path to ConsoleKit database]) + AC_DEFINE([SESSION_TRACKING_CONSOLEKIT], 1, [Define to 1 if ConsoleKit is available]) session_tracking="$session_tracking, consolekit" fi session_tracking="$(printf '%s' "${session_tracking}" | sed 's/^, //')" +AC_DEFINE([CKDB_PATH], "/var/run/ConsoleKit/database", [Path to ConsoleKit database]) + AC_ARG_WITH(suspend-resume, AS_HELP_STRING([--with-suspend-resume=upower|systemd|consolekit], [Build NetworkManager with specific suspend/resume support])) if test "z$with_suspend_resume" = "z"; then PKG_CHECK_EXISTS([libsystemd >= 209], [have_systemd_inhibit=yes], --- NetworkManager-1.4.4/src/nm-session-monitor.c.orig 2016-12-15 20:38:53.000000000 +0100 +++ NetworkManager-1.4.4/src/nm-session-monitor.c 2016-12-18 20:44:54.507822307 +0100 @@ -30,6 +30,7 @@ #include "NetworkManagerUtils.h" #ifdef SESSION_TRACKING_SYSTEMD +#include #include #endif @@ -52,13 +53,11 @@ struct _NMSessionMonitor { } sd; #endif -#ifdef SESSION_TRACKING_CONSOLEKIT struct { GFileMonitor *monitor; GHashTable *cache; time_t timestamp; } ck; -#endif }; struct _NMSessionMonitorClass { @@ -150,7 +149,6 @@ st_sd_finalize (NMSessionMonitor *monito /********************************************************************/ -#ifdef SESSION_TRACKING_CONSOLEKIT typedef struct { gboolean active; } CkSession; @@ -284,7 +282,6 @@ ck_finalize (NMSessionMonitor *monitor) g_clear_pointer (&monitor->ck.cache, g_hash_table_unref); g_clear_object (&monitor->ck.monitor); } -#endif /* SESSION_TRACKING_CONSOLEKIT */ /********************************************************************/ @@ -356,13 +353,16 @@ nm_session_monitor_session_exists (NMSes g_return_val_if_fail (NM_IS_SESSION_MONITOR (self), FALSE); #ifdef SESSION_TRACKING_SYSTEMD - if (st_sd_session_exists (self, uid, active)) - return TRUE; + if (sd_booted () > 0) { + if (st_sd_session_exists (self, uid, active)) + return TRUE; + } else { #endif - -#ifdef SESSION_TRACKING_CONSOLEKIT if (ck_session_exists (self, uid, active)) return TRUE; + +#ifdef SESSION_TRACKING_SYSTEMD + } #endif return FALSE; @@ -374,25 +374,31 @@ static void nm_session_monitor_init (NMSessionMonitor *monitor) { #ifdef SESSION_TRACKING_SYSTEMD + if (sd_booted () > 0) { st_sd_init (monitor); _LOGD ("using systemd-logind session tracking"); + } else #endif -#ifdef SESSION_TRACKING_CONSOLEKIT + { ck_init (monitor); _LOGD ("using ConsoleKit session tracking"); -#endif + } } static void nm_session_monitor_finalize (GObject *object) { #ifdef SESSION_TRACKING_SYSTEMD - st_sd_finalize (NM_SESSION_MONITOR (object)); + if (sd_booted () > 0) { + st_sd_finalize (NM_SESSION_MONITOR (object)); + } else { #endif -#ifdef SESSION_TRACKING_CONSOLEKIT ck_finalize (NM_SESSION_MONITOR (object)); + +#ifdef SESSION_TRACKING_SYSTEMD + } #endif if (G_OBJECT_CLASS (nm_session_monitor_parent_class)->finalize != NULL) --- NetworkManager-1.4.0/src/nm-sleep-monitor.c.orig 2016-08-24 15:09:03.000000000 +0200 +++ NetworkManager-1.4.0/src/nm-sleep-monitor.c 2016-09-27 16:43:07.397044526 +0200 @@ -26,6 +26,10 @@ #include #include +#ifdef SUSPEND_RESUME_SYSTEMD +# include +#endif + #include "nm-core-internal.h" #include "NetworkManagerUtils.h" @@ -40,13 +44,24 @@ #elif defined (SUSPEND_RESUME_SYSTEMD) -#define SUSPEND_DBUS_NAME "org.freedesktop.login1" -#define SUSPEND_DBUS_PATH "/org/freedesktop/login1" -#define SUSPEND_DBUS_INTERFACE "org.freedesktop.login1.Manager" +#define SD_SUSPEND_DBUS_NAME "org.freedesktop.login1" +#define SD_SUSPEND_DBUS_PATH "/org/freedesktop/login1" +#define SD_SUSPEND_DBUS_INTERFACE "org.freedesktop.login1.Manager" #define USE_UPOWER 0 #define _NMLOG_PREFIX_NAME "sleep-monitor-sd" #elif defined(SUSPEND_RESUME_CONSOLEKIT) + +#define USE_UPOWER 0 +#define _NMLOG_PREFIX_NAME "sleep-monitor-ck" + +#else + +#error define one of SUSPEND_RESUME_SYSTEMD, SUSPEND_RESUME_CONSOLEKIT, or SUSPEND_RESUME_UPOWER + +#endif + +#if defined (SUSPEND_RESUME_SYSTEMD) || defined(SUSPEND_RESUME_CONSOLEKIT) /* ConsoleKit2 has added the same suspend/resume DBUS API that Systemd * uses. http://consolekit2.github.io/ConsoleKit2/#Manager.Inhibit @@ -55,12 +70,6 @@ #define SUSPEND_DBUS_NAME "org.freedesktop.ConsoleKit" #define SUSPEND_DBUS_PATH "/org/freedesktop/ConsoleKit/Manager" #define SUSPEND_DBUS_INTERFACE "org.freedesktop.ConsoleKit.Manager" -#define USE_UPOWER 0 -#define _NMLOG_PREFIX_NAME "sleep-monitor-ck" - -#else - -#error define one of SUSPEND_RESUME_SYSTEMD, SUSPEND_RESUME_CONSOLEKIT, or SUSPEND_RESUME_UPOWER #endif @@ -342,6 +351,17 @@ { self->inhibit_fd = -1; self->cancellable = g_cancellable_new (); +#ifdef SUSPEND_RESUME_SYSTEMD + if (sd_booted () > 0) + g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, + G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START | + G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, + NULL, + SD_SUSPEND_DBUS_NAME, SD_SUSPEND_DBUS_PATH, SD_SUSPEND_DBUS_INTERFACE, + self->cancellable, + (GAsyncReadyCallback) on_proxy_acquired, self); + else +#endif g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START | G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,