diff options
author | Thomas Haller <thaller@redhat.com> | 2017-02-24 12:58:55 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-02-24 13:06:13 +0100 |
commit | c0d9243e7ebdb6efd5c3e866b03a28cd91b08c83 (patch) | |
tree | 73af5335013b9bc4fbb72a7ade4d089e7e7bf518 | |
parent | 360e80b75faead6595ceb4ca8cd91dd7fbaa2f47 (diff) | |
download | NetworkManager-th/elogind-bgo779167.tar.gz |
session: make systemd-logind and elogind conflicting build optionsth/elogind-bgo779167
-rw-r--r-- | configure.ac | 9 | ||||
-rw-r--r-- | src/nm-session-monitor.c | 25 | ||||
-rw-r--r-- | src/nm-sleep-monitor.c | 4 |
3 files changed, 20 insertions, 18 deletions
diff --git a/configure.ac b/configure.ac index c5d43e5525..e7d8878279 100644 --- a/configure.ac +++ b/configure.ac @@ -454,11 +454,14 @@ if test "$use_systemd_logind" = "yes" -a "$have_systemd_logind" = "no"; then AC_MSG_ERROR([You must have libsystemd installed to build with systemd-logind support.]) fi if test "$have_systemd_logind" = "yes"; then - AC_DEFINE([SESSION_TRACKING_SYSTEMD], 1, [Define to 1 if libsystemd-login is available]) - session_tracking="$session_tracking, systemd-logind" + AC_DEFINE([SESSION_TRACKING_SYSTEMD], 1, [Define to 1 if libsystemd-login is available]) + session_tracking="$session_tracking, systemd-logind" fi -if test "$use_elogind" = "yes" -o "$use_elogind" = "auto"; then +if test "$use_elogind" = "yes" -a "$have_systemd_logind" = "yes"; then + AC_MSG_ERROR([Cannot enable systemd-logind together with elogind.]) +fi +if test "$use_elogind" = "yes"; then PKG_CHECK_MODULES(SYSTEMD_LOGIN, [libelogind], [have_elogind=yes], [PKG_CHECK_MODULES(SYSTEMD_LOGIN, [libelogind], [have_elogind=yes], [have_elogind=no])]) else have_elogind=no diff --git a/src/nm-session-monitor.c b/src/nm-session-monitor.c index 342ec55f94..151deec899 100644 --- a/src/nm-session-monitor.c +++ b/src/nm-session-monitor.c @@ -28,11 +28,18 @@ #include <string.h> #include <sys/stat.h> +#if defined (SESSION_TRACKING_SYSTEMD) && defined (SESSION_TRACKING_ELOGIND) +#error Cannot build both systemd-logind and elogind support +#endif + #ifdef SESSION_TRACKING_SYSTEMD #include <systemd/sd-login.h> +#define LOGIND_NAME "systemd-logind" #endif + #ifdef SESSION_TRACKING_ELOGIND #include <elogind/sd-login.h> +#define LOGIND_NAME "elogind" /* Re-Use SESSION_TRACKING_SYSTEMD as elogind substitutes systemd-login */ #define SESSION_TRACKING_SYSTEMD 1 #endif @@ -90,11 +97,7 @@ st_sd_session_exists (NMSessionMonitor *monitor, uid_t uid, gboolean active) status = sd_uid_get_sessions (uid, active, NULL); if (status < 0) -#ifdef SESSION_TRACKING_ELOGIND - _LOGE ("failed to get elogind sessions for uid %d: %d", uid, status); -#else - _LOGE ("failed to get systemd sessions for uid %d: %d", uid, status); -#endif /* SESSION_TRACKING_ELOGIND */ + _LOGE ("failed to get "LOGIND_NAME" sessions for uid %d: %d", uid, status); return status > 0; } @@ -121,11 +124,7 @@ st_sd_init (NMSessionMonitor *monitor) return; if ((status = sd_login_monitor_new (NULL, &monitor->sd.monitor)) < 0) { -#ifdef SESSION_TRACKING_ELOGIND - _LOGE ("failed to create elogind monitor: %d", status); -#else - _LOGE ("failed to create systemd login monitor: %d", status); -#endif /* SESSION_TRACKING_ELOGIND */ + _LOGE ("failed to create "LOGIND_NAME" monitor: %d", status); return; } @@ -370,11 +369,7 @@ nm_session_monitor_init (NMSessionMonitor *monitor) { #ifdef SESSION_TRACKING_SYSTEMD st_sd_init (monitor); -#ifdef SESSION_TRACKING_ELOGIND - _LOGD ("using elogind session tracking"); -#else - _LOGD ("using systemd-logind session tracking"); -#endif /* SESSION_TRACKING_ELOGIND */ + _LOGD ("using "LOGIND_NAME" session tracking"); #endif #ifdef SESSION_TRACKING_CONSOLEKIT diff --git a/src/nm-sleep-monitor.c b/src/nm-sleep-monitor.c index edef04f80f..037db11b7f 100644 --- a/src/nm-sleep-monitor.c +++ b/src/nm-sleep-monitor.c @@ -44,7 +44,11 @@ #define SUSPEND_DBUS_PATH "/org/freedesktop/login1" #define SUSPEND_DBUS_INTERFACE "org.freedesktop.login1.Manager" #define USE_UPOWER 0 +#if defined (SUSPEND_RESUME_SYSTEMD) #define _NMLOG_PREFIX_NAME "sleep-monitor-sd" +#else +#define _NMLOG_PREFIX_NAME "sleep-monitor-el" +#endif #elif defined(SUSPEND_RESUME_CONSOLEKIT) |