Contents of /trunk/xfce4-session/patches/xfce4-session-4.10.0-systemd-v2.patch
Parent Directory | Revision Log
Revision 1933 -
(show annotations)
(download)
Wed Oct 31 14:49:48 2012 UTC (11 years, 10 months ago) by niro
File size: 12799 byte(s)
Wed Oct 31 14:49:48 2012 UTC (11 years, 10 months ago) by niro
File size: 12799 byte(s)
-added christians hesses systemd-v2 patch, see:https://bugzilla.xfce.org/show_bug.cgi?id=8729
1 | diff -Nurp xfce4-session-4.10.0-orig/configure.in xfce4-session-4.10.0/configure.in |
2 | --- xfce4-session-4.10.0-orig/configure.in 2012-04-28 22:43:29.000000000 +0200 |
3 | +++ xfce4-session-4.10.0/configure.in 2012-10-30 21:55:21.292172649 +0100 |
4 | @@ -106,6 +106,33 @@ XDT_CHECK_OPTIONAL_PACKAGE([GNOME_KEYRIN |
5 | [libgnome-keyring], |
6 | [Extra gnome-keyring compatibility support], [no]) |
7 | |
8 | +dnl systemd integration |
9 | +AC_ARG_ENABLE([systemd], |
10 | + AS_HELP_STRING([--enable-systemd], [Use systemd]), |
11 | + [with_systemd=$enableval], |
12 | + [with_systemd=auto]) |
13 | +PKG_CHECK_MODULES(SYSTEMD, |
14 | + [libsystemd-login polkit-gobject-1], |
15 | + [have_systemd=yes], [have_systemd=no]) |
16 | +AC_MSG_CHECKING([whether to use systemd]) |
17 | +if test x$with_systemd = xauto ; then |
18 | + if test x$have_systemd = xno ; then |
19 | + with_systemd=no |
20 | + else |
21 | + with_systemd=yes |
22 | + fi |
23 | +fi |
24 | +AC_MSG_RESULT($with_systemd) |
25 | +if test x$with_systemd = xyes; then |
26 | + if test x$have_systemd = xno; then |
27 | + AC_MSG_ERROR([Systemd support explicitly required, but systemd not found]) |
28 | + fi |
29 | + AC_DEFINE(HAVE_SYSTEMD, 1, [Define if systemd is used for session tracking]) |
30 | +fi |
31 | +AC_SUBST(SYSTEMD_CFLAGS) |
32 | +AC_SUBST(SYSTEMD_LIBS) |
33 | +AM_CONDITIONAL(WITH_SYSTEMD, [test "$with_systemd" = "yes"], [Using systemd]) |
34 | + |
35 | dnl Check for debugging support |
36 | XDT_FEATURE_DEBUG([xfsm_debug_default]) |
37 | |
38 | diff -Nurp xfce4-session-4.10.0-orig/xfce4-session/Makefile.am xfce4-session-4.10.0/xfce4-session/Makefile.am |
39 | --- xfce4-session-4.10.0-orig/xfce4-session/Makefile.am 2012-04-28 22:43:27.000000000 +0200 |
40 | +++ xfce4-session-4.10.0/xfce4-session/Makefile.am 2012-10-30 21:56:26.374874843 +0100 |
41 | @@ -38,8 +38,6 @@ xfce4_session_SOURCES = \ |
42 | xfsm-compat-gnome.h \ |
43 | xfsm-compat-kde.c \ |
44 | xfsm-compat-kde.h \ |
45 | - xfsm-consolekit.c \ |
46 | - xfsm-consolekit.h \ |
47 | xfsm-dns.c \ |
48 | xfsm-dns.h \ |
49 | xfsm-error.c \ |
50 | @@ -65,6 +63,16 @@ xfce4_session_SOURCES = \ |
51 | xfsm-upower.c \ |
52 | xfsm-upower.h |
53 | |
54 | +if WITH_SYSTEMD |
55 | +xfce4_session_SOURCES += \ |
56 | + xfsm-systemd.c \ |
57 | + xfsm-systemd.h |
58 | +else |
59 | +xfce4_session_SOURCES += \ |
60 | + xfsm-consolekit.c \ |
61 | + xfsm-consolekit.h |
62 | +endif |
63 | + |
64 | xfce4_session_CFLAGS = \ |
65 | $(GNOME_KEYRING_CFLAGS) \ |
66 | $(LIBSM_CFLAGS) \ |
67 | @@ -73,6 +81,7 @@ xfce4_session_CFLAGS = \ |
68 | $(DBUS_CFLAGS) \ |
69 | $(DBUS_GLIB_CFLAGS) \ |
70 | $(LIBWNCK_CFLAGS) \ |
71 | + $(SYSTEMD_CFLAGS) \ |
72 | $(XFCONF_CFLAGS) \ |
73 | $(GMODULE_CFLAGS) \ |
74 | $(PLATFORM_CFLAGS) |
75 | @@ -92,6 +101,7 @@ xfce4_session_LDADD = \ |
76 | $(DBUS_LIBS) \ |
77 | $(DBUS_GLIB_LIBS) \ |
78 | $(LIBWNCK_LIBS) \ |
79 | + $(SYSTEMD_LIBS) \ |
80 | $(XFCONF_LIBS) \ |
81 | $(GNOME_KEYRING_LIBS) \ |
82 | -lm |
83 | diff -Nurp xfce4-session-4.10.0-orig/xfce4-session/xfsm-shutdown.c xfce4-session-4.10.0/xfce4-session/xfsm-shutdown.c |
84 | --- xfce4-session-4.10.0-orig/xfce4-session/xfsm-shutdown.c 2012-04-28 22:43:27.000000000 +0200 |
85 | +++ xfce4-session-4.10.0/xfce4-session/xfsm-shutdown.c 2012-10-30 21:58:49.423400226 +0100 |
86 | @@ -66,10 +66,13 @@ |
87 | #include <xfce4-session/xfsm-fadeout.h> |
88 | #include <xfce4-session/xfsm-global.h> |
89 | #include <xfce4-session/xfsm-legacy.h> |
90 | -#include <xfce4-session/xfsm-consolekit.h> |
91 | #include <xfce4-session/xfsm-upower.h> |
92 | |
93 | - |
94 | +#ifdef HAVE_SYSTEMD |
95 | +#include <xfce4-session/xfsm-systemd.h> |
96 | +#else |
97 | +#include <xfce4-session/xfsm-consolekit.h> |
98 | +#endif |
99 | |
100 | static void xfsm_shutdown_finalize (GObject *object); |
101 | static void xfsm_shutdown_sudo_free (XfsmShutdown *shutdown); |
102 | @@ -93,7 +96,11 @@ struct _XfsmShutdown |
103 | { |
104 | GObject __parent__; |
105 | |
106 | +#ifdef HAVE_SYSTEMD |
107 | + XfsmSystemd *systemd; |
108 | +#else |
109 | XfsmConsolekit *consolekit; |
110 | +#endif |
111 | XfsmUPower *upower; |
112 | |
113 | /* kiosk settings */ |
114 | @@ -131,7 +138,11 @@ xfsm_shutdown_init (XfsmShutdown *shutdo |
115 | { |
116 | XfceKiosk *kiosk; |
117 | |
118 | +#ifdef HAVE_SYSTEMD |
119 | + shutdown->systemd = xfsm_systemd_new (); |
120 | +#else |
121 | shutdown->consolekit = xfsm_consolekit_get (); |
122 | +#endif |
123 | shutdown->upower = xfsm_upower_get (); |
124 | shutdown->helper_state = SUDO_NOT_INITIAZED; |
125 | shutdown->helper_require_password = FALSE; |
126 | @@ -150,7 +161,11 @@ xfsm_shutdown_finalize (GObject *object) |
127 | { |
128 | XfsmShutdown *shutdown = XFSM_SHUTDOWN (object); |
129 | |
130 | +#ifdef HAVE_SYSTEMD |
131 | + xfsm_systemd_free (shutdown->systemd); |
132 | +#else |
133 | g_object_unref (G_OBJECT (shutdown->consolekit)); |
134 | +#endif |
135 | g_object_unref (G_OBJECT (shutdown->upower)); |
136 | |
137 | /* close down helper */ |
138 | @@ -641,7 +656,11 @@ xfsm_shutdown_try_restart (XfsmShutdown |
139 | if (shutdown->helper_state == SUDO_AVAILABLE) |
140 | return xfsm_shutdown_sudo_try_action (shutdown, XFSM_SHUTDOWN_RESTART, error); |
141 | else |
142 | +#ifdef HAVE_SYSTEMD |
143 | + return xfsm_systemd_try_reboot (shutdown->systemd, error); |
144 | +#else |
145 | return xfsm_consolekit_try_restart (shutdown->consolekit, error); |
146 | +#endif |
147 | } |
148 | |
149 | |
150 | @@ -658,7 +677,11 @@ xfsm_shutdown_try_shutdown (XfsmShutdown |
151 | if (shutdown->helper_state == SUDO_AVAILABLE) |
152 | return xfsm_shutdown_sudo_try_action (shutdown, XFSM_SHUTDOWN_SHUTDOWN, error); |
153 | else |
154 | +#ifdef HAVE_SYSTEMD |
155 | + return xfsm_systemd_try_shutdown (shutdown->systemd, error); |
156 | +#else |
157 | return xfsm_consolekit_try_shutdown (shutdown->consolekit, error); |
158 | +#endif |
159 | } |
160 | |
161 | |
162 | @@ -698,7 +729,11 @@ xfsm_shutdown_can_restart (XfsmShutdown |
163 | return TRUE; |
164 | } |
165 | |
166 | +#ifdef HAVE_SYSTEMD |
167 | + if (xfsm_systemd_can_reboot (shutdown->systemd, can_restart, error)) |
168 | +#else |
169 | if (xfsm_consolekit_can_restart (shutdown->consolekit, can_restart, error)) |
170 | +#endif |
171 | return TRUE; |
172 | |
173 | if (xfsm_shutdown_sudo_init (shutdown, error)) |
174 | @@ -725,7 +760,11 @@ xfsm_shutdown_can_shutdown (XfsmShutdown |
175 | return TRUE; |
176 | } |
177 | |
178 | +#ifdef HAVE_SYSTEMD |
179 | + if (xfsm_systemd_can_poweroff (shutdown->systemd, can_shutdown, error)) |
180 | +#else |
181 | if (xfsm_consolekit_can_shutdown (shutdown->consolekit, can_shutdown, error)) |
182 | +#endif |
183 | return TRUE; |
184 | |
185 | if (xfsm_shutdown_sudo_init (shutdown, error)) |
186 | diff -Nurp xfce4-session-4.10.0-orig/xfce4-session/xfsm-systemd.c xfce4-session-4.10.0/xfce4-session/xfsm-systemd.c |
187 | --- xfce4-session-4.10.0-orig/xfce4-session/xfsm-systemd.c 1970-01-01 01:00:00.000000000 +0100 |
188 | +++ xfce4-session-4.10.0/xfce4-session/xfsm-systemd.c 2012-10-30 21:57:33.760861643 +0100 |
189 | @@ -0,0 +1,126 @@ |
190 | +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- |
191 | + * |
192 | + * Copyright (C) 2012 Christian Hesse |
193 | + * |
194 | + * Licensed under the GNU General Public License Version 2 |
195 | + * |
196 | + * This program is free software; you can redistribute it and/or modify |
197 | + * it under the terms of the GNU General Public License as published by |
198 | + * the Free Software Foundation; either version 2 of the License, or |
199 | + * (at your option) any later version. |
200 | + * |
201 | + * This program is distributed in the hope that it will be useful, |
202 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
203 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
204 | + * GNU General Public License for more details. |
205 | + * |
206 | + * You should have received a copy of the GNU General Public License |
207 | + * along with this program; if not, write to the Free Software |
208 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
209 | + */ |
210 | + |
211 | +#include <config.h> |
212 | + |
213 | +#include <gio/gio.h> |
214 | +#include <polkit/polkit.h> |
215 | + |
216 | +#include "xfsm-systemd.h" |
217 | + |
218 | +#define SYSTEMD_DBUS_NAME "org.freedesktop.login1" |
219 | +#define SYSTEMD_DBUS_PATH "/org/freedesktop/login1" |
220 | +#define SYSTEMD_DBUS_INTERFACE "org.freedesktop.login1.Manager" |
221 | +#define SYSTEMD_REBOOT_ACTION "Reboot" |
222 | +#define SYSTEMD_POWEROFF_ACTION "PowerOff" |
223 | +#define SYSTEMD_REBOOT_TEST "org.freedesktop.login1.reboot" |
224 | +#define SYSTEMD_POWEROFF_TEST "org.freedesktop.login1.power-off" |
225 | + |
226 | +struct _XfsmSystemd { |
227 | + PolkitAuthority *authority; |
228 | + PolkitSubject *subject; |
229 | +}; |
230 | + |
231 | +XfsmSystemd * |
232 | +xfsm_systemd_new (void) |
233 | +{ |
234 | + XfsmSystemd *proxy; |
235 | + |
236 | + proxy = g_new0 (XfsmSystemd, 1); |
237 | + |
238 | + proxy->authority = polkit_authority_get_sync (NULL, NULL); |
239 | + proxy->subject = polkit_unix_process_new (getpid()); |
240 | + |
241 | + return proxy; |
242 | +} |
243 | + |
244 | +void |
245 | +xfsm_systemd_free (XfsmSystemd *proxy) |
246 | +{ |
247 | + g_object_unref (proxy->authority); |
248 | + g_object_unref (proxy->subject); |
249 | + |
250 | + g_free (proxy); |
251 | +} |
252 | + |
253 | +gboolean xfsm_systemd_can_method (XfsmSystemd *proxy, gboolean *can_method, const gchar *method, GError **error) |
254 | +{ |
255 | + PolkitAuthorizationResult *res; |
256 | + GError *local_error = NULL; |
257 | + |
258 | + *can_method = FALSE; |
259 | + res = polkit_authority_check_authorization_sync (proxy->authority, |
260 | + proxy->subject, |
261 | + method, |
262 | + NULL, |
263 | + POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE, |
264 | + NULL, |
265 | + &local_error); |
266 | + if (res == NULL) { |
267 | + g_propagate_error (error, local_error); |
268 | + return FALSE; |
269 | + } |
270 | + |
271 | + *can_method = polkit_authorization_result_get_is_authorized (res) || |
272 | + polkit_authorization_result_get_is_challenge (res); |
273 | + |
274 | + g_object_unref (res); |
275 | + |
276 | + return TRUE; |
277 | +} |
278 | + |
279 | +gboolean xfsm_systemd_can_reboot (XfsmSystemd *proxy, gboolean *can_reboot, GError **error) |
280 | +{ |
281 | + return xfsm_systemd_can_method(proxy, can_reboot, SYSTEMD_REBOOT_TEST, error); |
282 | +} |
283 | + |
284 | +gboolean xfsm_systemd_can_poweroff (XfsmSystemd *proxy, gboolean *can_poweroff, GError **error) |
285 | +{ |
286 | + return xfsm_systemd_can_method(proxy, can_poweroff, SYSTEMD_POWEROFF_TEST, error); |
287 | +} |
288 | + |
289 | +gboolean xfsm_systemd_try_method (XfsmSystemd *proxy, const gchar *method, GError **error) |
290 | +{ |
291 | + GDBusConnection *bus; |
292 | + |
293 | + bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL); |
294 | + g_dbus_connection_call_sync (bus, |
295 | + SYSTEMD_DBUS_NAME, |
296 | + SYSTEMD_DBUS_PATH, |
297 | + SYSTEMD_DBUS_INTERFACE, |
298 | + method, |
299 | + g_variant_new ("(b)", TRUE), |
300 | + NULL, 0, G_MAXINT, NULL, NULL); |
301 | + g_object_unref (bus); |
302 | + |
303 | + return TRUE; |
304 | +} |
305 | + |
306 | +gboolean xfsm_systemd_try_reboot (XfsmSystemd *proxy, GError **error) |
307 | +{ |
308 | + return xfsm_systemd_try_method(proxy, SYSTEMD_REBOOT_ACTION, error); |
309 | +} |
310 | + |
311 | +gboolean xfsm_systemd_try_shutdown (XfsmSystemd *proxy, GError **error) |
312 | +{ |
313 | + return xfsm_systemd_try_method(proxy, SYSTEMD_POWEROFF_ACTION, error); |
314 | +} |
315 | + |
316 | diff -Nurp xfce4-session-4.10.0-orig/xfce4-session/xfsm-systemd.h xfce4-session-4.10.0/xfce4-session/xfsm-systemd.h |
317 | --- xfce4-session-4.10.0-orig/xfce4-session/xfsm-systemd.h 1970-01-01 01:00:00.000000000 +0100 |
318 | +++ xfce4-session-4.10.0/xfce4-session/xfsm-systemd.h 2012-10-30 21:56:43.724702459 +0100 |
319 | @@ -0,0 +1,44 @@ |
320 | +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- |
321 | + * |
322 | + * Copyright (C) 2012 Christian Hesse |
323 | + * |
324 | + * Licensed under the GNU General Public License Version 2 |
325 | + * |
326 | + * This program is free software; you can redistribute it and/or modify |
327 | + * it under the terms of the GNU General Public License as published by |
328 | + * the Free Software Foundation; either version 2 of the License, or |
329 | + * (at your option) any later version. |
330 | + * |
331 | + * This program is distributed in the hope that it will be useful, |
332 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
333 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
334 | + * GNU General Public License for more details. |
335 | + * |
336 | + * You should have received a copy of the GNU General Public License |
337 | + * along with this program; if not, write to the Free Software |
338 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
339 | + */ |
340 | + |
341 | +#ifndef __XFSM_SYSTEMD_H__ |
342 | +#define __XFSM_SYSTEMD_H__ |
343 | + |
344 | +#include <glib.h> |
345 | + |
346 | +G_BEGIN_DECLS |
347 | + |
348 | +typedef struct _XfsmSystemd XfsmSystemd; |
349 | + |
350 | +XfsmSystemd * xfsm_systemd_new (void); |
351 | +void xfsm_systemd_free (XfsmSystemd *proxy); |
352 | + |
353 | +gboolean xfsm_systemd_can_method (XfsmSystemd *proxy, gboolean *can_method, const char *method, GError **error); |
354 | +gboolean xfsm_systemd_can_reboot (XfsmSystemd *proxy, gboolean *can_reboot, GError **error); |
355 | +gboolean xfsm_systemd_can_poweroff (XfsmSystemd *proxy, gboolean *can_poweroff, GError **error); |
356 | + |
357 | +gboolean xfsm_systemd_try_method (XfsmSystemd *proxy, const char *method, GError **error); |
358 | +gboolean xfsm_systemd_try_reboot (XfsmSystemd *proxy, GError **error); |
359 | +gboolean xfsm_systemd_try_poweroff (XfsmSystemd *proxy, GError **error); |
360 | + |
361 | +G_END_DECLS |
362 | + |
363 | +#endif /* __XFSM_SYSTEMD_H__ */ |