summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pitt <martinpitt@gnome.org>2013-03-26 11:36:31 +0100
committerMartin Pitt <martinpitt@gnome.org>2013-04-05 18:16:58 +0200
commit79d860fe78ff9e53fe3150fb55a8a8b03c4f6470 (patch)
tree1905740de9ce74a2006ee23dda5549c0efd81a34
parent9e542e0b3a5069f340072c93b5d2283848a42a2e (diff)
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://mail.gnome.org/archives/desktop-devel-list/2013-March/msg00092.html> https://bugs.freedesktop.org/show_bug.cgi?id=62754
-rw-r--r--src/login/pam-module.c6
-rw-r--r--src/shared/util.h5
-rw-r--r--src/udev/udev-builtin-uaccess.c3
3 files changed, 8 insertions, 6 deletions
diff --git a/src/login/pam-module.c b/src/login/pam-module.c
index 702095e5e..0d4f7991e 100644
--- a/src/login/pam-module.c
+++ b/src/login/pam-module.c
@@ -29,14 +29,12 @@
#include <security/pam_modules.h>
#include <security/_pam_macros.h>
#include <security/pam_modutil.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 "strv.h"
#include "dbus-common.h"
#include "def.h"
@@ -345,14 +343,14 @@ _public_ PAM_EXTERN int pam_sm_open_session(
assert(handle);
dbus_error_init(&error);
/* 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,
argc, argv,
&controllers, &reset_controllers,
&kill_processes, &kill_only_users, &kill_exclude_users,
diff --git a/src/shared/util.h b/src/shared/util.h
index 7c3da08dd..4c4aed583 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -33,12 +33,13 @@
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <sys/resource.h>
#include <stddef.h>
+#include <unistd.h>
#include <systemd/sd-journal.h>
#include "macro.h"
#include "time-util.h"
union dirent_storage {
@@ -636,6 +637,10 @@ static inline void _reset_umask_(struct umask_struct *s) {
!_saved_umask_.quit ; \
_saved_umask_.quit = true)
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;
+}
diff --git a/src/udev/udev-builtin-uaccess.c b/src/udev/udev-builtin-uaccess.c
index 662bac9e0..354ee08f2 100644
--- a/src/udev/udev-builtin-uaccess.c
+++ b/src/udev/udev-builtin-uaccess.c
@@ -26,13 +26,12 @@
#include <ctype.h>
#include <fcntl.h>
#include <errno.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 "util.h"
static int builtin_uaccess(struct udev_device *dev, int argc, char *argv[], bool test)
@@ -46,13 +45,13 @@ static int builtin_uaccess(struct udev_device *dev, int argc, char *argv[], bool
log_parse_environment();
log_open();
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);
seat = udev_device_get_property_value(dev, "ID_SEAT");
if (!seat)
seat = "seat0";