summaryrefslogtreecommitdiff
path: root/src/pam-module.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-06-30 04:31:49 +0200
committerLennart Poettering <lennart@poettering.net>2011-06-30 04:31:49 +0200
commit30b2c336d80aa08ffcc6ebba9540b15b07563a73 (patch)
treef436a9a55e94782d8d4679735340dd4c11b84d12 /src/pam-module.c
parentaa87e624744cb7fbd9e28e70e855e28fd3b255c2 (diff)
pam: initialize XDG_RUNTIME_DIR
Diffstat (limited to 'src/pam-module.c')
-rw-r--r--src/pam-module.c47
1 files changed, 40 insertions, 7 deletions
diff --git a/src/pam-module.c b/src/pam-module.c
index 178c46940c..dfeab97f53 100644
--- a/src/pam-module.c
+++ b/src/pam-module.c
@@ -361,13 +361,6 @@ _public_ PAM_EXTERN int pam_sm_open_session(
if (sd_booted() <= 0)
return PAM_SUCCESS;
- /* Make sure we don't enter a loop by talking to
- * systemd-logind when it is actually waiting for the
- * background to finish start-up, */
- pam_get_item(handle, PAM_SERVICE, (const void**) &service);
- if (streq_ptr(service, "systemd-shared"))
- return PAM_SUCCESS;
-
if (parse_argv(handle,
argc, argv,
&controllers, &reset_controllers,
@@ -381,6 +374,46 @@ _public_ PAM_EXTERN int pam_sm_open_session(
if (r != PAM_SUCCESS)
goto finish;
+ /* Make sure we don't enter a loop by talking to
+ * systemd-logind when it is actually waiting for the
+ * background to finish start-up. If the service is
+ * "systemd-shared" we simply set XDG_RUNTIME_DIR and
+ * leave. */
+
+ pam_get_item(handle, PAM_SERVICE, (const void**) &service);
+ if (streq_ptr(service, "systemd-shared")) {
+ char *p, *rt = NULL;
+
+ if (asprintf(&p, "/run/systemd/users/%lu", (unsigned long) pw->pw_uid) < 0) {
+ r = PAM_BUF_ERR;
+ goto finish;
+ }
+
+ r = parse_env_file(p, NEWLINE,
+ "RUNTIME", &rt,
+ NULL);
+ free(p);
+
+ if (r < 0 && r != -ENOENT) {
+ r = PAM_SESSION_ERR;
+ free(rt);
+ goto finish;
+ }
+
+ if (rt) {
+ r = pam_misc_setenv(handle, "XDG_RUNTIME_DIR", rt, 0);
+ free(rt);
+
+ if (r != PAM_SUCCESS) {
+ pam_syslog(handle, LOG_ERR, "Failed to set runtime dir.");
+ goto finish;
+ }
+ }
+
+ r = PAM_SUCCESS;
+ goto finish;
+ }
+
if (kill_processes)
kill_processes = check_user_lists(handle, pw->pw_uid, kill_only_users, kill_exclude_users);