summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Koegel <eric.koegel@gmail.com>2016-01-25 11:58:03 +0300
committerEric Koegel <eric.koegel@gmail.com>2016-01-25 11:58:03 +0300
commit3ccb5e38e59f570ec0f3dd6bf6e67fd82f5944a0 (patch)
tree475232ba78dc3fa14a5b838d67d26a2e8a80b440
parent3402fbafacf167d8b29d0b59f8b297b0e5731c29 (diff)
downloadlightdm-3ccb5e38e59f570ec0f3dd6bf6e67fd82f5944a0.tar.gz
Add XDG_RUNTIME_DIR from ConsoleKit2
-rw-r--r--src/console-kit.c50
-rw-r--r--src/console-kit.h2
-rw-r--r--src/session-child.c11
3 files changed, 63 insertions, 0 deletions
diff --git a/src/console-kit.c b/src/console-kit.c
index 41ffbc49..ac514cc2 100644
--- a/src/console-kit.c
+++ b/src/console-kit.c
@@ -260,3 +260,53 @@ ck_close_session (const gchar *cookie)
if (!is_closed)
g_warning ("ConsoleKit.Manager.CloseSession() returned false");
}
+
+gchar *
+ck_get_xdg_runtime_dir (const gchar *cookie)
+{
+ GDBusConnection *bus;
+ gchar *session_path;
+ gchar *runtime_dir = NULL;
+ GError *error = NULL;
+
+ g_return_if_fail (cookie != NULL);
+
+ g_debug ("Getting XDG_RUNTIME_DIR from ConsoleKit for session %s", cookie);
+
+ bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (error)
+ g_warning ("Failed to get system bus: %s", error->message);
+ g_clear_error (&error);
+ if (!bus)
+ return NULL;
+
+ session_path = get_ck_session (bus, cookie);
+ if (session_path)
+ {
+ GVariant *result;
+
+ result = g_dbus_connection_call_sync (bus,
+ "org.freedesktop.ConsoleKit",
+ session_path,
+ "org.freedesktop.ConsoleKit.Session",
+ "GetXDGRuntimeDir",
+ g_variant_new ("()"),
+ G_VARIANT_TYPE ("(s)"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ if (error)
+ g_warning ("Error getting XDG_RUNTIME_DIR from ConsoleKit: %s", error->message);
+ g_clear_error (&error);
+ if (!result)
+ return NULL;
+
+ g_variant_get (result, "(s)", &runtime_dir);
+ g_variant_unref (result);
+ g_debug ("ConsoleKit XDG_RUNTIME_DIR is %s", runtime_dir);
+ }
+
+ g_object_unref (bus);
+ return runtime_dir;
+}
diff --git a/src/console-kit.h b/src/console-kit.h
index 1080338e..5edaa2de 100644
--- a/src/console-kit.h
+++ b/src/console-kit.h
@@ -26,6 +26,8 @@ void ck_activate_session (const gchar *cookie);
void ck_close_session (const gchar *cookie);
+gchar *ck_get_xdg_runtime_dir (const gchar *cookie);
+
G_END_DECLS
#endif /* CONSOLE_KIT_H_ */
diff --git a/src/session-child.c b/src/session-child.c
index dcf75aae..36569423 100644
--- a/src/session-child.c
+++ b/src/session-child.c
@@ -621,9 +621,20 @@ session_child_run (int argc, char **argv)
if (console_kit_cookie)
{
gchar *value;
+ gchar *runtime_dir;
value = g_strdup_printf ("XDG_SESSION_COOKIE=%s", console_kit_cookie);
pam_putenv (pam_handle, value);
g_free (value);
+
+ runtime_dir = ck_get_xdg_runtime_dir (console_kit_cookie);
+ if (runtime_dir)
+ {
+ gchar *value;
+ value = g_strdup_printf ("XDG_RUNTIME_DIR=%s", runtime_dir);
+ pam_putenv (pam_handle, value);
+ g_free (value);
+ g_free (runtime_dir);
+ }
}
}