Commit 2291767a authored by Simon McVittie's avatar Simon McVittie Committed by Colin Walters

Use libsystemd instead of older libsystemd-login if possible

The command-line option is still --enable-libsystemd-login for now.

Bug-Debian: https://bugs.debian.org/779756
parent f4d71e0d
......@@ -187,39 +187,47 @@ dnl ---------------------------------------------------------------------------
dnl - Select wether to use libsystemd-login or ConsoleKit for session tracking
dnl ---------------------------------------------------------------------------
have_libsystemd_login=no
have_libsystemd=no
SESSION_TRACKING=ConsoleKit
AC_ARG_ENABLE([libsystemd-login],
AS_HELP_STRING([--enable-libsystemd-login[=@<:@auto/yes/no@:>@]], [Use libsystemd-login (auto/yes/no)]),
[AS_HELP_STRING([--enable-libsystemd-login[=@<:@auto/yes/no@:>@]], [Use libsystemd (auto/yes/no)])],
[enable_libsystemd_login=$enableval],
[enable_libsystemd_login=auto])
if test "$enable_libsystemd_login" != "no"; then
PKG_CHECK_MODULES(LIBSYSTEMD_LOGIN,
[libsystemd-login],
have_libsystemd_login=yes,
have_libsystemd_login=no)
if test "$have_libsystemd_login" = "yes"; then
PKG_CHECK_MODULES([LIBSYSTEMD],
[libsystemd],
[have_libsystemd=yes],
dnl if libsystemd is not available, fall back to the older libsystemd-login
[PKG_CHECK_MODULES([LIBSYSTEMD_LOGIN],
[libsystemd-login],
[
have_libsystemd=yes
LIBSYSTEMD_CFLAGS="$LIBSYSTEMD_LOGIN_CFLAGS"
LIBSYSTEMD_LIBS="$LIBSYSTEMD_LOGIN_LIBS"
],
[have_libsystemd=no])])
if test "$have_libsystemd" = "yes"; then
SESSION_TRACKING=libsystemd-login
AC_DEFINE([HAVE_LIBSYSTEMD_LOGIN], 1, [Define to 1 if libsystemd-login is available])
AC_DEFINE([HAVE_LIBSYSTEMD], 1, [Define to 1 if libsystemd is available])
save_LIBS=$LIBS
LIBS=$LIBSYSTEMD_LOGIN_LIBS
LIBS=$LIBSYSTEMD_LIBS
AC_CHECK_FUNCS(sd_uid_get_display)
LIBS=$save_LIBS
else
if test "$enable_libsystemd_login" = "yes"; then
AC_MSG_ERROR([libsystemd-login support requested but libsystemd-login library not found])
AC_MSG_ERROR([libsystemd support requested but libsystemd or libsystemd-login library not found])
fi
fi
fi
AS_IF([test "x$cross_compiling" != "xyes" ], [
AS_IF([test "$have_libsystemd_login" = "yes"], [
AS_IF([test "$have_libsystemd" = "yes"], [
AS_IF([test ! -d /sys/fs/cgroup/systemd/ ], [
AS_IF([test "$enable_libsystemd_login" = "yes"], [
AC_MSG_WARN([libsystemd-login requested but system does not appear to be using systemd])
AC_MSG_WARN([libsystemd requested but system does not appear to be using systemd])
], [
AC_MSG_ERROR([libsystemd-login autoconfigured, but system does not appear to use systemd])
AC_MSG_ERROR([libsystemd autoconfigured, but system does not appear to use systemd])
])
])
], [
......@@ -227,15 +235,15 @@ AS_IF([test "x$cross_compiling" != "xyes" ], [
AS_IF([test "$enable_libsystemd_login" = "no" ], [
AC_MSG_WARN([ConsoleKit requested but system appears to use systemd])
], [
AC_MSG_ERROR([ConsoleKit autoconfigured, but systemd is in use (missing libsystemd-login pkg-config?)])
AC_MSG_ERROR([ConsoleKit autoconfigured, but systemd is in use (missing libsystemd or libsystemd-login pkg-config?)])
])
])
])
])
AC_SUBST(LIBSYSTEMD_LOGIN_CFLAGS)
AC_SUBST(LIBSYSTEMD_LOGIN_LIBS)
AM_CONDITIONAL(HAVE_LIBSYSTEMD_LOGIN, [test "$have_libsystemd_login" = "yes"], [Using libsystemd-login])
AC_SUBST(LIBSYSTEMD_CFLAGS)
AC_SUBST(LIBSYSTEMD_LIBS)
AM_CONDITIONAL(HAVE_LIBSYSTEMD, [test "$have_libsystemd" = "yes"], [Using libsystemd])
dnl ---------------------------------------------------------------------------
dnl - systemd unit / service files
......
......@@ -81,7 +81,7 @@ libpolkit_gobject_1_la_SOURCES = \
polkitpermission.c polkitpermission.h \
$(NULL)
if HAVE_LIBSYSTEMD_LOGIN
if HAVE_LIBSYSTEMD
libpolkit_gobject_1_la_SOURCES += \
polkitunixsession-systemd.c polkitunixsession.h
else
......@@ -92,12 +92,12 @@ endif
libpolkit_gobject_1_la_CFLAGS = \
-D_POLKIT_COMPILATION \
$(GLIB_CFLAGS) \
$(LIBSYSTEMD_LOGIN_CFLAGS) \
$(LIBSYSTEMD_CFLAGS) \
$(NULL)
libpolkit_gobject_1_la_LIBADD = \
$(GLIB_LIBS) \
$(LIBSYSTEMD_LOGIN_LIBS) \
$(LIBSYSTEMD_LIBS) \
$(NULL)
libpolkit_gobject_1_la_LDFLAGS = -export-symbols-regex '(^polkit_.*)'
......
......@@ -38,7 +38,7 @@ libpolkit_backend_1_la_SOURCES = \
polkitbackendactionlookup.h polkitbackendactionlookup.c \
$(NULL)
if HAVE_LIBSYSTEMD_LOGIN
if HAVE_LIBSYSTEMD
libpolkit_backend_1_la_SOURCES += \
polkitbackendsessionmonitor.h polkitbackendsessionmonitor-systemd.c
else
......@@ -50,13 +50,13 @@ libpolkit_backend_1_la_CFLAGS = \
-D_POLKIT_COMPILATION \
-D_POLKIT_BACKEND_COMPILATION \
$(GLIB_CFLAGS) \
$(LIBSYSTEMD_LOGIN_CFLAGS) \
$(LIBSYSTEMD_CFLAGS) \
$(LIBJS_CFLAGS) \
$(NULL)
libpolkit_backend_1_la_LIBADD = \
$(GLIB_LIBS) \
$(LIBSYSTEMD_LOGIN_LIBS) \
$(LIBSYSTEMD_LIBS) \
$(top_builddir)/src/polkit/libpolkit-gobject-1.la \
$(EXPAT_LIBS) \
$(LIBJS_LIBS) \
......
......@@ -35,9 +35,9 @@
#include <polkit/polkitprivate.h>
#ifdef HAVE_LIBSYSTEMD_LOGIN
#ifdef HAVE_LIBSYSTEMD
#include <systemd/sd-login.h>
#endif /* HAVE_LIBSYSTEMD_LOGIN */
#endif /* HAVE_LIBSYSTEMD */
#include <jsapi.h>
......@@ -764,7 +764,7 @@ subject_to_jsval (PolkitBackendJsAuthority *authority,
g_assert_not_reached ();
}
#ifdef HAVE_LIBSYSTEMD_LOGIN
#ifdef HAVE_LIBSYSTEMD
if (sd_pid_get_session (pid, &session_str) == 0)
{
if (sd_session_get_seat (session_str, &seat_str) == 0)
......@@ -772,7 +772,7 @@ subject_to_jsval (PolkitBackendJsAuthority *authority,
/* do nothing */
}
}
#endif /* HAVE_LIBSYSTEMD_LOGIN */
#endif /* HAVE_LIBSYSTEMD */
g_assert (POLKIT_IS_UNIX_USER (user_for_subject));
uid = polkit_unix_user_get_uid (POLKIT_UNIX_USER (user_for_subject));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment