summaryrefslogtreecommitdiff
path: root/pam-ck-connector
diff options
context:
space:
mode:
authorEric Koegel <eric.koegel@gmail.com>2017-05-04 02:25:32 +0300
committerEric Koegel <eric.koegel@gmail.com>2017-05-04 02:29:10 +0300
commitcebe706bed6f88cdb3f4c3015b29db8c755af713 (patch)
tree921f8adf637d4b6403b506ae215b8aeae54b8a37 /pam-ck-connector
parentffe60ba5e9edbfcffc1c5f66986dbcd8fbf1af77 (diff)
downloadConsoleKit2-cebe706bed6f88cdb3f4c3015b29db8c755af713.tar.gz
Handle runtimedir not being created/set
For: https://github.com/ConsoleKit2/ConsoleKit2/issues/74
Diffstat (limited to 'pam-ck-connector')
-rw-r--r--pam-ck-connector/pam-ck-connector.c18
1 files changed, 11 insertions, 7 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) {