summaryrefslogtreecommitdiff
path: root/extra/gnome-control-center/systemd-fallback.patch
blob: 709e54019e69080eb6d7b5f2f0334c3aefb37a4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
commit 9873a7536844f5c38c2a123be58175c2774e5dcc
Author: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
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 <gio/gunixoutputstream.h>
 
+#ifdef HAVE_SYSTEMD
+#  include <systemd/sd-login.h>
+#  include <systemd/sd-daemon.h>
+#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 <systemd/sd-login.h>
-
 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)