commit 9873a7536844f5c38c2a123be58175c2774e5dcc Author: Jan Alexander Steffens (heftig) Date: Mon Mar 12 01:12:11 2012 +0100 Fallback to CK if systemd is not available Be nice to distributions where systemd is optional. This will select the code path at runtime depending on whether the system was booted using systemd. diff --git a/configure.ac b/configure.ac index aee97ac..867f061 100644 --- a/configure.ac +++ b/configure.ac @@ -56,7 +56,7 @@ AC_ARG_ENABLE([systemd], [with_systemd=$enableval], [with_systemd=no]) if test "$with_systemd" = "yes" ; then - SYSTEMD=libsystemd-login + SYSTEMD="libsystemd-login libsystemd-daemon" AC_DEFINE(HAVE_SYSTEMD, 1, [Define to 1 if systemd is available]) else SYSTEMD= diff --git a/panels/user-accounts/um-user.c b/panels/user-accounts/um-user.c index f027754..5ebbe29 100644 --- a/panels/user-accounts/um-user.c +++ b/panels/user-accounts/um-user.c @@ -37,6 +37,11 @@ #include +#ifdef HAVE_SYSTEMD +# include +# include +#endif + #include "um-user.h" #include "um-account-type.h" #include "um-utils.h" @@ -1003,25 +1008,18 @@ um_user_set_password (UmUser *user, } } -#ifdef HAVE_SYSTEMD - -#include - gboolean um_user_is_logged_in (UmUser *user) { - int n_sessions; - - n_sessions = sd_uid_get_sessions (um_user_get_uid (user), 0, NULL) > 0; - - return n_sessions > 0; -} +#ifdef HAVE_SYSTEMD + if (sd_booted () > 0) { + int n_sessions; -#else + n_sessions = sd_uid_get_sessions (um_user_get_uid (user), 0, NULL); -gboolean -um_user_is_logged_in (UmUser *user) -{ + return n_sessions > 0; + } +#endif GVariant *result; GVariantIter *iter; gint n_sessions; @@ -1052,8 +1050,6 @@ um_user_is_logged_in (UmUser *user) return n_sessions > 0; } -#endif - void um_user_set_automatic_login (UmUser *user, gboolean enabled)