From bb77759d1267abfb23416ba869296e7e526db562 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Tue, 26 Mar 2013 11:36:31 +0100 Subject: [PATCH 2/2] PAM, uaccess: check for logind, not for systemd 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://bugs.freedesktop.org/show_bug.cgi?id=62754 --- src/login/pam-module.c | 6 ++---- src/shared/util.h | 5 +++++ src/udev/udev-builtin-uaccess.c | 3 +-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/login/pam-module.c b/src/login/pam-module.c index 702095e..0d4f799 100644 --- a/src/login/pam-module.c +++ b/src/login/pam-module.c @@ -32,8 +32,6 @@ #include #include -#include - #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"); */ - /* 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, diff --git a/src/shared/util.h b/src/shared/util.h index 7a38421..4221ceb 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -36,6 +36,7 @@ #include #include #include +#include #include #include "macro.h" @@ -611,3 +612,7 @@ static inline void *mempset(void *s, int c, size_t n) { char *hexmem(const void *p, size_t l); char *strextend(char **x, ...); char *strrep(const char *s, unsigned n); + +static inline bool logind_running(void) { + return access("/run/systemd/seats/", F_OK) >= 0; +} diff --git a/src/udev/udev-builtin-uaccess.c b/src/udev/udev-builtin-uaccess.c index 662bac9..354ee08 100644 --- a/src/udev/udev-builtin-uaccess.c +++ b/src/udev/udev-builtin-uaccess.c @@ -29,7 +29,6 @@ #include #include -#include #include #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 */ - if (!sd_booted()) + if (!logind_running()) return 0; path = udev_device_get_devnode(dev); -- 1.8.1.2