SHA256
1
0
forked from pool/systemd
systemd/0001-pam_systemd_do_override_XDG_RUNTIME_DIR_of_the_original_user.patch

44 lines
1.7 KiB
Diff

From: Werner Fink <werner@suse.de>
Date: Wed Feb 26 14:36:27 UTC 2014
Subject: Do not clobber XDG_RUNTIME_DIR if su command preserve environment
Make sure that even if a su command without option -l or with option -m
is used, the XDG_RUNTIME_DIR will not be clobbered by the new uid.
This belongs to BNC#852015 and also to BNC#855160
---
src/login/pam_systemd.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
Index: systemd-221/src/login/pam_systemd.c
===================================================================
--- systemd-221.orig/src/login/pam_systemd.c
+++ systemd-221/src/login/pam_systemd.c
@@ -445,6 +445,25 @@ _public_ PAM_EXTERN int pam_sm_open_sess
r = export_legacy_dbus_address(handle, pw->pw_uid, runtime_path);
if (r != PAM_SUCCESS)
return r;
+ } else if (getenv("XDG_RUNTIME_DIR")) {
+ _cleanup_free_ char *p = NULL;
+
+ /* Make sure that after running YaST2 or the xdg-su scripts
+ * the runtime directory is not clobbered. Even a normal su
+ * command without -l or with -m may clobber. */
+
+ if ((r = asprintf(&p, "/run/user/%lu", (unsigned long)pw->pw_uid)) < 0)
+ return PAM_BUF_ERR;
+
+ r = pam_misc_setenv(handle, "XDG_RUNTIME_DIR", p, 0);
+ if (r != PAM_SUCCESS) {
+ pam_syslog(handle, LOG_ERR, "Failed to set runtime dir.");
+ return r;
+ }
+
+ r = export_legacy_dbus_address(handle, pw->pw_uid, p);
+ if (r != PAM_SUCCESS)
+ return r;
}
if (!isempty(seat)) {