Merge lp:~laney/lightdm/logind into lp:lightdm

Proposed by Iain Lane
Status: Merged
Approved by: Robert Ancell
Approved revision: 1673
Merged at revision: 1651
Proposed branch: lp:~laney/lightdm/logind
Merge into: lp:lightdm
Diff against target: 1350 lines (+577/-159)
14 files modified
liblightdm-gobject/power.c (+110/-67)
liblightdm-qt/power.cpp (+34/-2)
src/Makefile.am (+2/-0)
src/login1.c (+137/-0)
src/login1.h (+29/-0)
src/session-child.c (+43/-28)
src/session.c (+40/-20)
src/xauthority.c (+1/-1)
src/xserver-local.c (+1/-0)
tests/scripts/console-kit.conf (+3/-0)
tests/scripts/power-no-console-kit.conf (+4/-4)
tests/scripts/power.conf (+4/-4)
tests/src/libsystem.c (+1/-0)
tests/src/test-runner.c (+168/-33)
To merge this branch: bzr merge lp:~laney/lightdm/logind
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Robert Ancell Needs Fixing
Review via email: mp+160089@code.launchpad.net

Commit message

Use everywhere instead of UPower and ConsoleKit - lock/unlock/suspend/hibernate.

Description of the change

Fully use logind in preference to ConsoleKit and UPower, since these two are both deprecated. This adds support for both logging in with logind tracking the session, without CK, and for using logind to suspend/resume in addition to reboot/shutdown that was recently merged to trunk.

We don't need to explicitly register the session with logind, since this is handled by the PAM module for us.

I also fixed some small problems that were mostly caught by -Wall -Werror.

I'm not entirely sure about the test coverage, so please review that closely.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:1668
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~laney/lightdm/logind/+merge/160089/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/lightdm-ci/23/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/lightdm-raring-amd64-ci/17

Click here to trigger a rebuild:
http://s-jenkins:8080/job/lightdm-ci/23/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:1668
http://jenkins.qa.ubuntu.com/job/lightdm-ci/24/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/lightdm-raring-amd64-ci/18

Click here to trigger a rebuild:
http://s-jenkins:8080/job/lightdm-ci/24/rebuild

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

Thanks Iain!

The tests are wrong:
- You don't need to add a login1 test as it does nothing different to an autologin test, by default all logins will now uses login1 so all the other tests cover this.
- You need to add back the no-login1 and no-console-kit tests - these test that you can still log in if these services are not available. By removing them there's no checking for these cases

I think this should say "using login1". This should not be considered an error, use g_debug.

105 + g_printerr ("Can't suspend using lightdm; falling back to UPower: %s",
106 + (*error)->message);

174 + g_printerr ("Can't hibernate using lightdm; falling back to UPower: %s",
175 + (*error)->message);

Should be inside login1.h, not session.h. Also would prefer to be a function instead of a macro.

677 +#define LOGIND_RUNNING() (access ("/run/systemd/seats/", F_OK) >= 0)

Some minor issues using two spaces for indentation instead of four, use of // for comments instead of /* */.

Revision history for this message
Robert Ancell (robert-ancell) :
review: Needs Fixing
lp:~laney/lightdm/logind updated
1669. By Iain Lane

Fix copy and paste errors

 - Can't suspend using lightdm → logind
 - g_printerr → g_debug in above message; there is a fallback.

1670. By Iain Lane

Whitespace fixes

I'm sure there's more.

1671. By Iain Lane

Move LOGIND_RUNNING to login1.h

1672. By Iain Lane

Another comment fix

1673. By Iain Lane

Readd no-login1 and no-console-kit tests, remove login1 test.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:1673
http://jenkins.qa.ubuntu.com/job/lightdm-ci/26/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/lightdm-raring-amd64-ci/20

Click here to trigger a rebuild:
http://s-jenkins:8080/job/lightdm-ci/26/rebuild

review: Approve (continuous-integration)
Revision history for this message
Iain Lane (laney) wrote :

Hi, thanks for the review.

On Mon, Apr 22, 2013 at 11:23:25PM -0000, Robert Ancell wrote:
> Thanks Iain!
>
> The tests are wrong:
> - You don't need to add a login1 test as it does nothing different to an autologin test, by default all logins will now uses login1 so all the other tests cover this.
> - You need to add back the no-login1 and no-console-kit tests - these test that you can still log in if these services are not available. By removing them there's no checking for these cases

The no-console-kit test was the same as the login1 test. I'll put back the
other name though. I think that came from cavalier's branch.

laney@raring> diff -u no-console-kit.conf login1.conf
--- no-console-kit.conf 2013-04-23 15:18:55.722670000 +0100
+++ login1.conf 2013-04-22 12:05:01.628529093 +0100
@@ -1,5 +1,5 @@
 #
-# Check still works when ConsoleKit is not available
+# Check session can start with logind
 #

 [test-runner-config]

I think that test-no-login1 is the same as test-console-kit? Except with the
difference that console-kit checkes for the cookie being set too.

I have made these changes though; you can fix it up later on if you like.

>
> I think this should say "using login1". This should not be considered an error, use g_debug.
>
> 105 + g_printerr ("Can't suspend using lightdm; falling back to UPower: %s",
> 106 + (*error)->message);
>
> 174 + g_printerr ("Can't hibernate using lightdm; falling back to UPower: %s",
> 175 + (*error)->message);

Fixed. Thanks, good catch - copy&paste error.

>
> Should be inside login1.h, not session.h. Also would prefer to be a function instead of a macro.
>
> 677 +#define LOGIND_RUNNING() (access ("/run/systemd/seats/", F_OK) >= 0)

Moved but I've left it as a macro - this seems to be the standard way being
implemented in GNOME and other places, advocated by pitti and Lennart.

  https://mail.gnome.org/archives/desktop-devel-list/2013-March/msg00092.html

>
> Some minor issues using two spaces for indentation instead of four, use of // for comments instead of /* */.

Fixed some whitespace errors that I (and emacs) found. Not sure I caught them
all though.

