1 |
ssuominen 10/09/09 12:35:56 |
2 |
|
3 |
Added: xfce4-session-4.7.0-ck-launch-session.patch |
4 |
Log: |
5 |
Check for XDG_SESSION_COOKIE and run consolekit session if required (or reuse existing session). |
6 |
|
7 |
(Portage version: 2.2_rc75/cvs/Linux x86_64) |
8 |
|
9 |
Revision Changes Path |
10 |
1.1 xfce-base/xfce4-session/files/xfce4-session-4.7.0-ck-launch-session.patch |
11 |
|
12 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/xfce-base/xfce4-session/files/xfce4-session-4.7.0-ck-launch-session.patch?rev=1.1&view=markup |
13 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/xfce-base/xfce4-session/files/xfce4-session-4.7.0-ck-launch-session.patch?rev=1.1&content-type=text/plain |
14 |
|
15 |
Index: xfce4-session-4.7.0-ck-launch-session.patch |
16 |
=================================================================== |
17 |
From 35c620aa3749581580e0917ff7c2db1c223564a8 Mon Sep 17 00:00:00 2001 |
18 |
From: Jannis Pohlmann <jannis@××××.org> |
19 |
Date: Wed, 08 Sep 2010 10:02:46 +0000 |
20 |
Subject: Reuse existing ConsoleKit sessions (bug #6685). |
21 |
|
22 |
According to the ConsoleKit documentation, only one session leader may |
23 |
exist for a session. An application becomes the leader of a session by |
24 |
calling org.freedesktop.ConsoleKit.Manager.OpenSession() which returns a |
25 |
session identifier. This identifier is then made available to other |
26 |
session clients by setting the XDG_SESSION_COOKIE environment variable. |
27 |
|
28 |
GDM and upstart open ConsoleKit sessions on their own and desktop |
29 |
environments are supposed to reuse these sessions instead of opening new |
30 |
ones. So with this commit, xfce4-session checks for XDG_SESSION_COOKIE |
31 |
and, if it exists, does not try to call OpenSession in order to |
32 |
overwrite this environment variable. |
33 |
|
34 |
I tested this with xfce4-session-logout which finally allows me to |
35 |
reboot and shutdown again. |
36 |
|
37 |
Also fix the indentation, use spaces instead of tabs etc. |
38 |
--- |
39 |
diff --git a/xfce4-session/xfsm-manager.c b/xfce4-session/xfsm-manager.c |
40 |
index 3eb7696..892b6c6 100644 |
41 |
--- a/xfce4-session/xfsm-manager.c |
42 |
+++ b/xfce4-session/xfsm-manager.c |
43 |
@@ -257,11 +255,11 @@ xfsm_manager_init (XfsmManager *manager) |
44 |
#ifdef ENABLE_CONSOLE_KIT |
45 |
manager->system_bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); |
46 |
|
47 |
- if ( G_LIKELY (manager->system_bus != NULL) ) |
48 |
+ if (G_LIKELY (manager->system_bus != NULL)) |
49 |
{ |
50 |
xfsm_manager_consolekit_init (manager); |
51 |
} |
52 |
- else if ( error ) |
53 |
+ else if (error) |
54 |
{ |
55 |
g_warning ("Failed to connect to the system bus : %s", error->message); |
56 |
g_error_free (error); |
57 |
@@ -279,7 +277,7 @@ xfsm_manager_finalize (GObject *obj) |
58 |
#ifdef ENABLE_CONSOLE_KIT |
59 |
xfsm_manager_consolekit_cleanup (manager); |
60 |
|
61 |
- if ( manager->system_bus ) |
62 |
+ if (manager->system_bus) |
63 |
dbus_g_connection_unref (manager->system_bus); |
64 |
#endif /*ENABLE_CONSOLE_KIT*/ |
65 |
|
66 |
@@ -342,6 +340,7 @@ xfsm_manager_new (void) |
67 |
return manager; |
68 |
} |
69 |
|
70 |
+ |
71 |
#ifdef ENABLE_CONSOLE_KIT |
72 |
static void xfsm_manager_consolekit_init (XfsmManager *manager) |
73 |
{ |
74 |
@@ -349,61 +348,83 @@ static void xfsm_manager_consolekit_init (XfsmManager *manager) |
75 |
gboolean ret; |
76 |
|
77 |
manager->consolekit_proxy = dbus_g_proxy_new_for_name_owner (manager->system_bus, |
78 |
- "org.freedesktop.ConsoleKit", |
79 |
- "/org/freedesktop/ConsoleKit/Manager", |
80 |
- "org.freedesktop.ConsoleKit.Manager", |
81 |
- NULL); |
82 |
+ "org.freedesktop.ConsoleKit", |
83 |
+ "/org/freedesktop/ConsoleKit/Manager", |
84 |
+ "org.freedesktop.ConsoleKit.Manager", |
85 |
+ NULL); |
86 |
|
87 |
|
88 |
- if ( G_UNLIKELY (!manager->consolekit_proxy) ) |
89 |
+ if (G_UNLIKELY (!manager->consolekit_proxy)) |
90 |
{ |
91 |
g_warning ("Failed to create proxy for 'org.freedesktop.ConsoleKit'"); |
92 |
return; |
93 |
} |
94 |
|
95 |
- ret = dbus_g_proxy_call (manager->consolekit_proxy, "OpenSession", &error, |
96 |
- G_TYPE_INVALID, |
97 |
- G_TYPE_STRING, &manager->consolekit_cookie, |
98 |
- G_TYPE_INVALID); |
99 |
- |
100 |
- if ( G_LIKELY (ret) ) |
101 |
+ /* check if there is a session to reuse */ |
102 |
+ if (g_getenv ("XDG_SESSION_COOKIE") != NULL) |
103 |
{ |
104 |
- /* |
105 |
- * ConsoleKit doc says that the leader session should set the cookie |
106 |
- * on XDG_SESSION_COOKIE env variable. |
107 |
- */ |
108 |
- g_warn_if_fail (g_setenv ("XDG_SESSION_COOKIE", |
109 |
- manager->consolekit_cookie, |
110 |
- TRUE)); |
111 |
+#ifdef DEBUG |
112 |
+ g_debug ("Reusing existing ConsoleKit session: XDG_SESSION_ID=%s", |
113 |
+ g_getenv ("XDG_SESSION_COOKIE")); |
114 |
+#endif |
115 |
} |
116 |
- else if ( error ) |
117 |
+ else |
118 |
{ |
119 |
- g_warning ("OpenSession on 'org.freedesktop.ConsoleKit' failed with %s", error->message); |
120 |
- g_error_free (error); |
121 |
+ /* try to open a new session. as its leader we are then responsible for |
122 |
+ * setting XDG_SESSION_COOKIE as well as closing the session before we exit */ |
123 |
+ ret = dbus_g_proxy_call (manager->consolekit_proxy, "OpenSession", &error, |
124 |
+ G_TYPE_INVALID, |
125 |
+ G_TYPE_STRING, &manager->consolekit_cookie, |
126 |
+ G_TYPE_INVALID); |
127 |
+ |
128 |
+ if (G_LIKELY (ret)) |
129 |
+ { |
130 |
+ /* |
131 |
+ * ConsoleKit doc says that the leader session should set the cookie |
132 |
+ * on XDG_SESSION_COOKIE env variable. |
133 |
+ */ |
134 |
+ if (g_setenv ("XDG_SESSION_COOKIE", manager->consolekit_cookie, TRUE)) |
135 |
+ { |
136 |
+#ifdef DEBUG |
137 |
+ g_debug ("Opening a new ConsoleKit session: XDG_SESSION_COOKIE=%s", |
138 |
+ manager->consolekit_cookie); |
139 |
+#endif |
140 |
+ } |
141 |
+ else |
142 |
+ { |
143 |
+ g_warning ("Failed to set XDG_SESSION_COOKIE"); |
144 |
+ } |
145 |
+ } |
146 |
+ else if (error) |
147 |
+ { |
148 |
+ g_warning ("OpenSession on 'org.freedesktop.ConsoleKit' failed with %s", error->message); |
149 |
+ g_error_free (error); |
150 |
+ } |
151 |
} |
152 |
} |
153 |
|
154 |
+ |
155 |
static void xfsm_manager_consolekit_cleanup (XfsmManager *manager) |
156 |
{ |
157 |
- if ( manager->consolekit_proxy ) |
158 |
+ GError *error = NULL; |
159 |
+ gboolean ret, result; |
160 |
+ |
161 |
+ if (manager->consolekit_proxy) |
162 |
{ |
163 |
if (manager->consolekit_cookie) |
164 |
- { |
165 |
- GError *error = NULL; |
166 |
- gboolean ret, result; |
167 |
- |
168 |
- ret = dbus_g_proxy_call (manager->consolekit_proxy, "CloseSession", &error, |
169 |
- G_TYPE_STRING, manager->consolekit_cookie, |
170 |
- G_TYPE_INVALID, |
171 |
- G_TYPE_BOOLEAN, &result, |
172 |
- G_TYPE_INVALID); |
173 |
- if ( !ret ) |
174 |
- { |
175 |
- g_warning ("CloseSession on 'org.freedesktop.ConsoleKit' failed with %s", error->message); |
176 |
- g_error_free (error); |
177 |
- } |
178 |
- g_free (manager->consolekit_cookie); |
179 |
- } |
180 |
+ { |
181 |
+ ret = dbus_g_proxy_call (manager->consolekit_proxy, "CloseSession", &error, |
182 |
+ G_TYPE_STRING, manager->consolekit_cookie, |
183 |
+ G_TYPE_INVALID, |
184 |
+ G_TYPE_BOOLEAN, &result, |
185 |
+ G_TYPE_INVALID); |
186 |
+ if (!ret) |
187 |
+ { |
188 |
+ g_warning ("CloseSession on 'org.freedesktop.ConsoleKit' failed with %s", error->message); |
189 |
+ g_error_free (error); |
190 |
+ } |
191 |
+ g_free (manager->consolekit_cookie); |
192 |
+ } |
193 |
g_object_unref (manager->consolekit_proxy); |
194 |
} |
195 |
} |
196 |
@@ -1181,6 +1202,7 @@ xfsm_manager_interact_done (XfsmManager *manager, |
197 |
xfsm_manager_start_client_save_timeout (manager, client); |
198 |
} |
199 |
|
200 |
+ |
201 |
static void |
202 |
xfsm_manager_save_yourself_global (XfsmManager *manager, |
203 |
gint save_type, |
204 |
@@ -1222,8 +1244,8 @@ xfsm_manager_save_yourself_global (XfsmManager *manager, |
205 |
shutdown_helper = xfsm_shutdown_helper_new (); |
206 |
|
207 |
if (!xfsm_shutdown_helper_send_command (shutdown_helper, |
208 |
- manager->shutdown_type, |
209 |
- &error)) |
210 |
+ manager->shutdown_type, |
211 |
+ &error)) |
212 |
{ |
213 |
xfce_message_dialog (NULL, _("Shutdown Failed"), |
214 |
GTK_STOCK_DIALOG_ERROR, |
215 |
@@ -1237,7 +1259,7 @@ xfsm_manager_save_yourself_global (XfsmManager *manager, |
216 |
} |
217 |
|
218 |
/* clean up and return */ |
219 |
- g_object_unref (shutdown_helper); |
220 |
+ g_object_unref (shutdown_helper); |
221 |
|
222 |
|
223 |
/* at this point, either we failed to suspend/hibernate, or we |
224 |
-- |
225 |
cgit v0.8.2.1 |