Merge lp:~eric-koegel/lightdm/ck2-xdg-runtime-dir into lp:lightdm

Proposed by Eric Koegel
Status: Merged
Merged at revision: 2272
Proposed branch: lp:~eric-koegel/lightdm/ck2-xdg-runtime-dir
Merge into: lp:lightdm
Diff against target: 94 lines (+63/-0)
3 files modified
src/console-kit.c (+50/-0)
src/console-kit.h (+2/-0)
src/session-child.c (+11/-0)
To merge this branch: bzr merge lp:~eric-koegel/lightdm/ck2-xdg-runtime-dir
Reviewer Review Type Date Requested Status
Robert Ancell Approve
Review via email: mp+283886@code.launchpad.net

Description of the change

ConsoleKit2 recently added support for managing the XDG_RUNTIME_DIR (in git master but not as a release yet), this patch allows lighdm to get the runtime dir from CK2 and export it for the user.

To post a comment you must log in.
Revision history for this message
Robert Ancell (robert-ancell) wrote :

Thanks Eric!

There should be a test for this feature, but I'm happy to add that for you.

It may also be inappropriate to use g_warning when failing to get the directory, as older ConsolKits don't do this. But we can change that if anyone complains.

review: Approve
Revision history for this message
Robert Ancell (robert-ancell) wrote :

See revision 2274 for tests that were added for this.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/console-kit.c'
2--- src/console-kit.c 2014-11-21 07:45:05 +0000
3+++ src/console-kit.c 2016-01-26 01:28:04 +0000
4@@ -260,3 +260,53 @@
5 if (!is_closed)
6 g_warning ("ConsoleKit.Manager.CloseSession() returned false");
7 }
8+
9+gchar *
10+ck_get_xdg_runtime_dir (const gchar *cookie)
11+{
12+ GDBusConnection *bus;
13+ gchar *session_path;
14+ gchar *runtime_dir = NULL;
15+ GError *error = NULL;
16+
17+ g_return_if_fail (cookie != NULL);
18+
19+ g_debug ("Getting XDG_RUNTIME_DIR from ConsoleKit for session %s", cookie);
20+
21+ bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
22+ if (error)
23+ g_warning ("Failed to get system bus: %s", error->message);
24+ g_clear_error (&error);
25+ if (!bus)
26+ return NULL;
27+
28+ session_path = get_ck_session (bus, cookie);
29+ if (session_path)
30+ {
31+ GVariant *result;
32+
33+ result = g_dbus_connection_call_sync (bus,
34+ "org.freedesktop.ConsoleKit",
35+ session_path,
36+ "org.freedesktop.ConsoleKit.Session",
37+ "GetXDGRuntimeDir",
38+ g_variant_new ("()"),
39+ G_VARIANT_TYPE ("(s)"),
40+ G_DBUS_CALL_FLAGS_NONE,
41+ -1,
42+ NULL,
43+ &error);
44+ if (error)
45+ g_warning ("Error getting XDG_RUNTIME_DIR from ConsoleKit: %s", error->message);
46+ g_clear_error (&error);
47+ if (!result)
48+ return NULL;
49+
50+ g_variant_get (result, "(s)", &runtime_dir);
51+ g_variant_unref (result);
52+ g_debug ("ConsoleKit XDG_RUNTIME_DIR is %s", runtime_dir);
53+ }
54+
55+ g_object_unref (bus);
56+ return runtime_dir;
57+}
58
59=== modified file 'src/console-kit.h'
60--- src/console-kit.h 2014-11-21 07:45:05 +0000
61+++ src/console-kit.h 2016-01-26 01:28:04 +0000
62@@ -26,6 +26,8 @@
63
64 void ck_close_session (const gchar *cookie);
65
66+gchar *ck_get_xdg_runtime_dir (const gchar *cookie);
67+
68 G_END_DECLS
69
70 #endif /* CONSOLE_KIT_H_ */
71
72=== modified file 'src/session-child.c'
73--- src/session-child.c 2015-11-02 03:27:55 +0000
74+++ src/session-child.c 2016-01-26 01:28:04 +0000
75@@ -621,9 +621,20 @@
76 if (console_kit_cookie)
77 {
78 gchar *value;
79+ gchar *runtime_dir;
80 value = g_strdup_printf ("XDG_SESSION_COOKIE=%s", console_kit_cookie);
81 pam_putenv (pam_handle, value);
82 g_free (value);
83+
84+ runtime_dir = ck_get_xdg_runtime_dir (console_kit_cookie);
85+ if (runtime_dir)
86+ {
87+ gchar *value;
88+ value = g_strdup_printf ("XDG_RUNTIME_DIR=%s", runtime_dir);
89+ pam_putenv (pam_handle, value);
90+ g_free (value);
91+ g_free (runtime_dir);
92+ }
93 }
94 }
95

Subscribers

People subscribed via source and target branches