Merge lp:~ballogy/indicator-session/systemd-support into lp:indicator-session/13.04

Proposed by Balló György
Status: Rejected
Rejected by: Ted Gould
Proposed branch: lp:~ballogy/indicator-session/systemd-support
Merge into: lp:indicator-session/13.04
Diff against target: 84 lines (+66/-1)
1 file modified
src/gtk-logout-helper.c (+66/-1)
To merge this branch: bzr merge lp:~ballogy/indicator-session/systemd-support
Reviewer Review Type Date Requested Status
Mathieu Trudel-Lapierre Abstain
Review via email: mp+141656@code.launchpad.net

Description of the change

This change adds systemd support for gtk-logout-helper.

Since shutdown/reboot with gnome-session works only with a patch that rejected by upstream[1], and consolekit is no longer available on systemd systems (e.g. Arch Linux), systemd-logind[2] is the only way to do this.

[1] https://bugzilla.gnome.org/show_bug.cgi?id=575880
[2] http://www.freedesktop.org/wiki/Software/systemd/logind

To post a comment you must log in.
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Removing the consolekit_fallback looks wrong at first glance; but there's not enough context to see what's up. Seems to me like doing things this way would break those systems that should still fallback using consolekit.

It *is* a call to consolekit_fallback from within call_consolkit though, so maybe doing things this way isn't so crazy, but it seems to me like the initial assumption was to try again if the call to consolekit somehow failed; so that the failure can be recovered from.

Shouldn't it be possible to decide which backend to use at compile time?

review: Needs Information
Revision history for this message
Balló György (ballogy) wrote :

Calling consolekit_fallback from within consolekit_fallback would lead to an infinite loop if consolekit is not available, so I don't think it's a good solution. It was introduced by a debugging commit:
http://bazaar.launchpad.net/~indicator-applet-developers/indicator-session/trunk.13.04/revision/209

With my patch, gtk-logout-helper tries to use gnome-session first, then falls back to consolekit, and in the last case, it falls back to systemd. Of course, it can be easily implemented as a build option also, but I think it's simpler implementation as a fallback of fallback.

Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

This is still missing a review from Jenkins for CI, and I'd honestly like to see a review from someone else who knows more about consolekit and all than I do.

As for another branch from you, let's commit this to trunk as well. Could you please file another merge request for the same changes against lp:indicator-session?

review: Abstain
Revision history for this message
Ted Gould (ted) wrote :

I don't think this can reasonably land in 13.04 so I'm going to mark it as rejected. Not to the idea overall, but just to this MR.

Unmerged revisions

381. By Balló György

Add support for systemd

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/gtk-logout-helper.c'
2--- src/gtk-logout-helper.c 2012-11-29 22:09:57 +0000
3+++ src/gtk-logout-helper.c 2013-01-02 19:00:42 +0000
4@@ -31,6 +31,71 @@
5 #include "shared-names.h"
6
7 static GVariant *
8+call_systemd (const gchar *method, GVariant *parameters, GError **error)
9+{
10+ GDBusConnection * bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, error);
11+ if (!bus)
12+ {
13+ g_variant_unref (parameters);
14+ return NULL;
15+ }
16+
17+ GVariant *result = g_dbus_connection_call_sync(bus,
18+ "org.freedesktop.login1",
19+ "/org/freedesktop/login1",
20+ "org.freedesktop.login1.Manager",
21+ method,
22+ parameters,
23+ NULL,
24+ G_DBUS_CALL_FLAGS_NONE,
25+ -1,
26+ NULL,
27+ error);
28+ g_object_unref (bus);
29+
30+ return result;
31+}
32+
33+static void
34+systemd_fallback (LogoutDialogType action)
35+{
36+ GError * error = NULL;
37+ GVariant *result = NULL;
38+
39+ g_debug("Falling back to using systemd for action");
40+
41+ switch (action) {
42+ case LOGOUT_DIALOG_TYPE_LOG_OUT:
43+ g_warning("Unable to fallback to systemd for logout as it's a session issue. We need some sort of session handler.");
44+ break;
45+ case LOGOUT_DIALOG_TYPE_SHUTDOWN:
46+ g_debug("Telling systemd to 'PowerOff'");
47+ result = call_systemd ("PowerOff", g_variant_new ("(b)", TRUE), &error);
48+ break;
49+ case LOGOUT_DIALOG_TYPE_RESTART:
50+ g_debug("Telling systemd to 'Reboot'");
51+ result = call_systemd ("Reboot", g_variant_new ("(b)", TRUE), &error);
52+ break;
53+ default:
54+ g_warning("Unknown action");
55+ break;
56+ }
57+
58+ if (!result) {
59+ if (error != NULL) {
60+ g_warning ("systemd action failed: %s", error->message);
61+ } else {
62+ g_warning ("systemd action failed: unknown error");
63+ }
64+ }
65+ else
66+ g_variant_unref (result);
67+ g_clear_error (&error);
68+
69+ return;
70+}
71+
72+static GVariant *
73 call_console_kit (const gchar *method, GVariant *parameters, GError **error)
74 {
75 GDBusConnection * bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, error);
76@@ -88,7 +153,7 @@
77 g_warning ("ConsoleKit action failed: unknown error");
78 }
79
80- consolekit_fallback(action);
81+ systemd_fallback(action);
82 }
83 else
84 g_variant_unref (result);

Subscribers

People subscribed via source and target branches