[gnome-system-monitor/gnome-3-8] Check for logind, not for systemd It is possible to build systemd without logind, in which case sd_b



commit bfe51c1bc6c761b2d5d9d597c43259e860bf05d6
Author: Martin Pitt <martinpitt gnome org>
Date:   Mon Apr 22 01:04:32 2013 +0300

    Check for logind, not for systemd
    It is possible to build systemd without logind, in which case sd_booted() would
    succeed. Check for /run/systemd/seats to test for logind instead, as
    recommended by systemd upstream.
    For details, see:
    <https://mail.gnome.org/archives/desktop-devel-list/2013-March/msg00092.html>
    Drop the now unnecessary linking against libsystemd-daemon.
    https://bugzilla.gnome.org/show_bug.cgi?id=696274

 configure.ac        |    2 +-
 src/procdialogs.cpp |    6 +-----
 src/procman-app.cpp |    6 +-----
 src/proctable.cpp   |    5 ++---
 src/util.h          |    3 +++
 5 files changed, 8 insertions(+), 14 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index e3fcaeb..12523ef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -48,7 +48,7 @@ PKG_CHECK_MODULES(SCRIPTS, glib-2.0 >= $GLIB_REQUIRED)
 have_systemd=no
 AC_ARG_ENABLE(systemd, AS_HELP_STRING([--disable-systemd], [disable systemd support]),,enable_systemd=no)
 if test "x$enable_systemd" != "xno"; then
-        PKG_CHECK_MODULES(SYSTEMD, [ libsystemd-daemon >= $SYSTEMD_REQUIRED libsystemd-login >= 
$SYSTEMD_REQUIRED ],
+        PKG_CHECK_MODULES(SYSTEMD, [ libsystemd-login >= $SYSTEMD_REQUIRED ],
                                    [ PKG_CHECK_MODULES(SYSTEMD_EX, [ libsystemd-login = $SYSTEMD_EXCLUDED ],
                                                                    AC_MSG_ERROR([*** systemd v43 found but 
it has a bug in its header files (uses C++ keyword)]), # Can't use systemd v43 
                                                                    [AC_DEFINE(HAVE_SYSTEMD, 1, [Define if 
systemd is available]) have_systemd=yes])],
diff --git a/src/procdialogs.cpp b/src/procdialogs.cpp
index f507ddf..4a54b72 100644
--- a/src/procdialogs.cpp
+++ b/src/procdialogs.cpp
@@ -26,10 +26,6 @@
 #include <string.h>
 #include <stdio.h>
 
-#ifdef HAVE_SYSTEMD
-#include <systemd/sd-daemon.h>
-#endif
-
 #include "procdialogs.h"
 #include "proctable.h"
 #include "callbacks.h"
@@ -374,7 +370,7 @@ create_field_page(GtkBuilder* builder, GtkWidget *tree, const gchar *widgetname)
              column_id == COL_SEAT ||
              column_id == COL_OWNER)
 #ifdef HAVE_SYSTEMD
-            && sd_booted() <= 0
+            && !LOGIND_RUNNING()
 #endif
                 )
             continue;
diff --git a/src/procman-app.cpp b/src/procman-app.cpp
index 68d541c..6ce08b9 100644
--- a/src/procman-app.cpp
+++ b/src/procman-app.cpp
@@ -4,10 +4,6 @@
 #include <glibtop.h>
 #include <glibtop/close.h>
 
-#ifdef HAVE_SYSTEMD
-#include <systemd/sd-daemon.h>
-#endif
-
 #include "procman-app.h"
 #include "interface.h"
 #include "proctable.h"
@@ -455,7 +451,7 @@ procman_get_tree_state (GSettings *settings, GtkWidget *tree, const gchar *child
                 id == COL_SEAT ||
                 id == COL_OWNER)
 #ifdef HAVE_SYSTEMD
-                && sd_booted() <= 0
+                && !LOGIND_RUNNING()
 #endif
                 )
                 continue;
diff --git a/src/proctable.cpp b/src/proctable.cpp
index 63c1417..e4da3bb 100644
--- a/src/proctable.cpp
+++ b/src/proctable.cpp
@@ -45,7 +45,6 @@
 #include <list>
 
 #ifdef HAVE_SYSTEMD
-#include <systemd/sd-daemon.h>
 #include <systemd/sd-login.h>
 #endif
 
@@ -431,7 +430,7 @@ proctable_new (ProcmanApp * const app)
     g_signal_connect(G_OBJECT (theme), "changed", G_CALLBACK (cb_refresh_icons), app);
     
 #ifdef HAVE_SYSTEMD
-    if (sd_booted() <= 0)
+    if (!LOGIND_RUNNING())
 #endif
     {
         GtkTreeViewColumn *column;
@@ -707,7 +706,7 @@ get_process_systemd_info(ProcInfo *info)
 #ifdef HAVE_SYSTEMD
     uid_t uid;
 
-    if (sd_booted() <= 0)
+    if (!LOGIND_RUNNING())
         return;
 
     free(info->unit);
diff --git a/src/util.h b/src/util.h
index c6f33d2..f55f821 100644
--- a/src/util.h
+++ b/src/util.h
@@ -26,6 +26,9 @@ inline int procman_cmp(T x, T y)
 #define PROCMAN_CMP(X, Y) procman_cmp((X), (Y))
 #define PROCMAN_RCMP(X, Y) procman_cmp((Y), (X));
 
+/* check if logind is running */
+#define LOGIND_RUNNING() (access("/run/systemd/seats/", F_OK) >= 0)
+
 GtkWidget*
 procman_make_label_for_mmaps_or_ofiles(const char *format,
                                        const char *process_name,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]