--
Iain Lane [ <email address hidden> ]
Debian Developer [ <email address hidden> ]
Ubuntu Developer [ <email address hidden> ]

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'liblightdm-gobject/power.c'
2--- liblightdm-gobject/power.c 2013-04-15 03:06:52 +0000
3+++ liblightdm-gobject/power.c 2013-04-23 14:46:29 +0000
4@@ -22,8 +22,6 @@
5 static GVariant *
6 upower_call_function (const gchar *function, GError **error)
7 {
8- GVariant *result;
9-
10 if (!upower_proxy)
11 {
12 upower_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
13@@ -47,6 +45,36 @@
14 error);
15 }
16
17+static GVariant *
18+login1_call_function (const gchar *function, GVariant *parameters, GError **error)
19+{
20+ GVariant *r;
21+
22+ if (!login1_proxy)
23+ {
24+ login1_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
25+ G_DBUS_PROXY_FLAGS_NONE,
26+ NULL,
27+ "org.freedesktop.login1",
28+ "/org/freedesktop/login1",
29+ "org.freedesktop.login1.Manager",
30+ NULL,
31+ error);
32+ if (!login1_proxy)
33+ return NULL;
34+ }
35+
36+ r = g_dbus_proxy_call_sync (login1_proxy,
37+ function,
38+ parameters,
39+ G_DBUS_CALL_FLAGS_NONE,
40+ -1,
41+ NULL,
42+ error);
43+
44+ return r;
45+}
46+
47 /**
48 * lightdm_get_can_suspend:
49 *
50@@ -57,16 +85,27 @@
51 gboolean
52 lightdm_get_can_suspend (void)
53 {
54- GVariant *result;
55 gboolean can_suspend = FALSE;
56-
57- result = upower_call_function ("SuspendAllowed", NULL);
58- if (!result)
59- return FALSE;
60-
61- if (g_variant_is_of_type (result, G_VARIANT_TYPE ("(b)")))
62- g_variant_get (result, "(b)", &can_suspend);
63- g_variant_unref (result);
64+ GVariant *r;
65+
66+ r = login1_call_function ("CanSuspend", NULL, NULL);
67+ if (r)
68+ {
69+ gchar *result;
70+ if (g_variant_is_of_type (r, G_VARIANT_TYPE ("(s)")))
71+ {
72+ g_variant_get (r, "(&s)", &result);
73+ can_suspend = g_strcmp0 (result, "yes") == 0;
74+ }
75+ }
76+ else
77+ {
78+ r = upower_call_function ("SuspendAllowed", NULL);
79+ if (r && g_variant_is_of_type (r, G_VARIANT_TYPE ("(b)")))
80+ g_variant_get (r, "(b)", &can_suspend);
81+ }
82+ if (r)
83+ g_variant_unref (r);
84
85 return can_suspend;
86 }
87@@ -76,21 +115,33 @@
88 * @error: return location for a #GError, or %NULL
89 *
90 * Triggers a system suspend.
91- *
92+ *
93 * Return value: #TRUE if suspend initiated.
94 **/
95 gboolean
96 lightdm_suspend (GError **error)
97 {
98 GVariant *result;
99-
100- result = upower_call_function ("Suspend", error);
101+ gboolean suspended;
102+
103+ result = login1_call_function ("Suspend", g_variant_new("(b)", FALSE),
104+ error);
105+
106 if (!result)
107- return FALSE;
108-
109- g_variant_unref (result);
110-
111- return TRUE;
112+ {
113+ if (error)
114+ g_debug ("Can't suspend using logind; falling back to UPower: %s",
115+ (*error)->message);
116+ g_clear_error (error);
117+ result = upower_call_function ("Suspend", error);
118+ }
119+
120+ suspended = result != NULL;
121+ if (result)
122+ g_variant_unref (result);
123+
124+ return suspended;
125+
126 }
127
128 /**
129@@ -103,16 +154,27 @@
130 gboolean
131 lightdm_get_can_hibernate (void)
132 {
133- GVariant *result;
134 gboolean can_hibernate = FALSE;
135-
136- result = upower_call_function ("HibernateAllowed", NULL);
137- if (!result)
138- return FALSE;
139+ GVariant *r;
140
141- if (g_variant_is_of_type (result, G_VARIANT_TYPE ("(b)")))
142- g_variant_get (result, "(b)", &can_hibernate);
143- g_variant_unref (result);
144+ r = login1_call_function ("CanHibernate", NULL, NULL);
145+ if (r)
146+ {
147+ gchar *result;
148+ if (g_variant_is_of_type (r, G_VARIANT_TYPE ("(s)")))
149+ {
150+ g_variant_get (r, "(&s)", &result);
151+ can_hibernate = g_strcmp0 (result, "yes") == 0;
152+ }
153+ }
154+ else
155+ {
156+ r = upower_call_function ("HibernateAllowed", NULL);
157+ if (r && g_variant_is_of_type (r, G_VARIANT_TYPE ("(b)")))
158+ g_variant_get (r, "(b)", &can_hibernate);
159+ }
160+ if (r)
161+ g_variant_unref (r);
162
163 return can_hibernate;
164 }
165@@ -122,21 +184,32 @@
166 * @error: return location for a #GError, or %NULL
167 *
168 * Triggers a system hibernate.
169- *
170+ *
171 * Return value: #TRUE if hibernate initiated.
172 **/
173 gboolean
174 lightdm_hibernate (GError **error)
175 {
176 GVariant *result;
177-
178- result = upower_call_function ("Hibernate", error);
179+ gboolean hibernated;
180+
181+ result = login1_call_function ("Hibernate", g_variant_new("(b)", FALSE),
182+ error);
183+
184 if (!result)
185- return FALSE;
186-
187- g_variant_unref (result);
188-
189- return TRUE;
190+ {
191+ if (error)
192+ g_debug ("Can't hibernate using logind; falling back to UPower: %s",
193+ (*error)->message);
194+ g_clear_error (error);
195+ result = upower_call_function ("Hibernate", error);
196+ }
197+
198+ hibernated = result != NULL;
199+ if (result)
200+ g_variant_unref (result);
201+
202+ return hibernated;
203 }
204
205 static GVariant *
206@@ -169,37 +242,6 @@
207 return r;
208 }
209
210-static GVariant *
211-login1_call_function (const gchar *function, GVariant *parameters, GError **error)
212-{
213- GVariant *r;
214- gchar *str_result;
215-
216- if (!login1_proxy)
217- {
218- login1_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
219- G_DBUS_PROXY_FLAGS_NONE,
220- NULL,
221- "org.freedesktop.login1",
222- "/org/freedesktop/login1",
223- "org.freedesktop.login1.Manager",
224- NULL,
225- error);
226- if (!login1_proxy)
227- return NULL;
228- }
229-
230- r = g_dbus_proxy_call_sync (login1_proxy,
231- function,
232- parameters,
233- G_DBUS_CALL_FLAGS_NONE,
234- -1,
235- NULL,
236- error);
237-
238- return r;
239-}
240-
241 /**
242 * lightdm_get_can_restart:
243 *
244@@ -250,6 +292,7 @@
245 gboolean restarted;
246
247 r = login1_call_function ("Reboot", g_variant_new("(b)", FALSE), error);
248+
249 if (!r)
250 {
251 g_clear_error (error);
252@@ -274,7 +317,7 @@
253 {
254 gboolean can_shutdown = FALSE;
255 GVariant *r;
256-
257+
258 r = login1_call_function ("CanPowerOff", NULL, NULL);
259 if (r)
260 {
261
262=== modified file 'liblightdm-qt/power.cpp'
263--- liblightdm-qt/power.cpp 2013-04-15 03:06:52 +0000
264+++ liblightdm-qt/power.cpp 2013-04-23 14:46:29 +0000
265@@ -51,6 +51,17 @@
266
267 bool PowerInterface::canSuspend()
268 {
269+ if (d->login1Interface->isValid())
270+ {
271+ QDBusReply<QString> reply = d->login1Interface->call("CanSuspend");
272+ if (reply.isValid())
273+ {
274+ return reply.value() == "yes";
275+ }
276+ }
277+
278+ qWarning() << d->login1Interface->lastError();
279+
280 QDBusReply<bool> reply = d->powerManagementInterface->call("SuspendAllowed");
281 if (reply.isValid()) {
282 return reply.value();
283@@ -62,12 +73,28 @@
284
285 bool PowerInterface::suspend()
286 {
287- QDBusReply<void> reply = d->powerManagementInterface->call("Suspend");
288+ QDBusReply<void> reply;
289+ if (d->login1Interface->isValid())
290+ reply = d->login1Interface->call("Suspend", false);
291+ else
292+ reply = d->powerManagementInterface->call("Suspend");
293+
294 return reply.isValid ();
295 }
296
297 bool PowerInterface::canHibernate()
298 {
299+ if (d->login1Interface->isValid())
300+ {
301+ QDBusReply<QString> reply = d->login1Interface->call("CanHibernate");
302+ if (reply.isValid())
303+ {
304+ return reply.value() == "yes";
305+ }
306+ }
307+
308+ qWarning() << d->login1Interface->lastError();
309+
310 QDBusReply<bool> reply = d->powerManagementInterface->call("HibernateAllowed");
311 if (reply.isValid()) {
312 return reply.value();
313@@ -79,7 +106,12 @@
314
315 bool PowerInterface::hibernate()
316 {
317- QDBusReply<void> reply = d->powerManagementInterface->call("Hibernate");
318+ QDBusReply<void> reply;
319+ if (d->login1Interface->isValid())
320+ reply = d->login1Interface->call("Hibernate", false);
321+ else
322+ reply = d->powerManagementInterface->call("Hibernate");
323+
324 return reply.isValid ();
325 }
326
327
328=== modified file 'src/Makefile.am'
329--- src/Makefile.am 2013-01-28 17:09:01 +0000
330+++ src/Makefile.am 2013-04-23 14:46:29 +0000
331@@ -28,6 +28,8 @@
332 lightdm.c \
333 ldm-marshal.c \
334 ldm-marshal.h \
335+ login1.c \
336+ login1.h \
337 plymouth.c \
338 plymouth.h \
339 privileges.c \
340
341=== added file 'src/login1.c'
342--- src/login1.c 1970-01-01 00:00:00 +0000
343+++ src/login1.c 2013-04-23 14:46:29 +0000
344@@ -0,0 +1,137 @@
345+/* -*- Mode: C; indent-tabs-mode: nil; tab-width: 4 -*-
346+ *
347+ * Copyright (C) 2010-2011 Robert Ancell.
348+ * Author: Robert Ancell <robert.ancell@canonical.com>
349+ *
350+ * This program is free software: you can redistribute it and/or modify it under
351+ * the terms of the GNU General Public License as published by the Free Software
352+ * Foundation, either version 3 of the License, or (at your option) any later
353+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
354+ * license.
355+ */
356+
357+#include <gio/gio.h>
358+
359+#include "login1.h"
360+
361+gchar *
362+login1_get_session_id (void)
363+{
364+ GDBusConnection *bus;
365+ GVariant *result;
366+ gchar *session_path;
367+ GError *error = NULL;
368+
369+ bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
370+ if (error)
371+ g_warning ("Failed to get system bus: %s", error->message);
372+ g_clear_error (&error);
373+ if (!bus)
374+ return NULL;
375+ result = g_dbus_connection_call_sync (bus,
376+ "org.freedesktop.login1",
377+ "/org/freedesktop/login1",
378+ "org.freedesktop.login1.Manager",
379+ "GetSessionByPID",
380+ g_variant_new ("(u)", getpid()),
381+ G_VARIANT_TYPE ("(o)"),
382+ G_DBUS_CALL_FLAGS_NONE,
383+ -1,
384+ NULL,
385+ &error);
386+ g_object_unref (bus);
387+
388+ if (error)
389+ g_warning ("Failed to open login1 session: %s", error->message);
390+ g_clear_error (&error);
391+ if (!result)
392+ return NULL;
393+
394+ g_variant_get (result, "(o)", &session_path);
395+ g_variant_unref (result);
396+ g_debug ("Got login1 session id: %s", session_path);
397+
398+ return session_path;
399+}
400+
401+void
402+login1_lock_session (const gchar *session_path)
403+{
404+ GDBusConnection *bus;
405+ GError *error = NULL;
406+
407+ g_return_if_fail (session_path != NULL);
408+
409+ g_debug ("Locking login1 session %s", session_path);
410+
411+ bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
412+ if (error)
413+ g_warning ("Failed to get system bus: %s", error->message);
414+ g_clear_error (&error);
415+ if (!bus)
416+ return;
417+
418+ if (session_path)
419+ {
420+ GVariant *result;
421+
422+ result = g_dbus_connection_call_sync (bus,
423+ "org.freedesktop.login1",
424+ session_path,
425+ "org.freedesktop.login1.Session",
426+ "Lock",
427+ g_variant_new ("()"),
428+ G_VARIANT_TYPE ("()"),
429+ G_DBUS_CALL_FLAGS_NONE,
430+ -1,
431+ NULL,
432+ &error);
433+ if (error)
434+ g_warning ("Error locking login1 session: %s", error->message);
435+ g_clear_error (&error);
436+ if (result)
437+ g_variant_unref (result);
438+ }
439+ g_object_unref (bus);
440+}
441+
442+void
443+login1_unlock_session (const gchar *session_path)
444+{
445+ GDBusConnection *bus;
446+ GError *error = NULL;
447+
448+ g_return_if_fail (session_path != NULL);
449+
450+ g_debug ("Unlocking login1 session %s", session_path);
451+
452+ bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
453+ if (error)
454+ g_warning ("Failed to get system bus: %s", error->message);
455+ g_clear_error (&error);
456+ if (!bus)
457+ return;
458+
459+ if (session_path)
460+ {
461+ GVariant *result;
462+
463+ result = g_dbus_connection_call_sync (bus,
464+ "org.freedesktop.login1",
465+ session_path,
466+ "org.freedesktop.login1.Session",
467+ "Unlock",
468+ g_variant_new ("()"),
469+ G_VARIANT_TYPE ("()"),
470+ G_DBUS_CALL_FLAGS_NONE,
471+ -1,
472+ NULL,
473+ &error);
474+ if (error)
475+ g_warning ("Error unlocking login1 session: %s", error->message);
476+ g_clear_error (&error);
477+ if (result)
478+ g_variant_unref (result);
479+ }
480+ g_object_unref (bus);
481+}
482
483=== added file 'src/login1.h'
484--- src/login1.h 1970-01-01 00:00:00 +0000
485+++ src/login1.h 2013-04-23 14:46:29 +0000
486@@ -0,0 +1,29 @@
487+/*
488+ * Copyright (C) 2010-2011 Robert Ancell.
489+ * Author: Robert Ancell <robert.ancell@canonical.com>
490+ *
491+ * This program is free software: you can redistribute it and/or modify it under
492+ * the terms of the GNU General Public License as published by the Free Software
493+ * Foundation, either version 3 of the License, or (at your option) any later
494+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
495+ * license.
496+ */
497+
498+#ifndef _LOGIN1_H_
499+#define _LOGIN1_H_
500+
501+#include <glib-object.h>
502+
503+#define LOGIND_RUNNING() (access ("/run/systemd/seats/", F_OK) >= 0)
504+
505+G_BEGIN_DECLS
506+
507+gchar *login1_get_session_id (void);
508+
509+void login1_lock_session (const gchar *session_path);
510+
511+void login1_unlock_session (const gchar *session_path);
512+
513+G_END_DECLS
514+
515+#endif /* _LOGIN1_H_ */
516
517=== modified file 'src/session-child.c'
518--- src/session-child.c 2013-04-18 23:06:32 +0000
519+++ src/session-child.c 2013-04-23 14:46:29 +0000
520@@ -1,3 +1,5 @@
521+#include <config.h>
522+
523 #include <stdlib.h>
524 #include <stdio.h>
525 #include <unistd.h>
526@@ -14,9 +16,11 @@
527 #include <utmpx.h>
528 #include <sys/mman.h>
529
530+#include "configuration.h"
531 #include "session-child.h"
532 #include "session.h"
533 #include "console-kit.h"
534+#include "login1.h"
535 #include "privileges.h"
536 #include "xauthority.h"
537 #include "configuration.h"
538@@ -190,7 +194,9 @@
539 XAuthority *xauthority = NULL;
540 gchar *xauth_filename;
541 GDBusConnection *bus;
542- gchar *console_kit_cookie;
543+ gchar *console_kit_cookie = NULL;
544+ gchar *login1_session = NULL;
545+
546 const gchar *path;
547 GError *error = NULL;
548 const gchar *locale_value;
549@@ -443,33 +449,42 @@
550 if (!bus)
551 return EXIT_FAILURE;
552
553- /* Open a Console Kit session */
554- g_variant_builder_init (&ck_parameters, G_VARIANT_TYPE ("(a(sv))"));
555- g_variant_builder_open (&ck_parameters, G_VARIANT_TYPE ("a(sv)"));
556- g_variant_builder_add (&ck_parameters, "(sv)", "unix-user", g_variant_new_int32 (user_get_uid (user)));
557- if (g_strcmp0 (class, XDG_SESSION_CLASS_GREETER) == 0)
558- g_variant_builder_add (&ck_parameters, "(sv)", "session-type", g_variant_new_string ("LoginWindow"));
559- if (xdisplay)
560- {
561- g_variant_builder_add (&ck_parameters, "(sv)", "x11-display", g_variant_new_string (xdisplay));
562- if (tty)
563- g_variant_builder_add (&ck_parameters, "(sv)", "x11-display-device", g_variant_new_string (tty));
564- }
565- if (remote_host_name)
566- {
567- g_variant_builder_add (&ck_parameters, "(sv)", "is-local", g_variant_new_boolean (FALSE));
568- g_variant_builder_add (&ck_parameters, "(sv)", "remote-host-name", g_variant_new_string (remote_host_name));
569- }
570- else
571- g_variant_builder_add (&ck_parameters, "(sv)", "is-local", g_variant_new_boolean (TRUE));
572- console_kit_cookie = ck_open_session (&ck_parameters);
573- write_string (console_kit_cookie);
574- if (console_kit_cookie)
575- {
576- gchar *value;
577- value = g_strdup_printf ("XDG_SESSION_COOKIE=%s", console_kit_cookie);
578- pam_putenv (pam_handle, value);
579- g_free (value);
580+ if (LOGIND_RUNNING ())
581+ {
582+ login1_session = login1_get_session_id ();
583+ write_string (login1_session);
584+ }
585+
586+ if (!login1_session)
587+ {
588+ /* Open a Console Kit session */
589+ g_variant_builder_init (&ck_parameters, G_VARIANT_TYPE ("(a(sv))"));
590+ g_variant_builder_open (&ck_parameters, G_VARIANT_TYPE ("a(sv)"));
591+ g_variant_builder_add (&ck_parameters, "(sv)", "unix-user", g_variant_new_int32 (user_get_uid (user)));
592+ if (g_strcmp0 (class, XDG_SESSION_CLASS_GREETER) == 0)
593+ g_variant_builder_add (&ck_parameters, "(sv)", "session-type", g_variant_new_string ("LoginWindow"));
594+ if (xdisplay)
595+ {
596+ g_variant_builder_add (&ck_parameters, "(sv)", "x11-display", g_variant_new_string (xdisplay));
597+ if (tty)
598+ g_variant_builder_add (&ck_parameters, "(sv)", "x11-display-device", g_variant_new_string (tty));
599+ }
600+ if (remote_host_name)
601+ {
602+ g_variant_builder_add (&ck_parameters, "(sv)", "is-local", g_variant_new_boolean (FALSE));
603+ g_variant_builder_add (&ck_parameters, "(sv)", "remote-host-name", g_variant_new_string (remote_host_name));
604+ }
605+ else
606+ g_variant_builder_add (&ck_parameters, "(sv)", "is-local", g_variant_new_boolean (TRUE));
607+ console_kit_cookie = ck_open_session (&ck_parameters);
608+ write_string (console_kit_cookie);
609+ if (console_kit_cookie)
610+ {
611+ gchar *value;
612+ value = g_strdup_printf ("XDG_SESSION_COOKIE=%s", console_kit_cookie);
613+ pam_putenv (pam_handle, value);
614+ g_free (value);
615+ }
616 }
617
618 /* Write X authority */
619
620=== modified file 'src/session.c'
621--- src/session.c 2013-03-07 21:40:31 +0000
622+++ src/session.c 2013-04-23 14:46:29 +0000
623@@ -1,7 +1,7 @@
624 /*
625 * Copyright (C) 2010-2011 Robert Ancell.
626 * Author: Robert Ancell <robert.ancell@canonical.com>
627- *
628+ *
629 * This program is free software: you can redistribute it and/or modify it under
630 * the terms of the GNU General Public License as published by the Free Software
631 * Foundation, either version 3 of the License, or (at your option) any later
632@@ -9,6 +9,8 @@
633 * license.
634 */
635
636+#include <config.h>
637+
638 #include <stdlib.h>
639 #include <string.h>
640 #include <errno.h>
641@@ -22,6 +24,7 @@
642 #include "session.h"
643 #include "configuration.h"
644 #include "console-kit.h"
645+#include "login1.h"
646 #include "guest-account.h"
647
648 enum {
649@@ -62,16 +65,16 @@
650 gboolean authentication_complete;
651 int authentication_result;
652 gchar *authentication_result_string;
653-
654+
655 /* File to log to */
656 gchar *log_filename;
657-
658+
659 /* Seat class */
660 gchar *class;
661
662 /* tty this session is running on */
663 gchar *tty;
664-
665+
666 /* X display connected to */
667 gchar *xdisplay;
668 XAuthority *xauthority;
669@@ -83,6 +86,9 @@
670 /* Console kit cookie */
671 gchar *console_kit_cookie;
672
673+ /* login1 session */
674+ gchar *login1_session;
675+
676 /* Environment to set in child */
677 GList *env;
678 };
679@@ -206,10 +212,10 @@
680 g_warning ("Invalid string length %d from child", length);
681 return NULL;
682 }
683-
684+
685 value = g_malloc (sizeof (char) * (length + 1));
686 read_from_child (session, value, length);
687- value[length] = '\0';
688+ value[length] = '\0';
689
690 return value;
691 }
692@@ -220,7 +226,7 @@
693 Session *session = data;
694
695 session->priv->pid = 0;
696-
697+
698 if (WIFEXITED (status))
699 g_debug ("Session %d exited with return value %d", pid, WEXITSTATUS (status));
700 else if (WIFSIGNALED (status))
701@@ -234,7 +240,7 @@
702 session->priv->authentication_result = PAM_CONV_ERR;
703 g_free (session->priv->authentication_result_string);
704 session->priv->authentication_result_string = g_strdup ("Authentication stopped before completion");
705- g_signal_emit (G_OBJECT (session), signals[AUTHENTICATION_COMPLETE], 0);
706+ g_signal_emit (G_OBJECT (session), signals[AUTHENTICATION_COMPLETE], 0);
707 }
708
709 g_signal_emit (G_OBJECT (session), signals[STOPPED], 0);
710@@ -311,14 +317,14 @@
711 for (i = 0; i < session->priv->messages_length; i++)
712 {
713 struct pam_message *m = &session->priv->messages[i];
714- read_from_child (session, &m->msg_style, sizeof (m->msg_style));
715+ read_from_child (session, &m->msg_style, sizeof (m->msg_style));
716 m->msg = read_string_from_child (session);
717 }
718
719 g_debug ("Session %d got %d message(s) from PAM", session->priv->pid, session->priv->messages_length);
720
721 g_signal_emit (G_OBJECT (session), signals[GOT_MESSAGES], 0);
722- }
723+ }
724
725 return TRUE;
726 }
727@@ -391,7 +397,7 @@
728 /* Close the ends of the pipes we don't need */
729 close (to_child_output);
730 close (from_child_input);
731-
732+
733 /* Indicate what version of the protocol we are using */
734 version = 0;
735 write_data (session, &version, sizeof (version));
736@@ -422,7 +428,7 @@
737 write_data (session, xauth_get_authorization_data (session->priv->xauthority), length);
738 }
739 else
740- write_string (session, NULL);
741+ write_string (session, NULL);
742
743 g_debug ("Started session %d with service '%s', username '%s'", session->priv->pid, service, username);
744
745@@ -472,7 +478,7 @@
746 g_return_if_fail (session != NULL);
747 g_return_if_fail (error != PAM_SUCCESS);
748
749- write_data (session, &error, sizeof (error));
750+ write_data (session, &error, sizeof (error));
751 }
752
753 int
754@@ -529,7 +535,7 @@
755 {
756 gchar *run_dir, *dir;
757
758- run_dir = config_get_string (config_get_instance (), "LightDM", "run-directory");
759+ run_dir = config_get_string (config_get_instance (), "LightDM", "run-directory");
760 dir = g_build_filename (run_dir, session->priv->username, NULL);
761 g_free (run_dir);
762
763@@ -558,30 +564,43 @@
764 for (i = 0; i < argc; i++)
765 write_string (session, argv[i]);
766
767- session->priv->console_kit_cookie = read_string_from_child (session);
768+ if (LOGIND_RUNNING ())
769+ session->priv->login1_session = read_string_from_child (session);
770+ if (!session->priv->login1_session)
771+ session->priv->console_kit_cookie = read_string_from_child (session);
772 }
773
774 void
775 session_lock (Session *session)
776-{
777+{
778 g_return_if_fail (session != NULL);
779 if (getuid () == 0)
780- ck_lock_session (session->priv->console_kit_cookie);
781+ {
782+ if (LOGIND_RUNNING ())
783+ login1_lock_session (session->priv->login1_session);
784+ if (!session->priv->login1_session)
785+ ck_lock_session (session->priv->console_kit_cookie);
786+ }
787 }
788
789 void
790 session_unlock (Session *session)
791-{
792+{
793 g_return_if_fail (session != NULL);
794 if (getuid () == 0)
795- ck_unlock_session (session->priv->console_kit_cookie);
796+ {
797+ if (LOGIND_RUNNING ())
798+ login1_unlock_session (session->priv->login1_session);
799+ if (!session->priv->login1_session)
800+ ck_unlock_session (session->priv->console_kit_cookie);
801+ }
802 }
803
804 void
805 session_stop (Session *session)
806 {
807 g_return_if_fail (session != NULL);
808-
809+
810 if (session->priv->pid > 0)
811 {
812 g_debug ("Session %d: Sending SIGTERM", session->priv->pid);
813@@ -631,6 +650,7 @@
814 if (self->priv->xauthority)
815 g_object_unref (self->priv->xauthority);
816 g_free (self->priv->remote_host_name);
817+ g_free (self->priv->login1_session);
818 g_free (self->priv->console_kit_cookie);
819 g_list_free_full (self->priv->env, g_free);
820
821
822=== modified file 'src/xauthority.c'
823--- src/xauthority.c 2013-03-27 00:42:28 +0000
824+++ src/xauthority.c 2013-04-23 14:46:29 +0000
825@@ -329,7 +329,7 @@
826 }
827 g_list_free (records);
828
829- result = g_file_set_contents (filename, output->data, output->len, error);
830+ result = g_file_set_contents (filename, (gchar *)output->data, output->len, error);
831 g_byte_array_free (output, TRUE);
832
833 return result;
834
835=== modified file 'src/xserver-local.c'
836--- src/xserver-local.c 2013-04-16 01:03:09 +0000
837+++ src/xserver-local.c 2013-04-23 14:46:29 +0000
838@@ -16,6 +16,7 @@
839 #include <sys/stat.h>
840 #include <errno.h>
841 #include <glib/gstdio.h>
842+#include <stdlib.h>
843
844 #include "xserver-local.h"
845 #include "configuration.h"
846
847=== modified file 'tests/scripts/console-kit.conf'
848--- tests/scripts/console-kit.conf 2012-02-29 22:23:17 +0000
849+++ tests/scripts/console-kit.conf 2013-04-23 14:46:29 +0000
850@@ -2,6 +2,9 @@
851 # Check ConsoleKit variable is set in session
852 #
853
854+[test-runner-config]
855+disable-login1=true
856+
857 [LightDM]
858 minimum-display-number=50
859
860
861=== modified file 'tests/scripts/power-no-console-kit.conf'
862--- tests/scripts/power-no-console-kit.conf 2013-04-15 03:06:52 +0000
863+++ tests/scripts/power-no-console-kit.conf 2013-04-23 14:46:29 +0000
864@@ -26,21 +26,21 @@
865
866 # See if can suspend
867 #?*GREETER :50 GET-CAN-SUSPEND
868-#?UPOWER SUSPEND-ALLOWED
869+#?LOGIN1 CAN-SUSPEND
870 #?GREETER :50 CAN-SUSPEND ALLOWED=TRUE
871
872 # Suspend
873 #?*GREETER :50 SUSPEND
874-#?UPOWER SUSPEND
875+#?LOGIN1 SUSPEND
876
877 # See if can hibernate
878 #?*GREETER :50 GET-CAN-HIBERNATE
879-#?UPOWER HIBERNATE-ALLOWED
880+#?LOGIN1 CAN-HIBERNATE
881 #?GREETER :50 CAN-HIBERNATE ALLOWED=TRUE
882
883 # Hibernate
884 #?*GREETER :50 HIBERNATE
885-#?UPOWER HIBERNATE
886+#?LOGIN1 HIBERNATE
887
888 # See if can restart
889 #?*GREETER :50 GET-CAN-RESTART
890
891=== modified file 'tests/scripts/power.conf'
892--- tests/scripts/power.conf 2013-04-15 03:06:52 +0000
893+++ tests/scripts/power.conf 2013-04-23 14:46:29 +0000
894@@ -23,21 +23,21 @@
895
896 # See if can suspend
897 #?*GREETER :50 GET-CAN-SUSPEND
898-#?UPOWER SUSPEND-ALLOWED
899+#?LOGIN1 CAN-SUSPEND
900 #?GREETER :50 CAN-SUSPEND ALLOWED=TRUE
901
902 # Suspend
903 #?*GREETER :50 SUSPEND
904-#?UPOWER SUSPEND
905+#?LOGIN1 SUSPEND
906
907 # See if can hibernate
908 #?*GREETER :50 GET-CAN-HIBERNATE
909-#?UPOWER HIBERNATE-ALLOWED
910+#?LOGIN1 CAN-HIBERNATE
911 #?GREETER :50 CAN-HIBERNATE ALLOWED=TRUE
912
913 # Hibernate
914 #?*GREETER :50 HIBERNATE
915-#?UPOWER HIBERNATE
916+#?LOGIN1 HIBERNATE
917
918 # See if can restart
919 #?*GREETER :50 GET-CAN-RESTART
920
921=== modified file 'tests/src/libsystem.c'
922--- tests/src/libsystem.c 2013-03-06 22:35:36 +0000
923+++ tests/src/libsystem.c 2013-04-23 14:46:29 +0000
924@@ -4,6 +4,7 @@
925 #include <sys/types.h>
926 #include <sys/stat.h>
927 #include <pwd.h>
928+#include <unistd.h>
929 #include <grp.h>
930 #include <security/pam_appl.h>
931 #include <fcntl.h>
932
933=== modified file 'tests/src/test-runner.c'
934--- tests/src/test-runner.c 2013-04-15 03:06:52 +0000
935+++ tests/src/test-runner.c 2013-04-23 14:46:29 +0000
936@@ -83,7 +83,7 @@
937 } CKSession;
938 static GList *ck_sessions = NULL;
939 static gint ck_session_index = 0;
940-static void handle_ck_session_call (GDBusConnection *connection,
941+static void handle_session_call (GDBusConnection *connection,
942 const gchar *sender,
943 const gchar *object_path,
944 const gchar *interface_name,
945@@ -93,8 +93,18 @@
946 gpointer user_data);
947 static const GDBusInterfaceVTable ck_session_vtable =
948 {
949- handle_ck_session_call,
950+ handle_session_call,
951 };
952+
953+typedef struct
954+{
955+ gchar *path;
956+ guint pid;
957+} Login1Session;
958+
959+static GList *login1_sessions = NULL;
960+static gint login1_session_index = 0;
961+
962 typedef struct
963 {
964 GSocket *socket;
965@@ -134,7 +144,7 @@
966 {
967 Process *process;
968 gchar *status_text;
969-
970+
971 if (getenv ("DEBUG"))
972 {
973 if (WIFEXITED (status))
974@@ -173,7 +183,7 @@
975 static Process *
976 watch_process (pid_t pid)
977 {
978- Process *process;
979+ Process *process;
980
981 process = g_malloc0 (sizeof (Process));
982 process->pid = pid;
983@@ -360,7 +370,7 @@
984 else if (strcmp (name, "SWITCH-TO-USER") == 0)
985 {
986 gchar *status_text, *username;
987-
988+
989 username = g_hash_table_lookup (params, "USERNAME");
990 g_dbus_connection_call_sync (g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL),
991 "org.freedesktop.DisplayManager",
992@@ -456,21 +466,21 @@
993 StatusClient *client = link->data;
994 int length;
995 GError *error = NULL;
996-
997+
998 length = strlen (command);
999 g_socket_send (client->socket, (gchar *) &length, sizeof (length), NULL, &error);
1000 g_socket_send (client->socket, command, strlen (command), NULL, &error);
1001 if (error)
1002 g_printerr ("Failed to write to client socket: %s\n", error->message);
1003 g_clear_error (&error);
1004- }
1005+ }
1006 }
1007 else
1008 {
1009 g_printerr ("Unknown command '%s'\n", name);
1010 quit (EXIT_FAILURE);
1011 }
1012-
1013+
1014 g_free (name);
1015 g_hash_table_unref (params);
1016 }
1017@@ -514,9 +524,9 @@
1018
1019 if (stop)
1020 return;
1021-
1022+
1023 statuses = g_list_append (statuses, g_strdup (status));
1024-
1025+
1026 if (getenv ("DEBUG"))
1027 g_print ("%s\n", status);
1028
1029@@ -528,7 +538,7 @@
1030 result = g_regex_match_simple (full_pattern, status, 0, 0);
1031 g_free (full_pattern);
1032 }
1033-
1034+
1035 if (!result)
1036 {
1037 fail (NULL, pattern);
1038@@ -686,7 +696,7 @@
1039
1040 upower_info = g_dbus_node_info_new_for_xml (upower_interface, &error);
1041 if (error)
1042- g_warning ("Failed to parse D-Bus interface: %s", error->message);
1043+ g_warning ("Failed to parse D-Bus interface: %s", error->message);
1044 g_clear_error (&error);
1045 if (!upower_info)
1046 return;
1047@@ -829,15 +839,17 @@
1048 g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "No such method: %s", method_name);
1049 }
1050
1051+
1052+/* Shared between CK and Login1 - identical signatures */
1053 static void
1054-handle_ck_session_call (GDBusConnection *connection,
1055- const gchar *sender,
1056- const gchar *object_path,
1057- const gchar *interface_name,
1058- const gchar *method_name,
1059- GVariant *parameters,
1060- GDBusMethodInvocation *invocation,
1061- gpointer user_data)
1062+handle_session_call (GDBusConnection *connection,
1063+ const gchar *sender,
1064+ const gchar *object_path,
1065+ const gchar *interface_name,
1066+ const gchar *method_name,
1067+ GVariant *parameters,
1068+ GDBusMethodInvocation *invocation,
1069+ gpointer user_data)
1070 {
1071 if (strcmp (method_name, "Lock") == 0)
1072 g_dbus_method_invocation_return_value (invocation, g_variant_new ("()"));
1073@@ -904,13 +916,13 @@
1074
1075 ck_info = g_dbus_node_info_new_for_xml (ck_interface, &error);
1076 if (error)
1077- g_warning ("Failed to parse D-Bus interface: %s", error->message);
1078+ g_warning ("Failed to parse D-Bus interface: %s", error->message);
1079 g_clear_error (&error);
1080 if (!ck_info)
1081 return;
1082 ck_session_info = g_dbus_node_info_new_for_xml (ck_session_interface, &error);
1083 if (error)
1084- g_warning ("Failed to parse D-Bus interface: %s", error->message);
1085+ g_warning ("Failed to parse D-Bus interface: %s", error->message);
1086 g_clear_error (&error);
1087 if (!ck_session_info)
1088 return;
1089@@ -944,6 +956,59 @@
1090 NULL);
1091 }
1092
1093+static Login1Session *
1094+open_login1_session (GDBusConnection *connection,
1095+ GVariant *params)
1096+{
1097+ Login1Session *session;
1098+ GError *error = NULL;
1099+ GDBusNodeInfo *login1_session_info;
1100+
1101+ const gchar *login1_session_interface =
1102+ "<node>"
1103+ " <interface name='org.freedesktop.login1.Session'>"
1104+ " <method name='Lock'/>"
1105+ " <method name='Unlock'/>"
1106+ " </interface>"
1107+ "</node>";
1108+ static const GDBusInterfaceVTable login1_session_vtable =
1109+ {
1110+ handle_session_call,
1111+ };
1112+
1113+ session = g_malloc0 (sizeof (Login1Session));
1114+ login1_sessions = g_list_append (login1_sessions, session);
1115+
1116+ session->path = g_strdup_printf("/org/freedesktop/login1/Session/c%d",
1117+ login1_session_index++);
1118+
1119+
1120+
1121+ login1_session_info = g_dbus_node_info_new_for_xml (login1_session_interface,
1122+ &error);
1123+ if (error)
1124+ g_warning ("Failed to parse login1 session D-Bus interface: %s",
1125+ error->message);
1126+ g_clear_error (&error);
1127+ if (!login1_session_info)
1128+ return;
1129+
1130+ g_dbus_connection_register_object (connection,
1131+ session->path,
1132+ login1_session_info->interfaces[0],
1133+ &login1_session_vtable,
1134+ session,
1135+ NULL,
1136+ &error);
1137+ if (error)
1138+ g_warning ("Failed to register login1 session: %s", error->message);
1139+ g_clear_error (&error);
1140+ g_dbus_node_info_unref (login1_session_info);
1141+
1142+ return session;
1143+}
1144+
1145+
1146 static void
1147 handle_login1_call (GDBusConnection *connection,
1148 const gchar *sender,
1149@@ -954,7 +1019,36 @@
1150 GDBusMethodInvocation *invocation,
1151 gpointer user_data)
1152 {
1153- if (strcmp (method_name, "CanReboot") == 0)
1154+
1155+ if (strcmp (method_name, "GetSessionByPID") == 0)
1156+ {
1157+ /* Look for a session with our PID, and create one if we don't have one
1158+ already. */
1159+ GList *link;
1160+ guint pid;
1161+ Login1Session *ret = NULL;
1162+
1163+ g_variant_get (parameters, "(u)", &pid);
1164+
1165+ for (link = login1_sessions; link; link = link->next)
1166+ {
1167+ Login1Session *session;
1168+ session = link->data;
1169+ if (session->pid == pid)
1170+ {
1171+ ret = session;
1172+ break;
1173+ }
1174+ }
1175+ /* Not found */
1176+ if (!ret)
1177+ ret = open_login1_session (connection, parameters);
1178+
1179+ g_dbus_method_invocation_return_value (invocation,
1180+ g_variant_new("(o)", ret->path));
1181+
1182+ }
1183+ else if (strcmp (method_name, "CanReboot") == 0)
1184 {
1185 check_status ("LOGIN1 CAN-REBOOT");
1186 g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", "yes"));
1187@@ -971,6 +1065,18 @@
1188 check_status ("LOGIN1 CAN-POWER-OFF");
1189 g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", "yes"));
1190 }
1191+ else if (strcmp (method_name, "Suspend") == 0)
1192+ {
1193+ gboolean interactive;
1194+ g_variant_get (parameters, "(b)", &interactive);
1195+ check_status ("LOGIN1 SUSPEND");
1196+ g_dbus_method_invocation_return_value (invocation, g_variant_new ("()"));
1197+ }
1198+ else if (strcmp (method_name, "CanSuspend") == 0)
1199+ {
1200+ check_status ("LOGIN1 CAN-SUSPEND");
1201+ g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", "yes"));
1202+ }
1203 else if (strcmp (method_name, "PowerOff") == 0)
1204 {
1205 gboolean interactive;
1206@@ -978,6 +1084,18 @@
1207 check_status ("LOGIN1 POWER-OFF");
1208 g_dbus_method_invocation_return_value (invocation, g_variant_new ("()"));
1209 }
1210+ else if (strcmp (method_name, "CanHibernate") == 0)
1211+ {
1212+ check_status ("LOGIN1 CAN-HIBERNATE");
1213+ g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", "yes"));
1214+ }
1215+ else if (strcmp (method_name, "Hibernate") == 0)
1216+ {
1217+ gboolean interactive;
1218+ g_variant_get (parameters, "(b)", &interactive);
1219+ check_status ("LOGIN1 HIBERNATE");
1220+ g_dbus_method_invocation_return_value (invocation, g_variant_new ("()"));
1221+ }
1222 else
1223 g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "No such method: %s", method_name);
1224 }
1225@@ -990,6 +1108,10 @@
1226 const gchar *login1_interface =
1227 "<node>"
1228 " <interface name='org.freedesktop.login1.Manager'>"
1229+ " <method name='GetSessionByPID'>"
1230+ " <arg name='pid' type='u' direction='in'/>"
1231+ " <arg name='session' type='o' direction='out'/>"
1232+ " </method>"
1233 " <method name='CanReboot'>"
1234 " <arg name='result' direction='out' type='s'/>"
1235 " </method>"
1236@@ -1002,6 +1124,18 @@
1237 " <method name='PowerOff'>"
1238 " <arg name='interactive' direction='in' type='b'/>"
1239 " </method>"
1240+ " <method name='CanSuspend'>"
1241+ " <arg name='result' direction='out' type='s'/>"
1242+ " </method>"
1243+ " <method name='Suspend'>"
1244+ " <arg name='interactive' direction='in' type='b'/>"
1245+ " </method>"
1246+ " <method name='CanHibernate'>"
1247+ " <arg name='result' direction='out' type='s'/>"
1248+ " </method>"
1249+ " <method name='Hibernate'>"
1250+ " <arg name='interactive' direction='in' type='b'/>"
1251+ " </method>"
1252 " </interface>"
1253 "</node>";
1254 static const GDBusInterfaceVTable login1_vtable =
1255@@ -1013,7 +1147,7 @@
1256
1257 login1_info = g_dbus_node_info_new_for_xml (login1_interface, &error);
1258 if (error)
1259- g_warning ("Failed to parse D-Bus interface: %s", error->message);
1260+ g_warning ("Failed to parse login1 D-Bus interface: %s", error->message);
1261 g_clear_error (&error);
1262 if (!login1_info)
1263 return;
1264@@ -1150,7 +1284,7 @@
1265
1266 g_variant_builder_init (&builder, G_VARIANT_TYPE ("ao"));
1267
1268- load_passwd_file ();
1269+ load_passwd_file ();
1270 for (link = accounts_users; link; link = link->next)
1271 {
1272 AccountsUser *user = link->data;
1273@@ -1183,7 +1317,7 @@
1274 g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "No such user: %s", user_name);
1275 }
1276 else
1277- g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "No such method: %s", method_name);
1278+ g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "No such method: %s", method_name);
1279 }
1280
1281 static void
1282@@ -1292,13 +1426,13 @@
1283
1284 accounts_info = g_dbus_node_info_new_for_xml (accounts_interface, &error);
1285 if (error)
1286- g_warning ("Failed to parse D-Bus interface: %s", error->message);
1287+ g_warning ("Failed to parse D-Bus interface: %s", error->message);
1288 g_clear_error (&error);
1289 if (!accounts_info)
1290 return;
1291 user_info = g_dbus_node_info_new_for_xml (user_interface, &error);
1292 if (error)
1293- g_warning ("Failed to parse D-Bus interface: %s", error->message);
1294+ g_warning ("Failed to parse D-Bus interface: %s", error->message);
1295 g_clear_error (&error);
1296 if (!user_info)
1297 return;
1298@@ -1424,7 +1558,7 @@
1299 g_critical ("Error getting current directory: %s", strerror (errno));
1300 quit (EXIT_FAILURE);
1301 }
1302-
1303+
1304 /* Don't contact our X server */
1305 g_unsetenv ("DISPLAY");
1306
1307@@ -1439,7 +1573,7 @@
1308 g_free (path);
1309
1310 /* Use locally built libraries */
1311- path1 = g_build_filename (BUILDDIR, "liblightdm-gobject", ".libs", NULL);
1312+ path1 = g_build_filename (BUILDDIR, "liblightdm-gobject", ".libs", NULL);
1313 path2 = g_build_filename (BUILDDIR, "liblightdm-qt", ".libs", NULL);
1314 ld_library_path = g_strdup_printf ("%s:%s", path1, path2);
1315 g_free (path1);
1316@@ -1510,7 +1644,7 @@
1317
1318 /* Always copy the script */
1319 if (system (g_strdup_printf ("cp %s %s/script", config_path, temp_dir)))
1320- perror ("Failed to copy configuration");
1321+ perror ("Failed to copy configuration");
1322
1323 /* Copy over the greeter files */
1324 if (system (g_strdup_printf ("cp -r %s/xsessions %s/usr/share", DATADIR, temp_dir)))
1325@@ -1568,7 +1702,7 @@
1326 /* This account has a set of keyboard layouts */
1327 {"have-layouts", "", TRUE, "Layouts User", NULL, "ru", "fr\toss;ru;", NULL, 1010},
1328 /* This account has a language set */
1329- {"have-language", "", TRUE, "Language User", NULL, NULL, NULL, "en_AU.utf8", 1011},
1330+ {"have-language", "", TRUE, "Language User", NULL, NULL, NULL, "en_AU.utf8", 1011},
1331 /* This account has a preconfigured session */
1332 {"have-session", "", TRUE, "Session User", "alternative", NULL, NULL, NULL, 1012},
1333 /* This account has the home directory mounted on login */
1334@@ -1642,6 +1776,7 @@
1335 {
1336 g_key_file_set_string (dmrc_file, "X-Accounts", "Layouts", users[i].dbus_layouts);
1337 save_dmrc = TRUE;
1338+
1339 }
1340 if (users[i].language)
1341 {
1342@@ -1657,7 +1792,7 @@
1343 data = g_key_file_to_data (dmrc_file, NULL, NULL);
1344 g_file_set_contents (path, data, -1, NULL);
1345 g_free (data);
1346- g_free (path);
1347+ g_free (path);
1348 }
1349
1350 g_key_file_free (dmrc_file);

Subscribers

People subscribed via source and target branches