diff options
-rw-r--r-- | pam-ck-connector/pam-ck-connector.c | 18 | ||||
-rw-r--r-- | tools/ck-launch-session.c | 9 |
2 files changed, 17 insertions, 10 deletions
diff --git a/pam-ck-connector/pam-ck-connector.c b/pam-ck-connector/pam-ck-connector.c index e5dcae9..986bc8e 100644 --- a/pam-ck-connector/pam-ck-connector.c +++ b/pam-ck-connector/pam-ck-connector.c @@ -245,6 +245,7 @@ pam_sm_open_session (pam_handle_t *pamh, const char *x11_display; const char *x11_display_device; const char *remote_host_name; + const char *runtime_dir; const char *s; uid_t uid; char buf[256]; @@ -420,14 +421,17 @@ pam_sm_open_session (pam_handle_t *pamh, /* and set the runtime dir */ buf[sizeof (buf) - 1] = '\0'; - snprintf (buf, sizeof (buf) - 1, "XDG_RUNTIME_DIR=%s", ck_connector_get_runtime_dir (ckc, &error)); - if (pam_putenv (pamh, buf) != PAM_SUCCESS) { - ck_pam_syslog (pamh, LOG_ERR, "unable to set XDG_RUNTIME_DIR in environment"); - /* tear down session the hard way */ - ck_connector_unref (ckc); - ckc = NULL; + runtime_dir = ck_connector_get_runtime_dir (ckc, &error); + if (runtime_dir != NULL) { + snprintf (buf, sizeof (buf) - 1, "XDG_RUNTIME_DIR=%s", runtime_dir); + if (pam_putenv (pamh, buf) != PAM_SUCCESS) { + ck_pam_syslog (pamh, LOG_ERR, "unable to set XDG_RUNTIME_DIR in environment"); + /* tear down session the hard way */ + ck_connector_unref (ckc); + ckc = NULL; - goto out; + goto out; + } } if (opt_debug) { diff --git a/tools/ck-launch-session.c b/tools/ck-launch-session.c index 427e07b..a102998 100644 --- a/tools/ck-launch-session.c +++ b/tools/ck-launch-session.c @@ -58,7 +58,7 @@ main (int argc, char **argv) /* Setup for i18n */ setlocale(LC_ALL, ""); - + #ifdef ENABLE_NLS bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); @@ -68,6 +68,7 @@ main (int argc, char **argv) if (ckc != NULL) { dbus_error_init (&error); if (ck_connector_open_session (ckc, &error)) { + const char *runtime_dir = NULL; pid = fork (); switch (pid) { case -1: @@ -77,8 +78,10 @@ main (int argc, char **argv) setenv ("XDG_SESSION_COOKIE", ck_connector_get_cookie (ckc), 1); - setenv ("XDG_RUNTIME_DIR", - ck_connector_get_runtime_dir (ckc, &error), 1); + runtime_dir = ck_connector_get_runtime_dir (ckc, &error); + if (runtime_dir != NULL) { + setenv ("XDG_RUNTIME_DIR", runtime_dir, 1); + } break; default: waitpid (pid, &status, 0); |