--- NetworkManager-1.8.0/configure.ac.orig 2017-05-27 22:30:22.001467624 +0200 +++ NetworkManager-1.8.0/configure.ac 2017-05-27 22:57:15.061449204 +0200 @@ -447,7 +447,7 @@ # 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 --- NetworkManager-1.34.0/src/core/nm-session-monitor.c.orig 2022-01-13 15:49:26.000000000 +0100 +++ NetworkManager-1.34.0/src/core/nm-session-monitor.c 2022-01-13 20:47:31.545775434 +0100 @@ -18,6 +18,7 @@ #endif #if SESSION_TRACKING_SYSTEMD +#include #include #define LOGIND_NAME "systemd-logind" #endif @@ -52,13 +53,11 @@ struct _NMSessionMonitor { } sd; #endif -#if SESSION_TRACKING_CONSOLEKIT struct { GFileMonitor *monitor; GHashTable *cache; time_t timestamp; } ck; -#endif }; struct _NMSessionMonitorClass { @@ -136,7 +135,6 @@ st_sd_finalize(NMSessionMonitor *monitor /*****************************************************************************/ -#if SESSION_TRACKING_CONSOLEKIT typedef struct { gboolean active; } CkSession; @@ -269,7 +267,6 @@ ck_finalize(NMSessionMonitor *monitor) nm_clear_pointer(&monitor->ck.cache, g_hash_table_unref); g_clear_object(&monitor->ck.monitor); } -#endif /* SESSION_TRACKING_CONSOLEKIT */ /*****************************************************************************/ @@ -295,14 +292,15 @@ nm_session_monitor_session_exists(NMSess g_return_val_if_fail(NM_IS_SESSION_MONITOR(self), FALSE); #if SESSION_TRACKING_XLOGIND + if (sd_booted() > 0) { if (st_sd_session_exists(self, uid, active)) return TRUE; + } else #endif - -#if SESSION_TRACKING_CONSOLEKIT + { if (ck_session_exists(self, uid, active)) return TRUE; -#endif + } return FALSE; } @@ -313,26 +311,28 @@ static void nm_session_monitor_init(NMSessionMonitor *monitor) { #if SESSION_TRACKING_XLOGIND + if (sd_booted() > 0) { st_sd_init(monitor); _LOGD("using " LOGIND_NAME " session tracking"); + } else #endif -#if SESSION_TRACKING_CONSOLEKIT + { ck_init(monitor); _LOGD("using ConsoleKit session tracking"); -#endif + } } static void finalize(GObject *object) { #if SESSION_TRACKING_XLOGIND + if (sd_booted() > 0) st_sd_finalize(NM_SESSION_MONITOR(object)); + else #endif -#if SESSION_TRACKING_CONSOLEKIT ck_finalize(NM_SESSION_MONITOR(object)); -#endif G_OBJECT_CLASS(nm_session_monitor_parent_class)->finalize(object); } --- NetworkManager-1.34.0/src/core/nm-sleep-monitor.c.orig 2022-01-13 15:49:26.000000000 +0100 +++ NetworkManager-1.34.0/src/core/nm-sleep-monitor.c 2022-01-13 21:09:37.908589909 +0100 @@ -11,6 +11,10 @@ #include #include +#ifdef SUSPEND_RESUME_SYSTEMD +# include +#endif + #include "libnm-glib-aux/nm-dbus-aux.h" #include "libnm-core-intern/nm-core-internal.h" #include "NetworkManagerUtils.h" @@ -24,9 +28,9 @@ #elif defined(SUSPEND_RESUME_SYSTEMD) || defined(SUSPEND_RESUME_ELOGIND) -#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 #if defined(SUSPEND_RESUME_SYSTEMD) #define _NMLOG_PREFIX_NAME "sleep-monitor-sd" @@ -36,6 +40,17 @@ #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_ELOGIND, 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 */ @@ -43,12 +58,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_ELOGIND, SUSPEND_RESUME_CONSOLEKIT, or SUSPEND_RESUME_UPOWER #endif @@ -329,6 +338,20 @@ nm_sleep_monitor_init(NMSleepMonitor *se { 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,