chiark / gitweb /
PAM, uaccess: check for logind, not for systemd
authorMartin Pitt <martinpitt@gnome.org>
Tue, 26 Mar 2013 10:36:31 +0000 (11:36 +0100)
committerMartin Pitt <martinpitt@gnome.org>
Fri, 5 Apr 2013 16:16:58 +0000 (18:16 +0200)
It is possible to build systemd without logind or run logind without systemd
init. Commit 66e41181 fixed sd_booted() to only succeed for systemd init; with
that, testing for systemd init is wrong in the parts that talk to logind.

In particular, this affects the PAM module and the "uaccess" udev builtin.
Change sd_booted() to a new logind_running() which tests for
/run/systemd/seats/.

For details, see:
<https://mail.gnome.org/archives/desktop-devel-list/2013-March/msg00092.html>

https://bugs.freedesktop.org/show_bug.cgi?id=62754

src/login/pam-module.c
src/shared/util.h
src/udev/udev-builtin-uaccess.c

index 702095e5e677aec9ab3352ec0f808c3c461222bd..0d4f7991e7a6617b247497744788156f62366ad8 100644 (file)
@@ -32,8 +32,6 @@
 #include <security/pam_ext.h>
 #include <security/pam_misc.h>
 
 #include <security/pam_ext.h>
 #include <security/pam_misc.h>
 
-#include <systemd/sd-daemon.h>
-
 #include "util.h"
 #include "audit.h"
 #include "macro.h"
 #include "util.h"
 #include "audit.h"
 #include "macro.h"
@@ -348,8 +346,8 @@ _public_ PAM_EXTERN int pam_sm_open_session(
 
         /* pam_syslog(handle, LOG_INFO, "pam-systemd initializing"); */
 
 
         /* pam_syslog(handle, LOG_INFO, "pam-systemd initializing"); */
 
-        /* Make this a NOP on non-systemd systems */
-        if (sd_booted() <= 0)
+        /* Make this a NOP on non-logind systems */
+        if (!logind_running())
                 return PAM_SUCCESS;
 
         if (parse_argv(handle,
                 return PAM_SUCCESS;
 
         if (parse_argv(handle,
index 7c3da08dd8856787a8937a882d79aba17e6eae6d..4c4aed583e9afafc159b7da9a4c40eeadb9d1d59 100644 (file)
@@ -36,6 +36,7 @@
 #include <dirent.h>
 #include <sys/resource.h>
 #include <stddef.h>
 #include <dirent.h>
 #include <sys/resource.h>
 #include <stddef.h>
+#include <unistd.h>
 #include <systemd/sd-journal.h>
 
 #include "macro.h"
 #include <systemd/sd-journal.h>
 
 #include "macro.h"
@@ -639,3 +640,7 @@ static inline void _reset_umask_(struct umask_struct *s) {
 static inline unsigned u64log2(uint64_t n) {
         return (n > 1) ? __builtin_clzll(n) ^ 63U : 0;
 }
 static inline unsigned u64log2(uint64_t n) {
         return (n > 1) ? __builtin_clzll(n) ^ 63U : 0;
 }
+
+static inline bool logind_running(void) {
+        return access("/run/systemd/seats/", F_OK) >= 0;
+}
index 662bac9e0b27fed2c6c759d16c7a86545c5e7876..354ee08f28bd262911d321bf25ef756989621a5b 100644 (file)
@@ -29,7 +29,6 @@
 #include <dirent.h>
 #include <getopt.h>
 
 #include <dirent.h>
 #include <getopt.h>
 
-#include <systemd/sd-daemon.h>
 #include <systemd/sd-login.h>
 #include "logind-acl.h"
 #include "udev.h"
 #include <systemd/sd-login.h>
 #include "logind-acl.h"
 #include "udev.h"
@@ -49,7 +48,7 @@ static int builtin_uaccess(struct udev_device *dev, int argc, char *argv[], bool
         umask(0022);
 
         /* don't muck around with ACLs when the system is not running systemd */
         umask(0022);
 
         /* don't muck around with ACLs when the system is not running systemd */
-        if (!sd_booted())
+        if (!logind_running())
                 return 0;
 
         path = udev_device_get_devnode(dev);
                 return 0;
 
         path = udev_device_get_devnode(dev);