From deae9b5b34d35acc62cd045dcf187e40b8c46200 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Fri, 14 Mar 2014 11:07:09 +0100 Subject: pam: Pass XDG_RUNTIME_DIR to new process If XDG_RUNTIME_DIR is not in the PAM envlist, but *is* in the process environment, then steal it from there similar to how we handle DISPLAY. https://bugzilla.gnome.org/show_bug.cgi?id=726196 --- pam/gkr-pam-module.c | 8 +++++++- pam/test-pam.c | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/pam/gkr-pam-module.c b/pam/gkr-pam-module.c index c06d8321..35927318 100644 --- a/pam/gkr-pam-module.c +++ b/pam/gkr-pam-module.c @@ -348,6 +348,7 @@ setup_child (int inp[2], const char *argument) { const char* display; + const char *runtime; int i, ret; char *args[] = { @@ -404,7 +405,12 @@ setup_child (int inp[2], if (display) ret = setup_pam_env (ph, "DISPLAY", display); } - + if (ret == PAM_SUCCESS && !pam_getenv (ph, "XDG_RUNTIME_DIR")) { + runtime = getenv ("XDG_RUNTIME_DIR"); + if (runtime) + ret = setup_pam_env (ph, "XDG_RUNTIME_DIR", runtime); + } + /* Make sure that worked */ if (ret != PAM_SUCCESS) { syslog (GKR_LOG_ERR, "gkr-pam: couldn't setup environment: %s", diff --git a/pam/test-pam.c b/pam/test-pam.c index 56eebcae..55f49ac6 100644 --- a/pam/test-pam.c +++ b/pam/test-pam.c @@ -278,6 +278,9 @@ test_starts_creates (Test *test, if (test->skipping) return; + /* We're testing that we create the directory appropriately */ + g_unsetenv ("XDG_RUNTIME_DIR"); + start_in_session = (strstr (pam_conf, "session") != NULL); login_keyring = g_build_filename (test->directory, "login.keyring", NULL); @@ -322,6 +325,9 @@ test_starts_only_session (Test *test, /* This is the PAM config that starts the daemon from session handler */ g_assert (strstr (pam_conf, "session-start") != NULL); + /* We're testing that we create the directory appropriately */ + g_unsetenv ("XDG_RUNTIME_DIR"); + login_keyring = g_build_filename (test->directory, "login.keyring", NULL); g_assert (!g_file_test (login_keyring, G_FILE_TEST_EXISTS)); @@ -345,6 +351,9 @@ test_starts_exists (Test *test, if (test->skipping) return; + /* We're testing that we create the directory appropriately */ + g_unsetenv ("XDG_RUNTIME_DIR"); + start_in_session = (strstr (pam_conf, "session") != NULL); egg_tests_copy_scratch_file (test->directory, SRCDIR "/pam/fixtures/login.keyring"); -- cgit v1.2.1