session: make systemd-logind and elogind conflicting build options

This commit is contained in:
Thomas Haller 2017-02-24 12:58:55 +01:00
parent 360e80b75f
commit c0d9243e7e
3 changed files with 20 additions and 18 deletions

View file

@ -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

View file

@ -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

View file

@ -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)