Merge lp:~mterry/lightdm/dbus-activate-logind into lp:lightdm

Proposed by Michael Terry
Status: Merged
Approved by: Robert Ancell
Approved revision: 1988
Merged at revision: 1987
Proposed branch: lp:~mterry/lightdm/dbus-activate-logind
Merge into: lp:lightdm
Diff against target: 66 lines (+37/-5)
2 files modified
src/login1.c (+37/-1)
tests/src/libsystem.c (+0/-4)
To merge this branch: bzr merge lp:~mterry/lightdm/dbus-activate-logind
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Robert Ancell Approve
Review via email: mp+219576@code.launchpad.net

Commit message

DBus-activate logind

Description of the change

DBus-activate logind.

While debugging a bug introduced by some upstart changes in Touch, I noticed that if LightDM starts before logind happens to be dbus-activated somewhere else, it will think it isn't available.

LightDM currently only checks if logind is ALREADY started. But since logind is started via dbus-activation instead of upstart, we can't ensure that. So when we check if logind is available, we should instead see if it can be started.

To post a comment you must log in.
Revision history for this message
Michael Terry (mterry) wrote :

Oh, right. Let me change test system for this.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Robert Ancell (robert-ancell) wrote :

Is that the appropriate way to start a service now? Shouldn't we just try to access it and that will cause it to be started if necessary? Could this change start logind even if the sysadmin wanted it disabled for some reason?

Revision history for this message
Michael Terry (mterry) wrote :

StartServiceByName is what gio does under the hood to start services. I was trying to be as direct as possible. But I realized that only works if there is a .service file for login1. Maybe some versions of login1 will be launched differently (by upstart or systemd) and be available already without a .service file. (like our test runner version of login1 in fact)

So I switched the logic to just create a proxy and check if there is a name owner.

As for sysadmins disabling logind activation, it's not just lightdm that will do this. Any app anywhere could start it up by trying to talk to it. The only safe way for an admin to disable it is deleting the .service file or removing the package. Which seems reasonable if you don't want to use logind.

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

Looks a lot better than that dodgy "check /run" there was before.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/login1.c'
2--- src/login1.c 2014-03-17 16:02:32 +0000
3+++ src/login1.c 2014-05-14 20:19:19 +0000
4@@ -14,10 +14,46 @@
5
6 #include "login1.h"
7
8+static gboolean
9+check_login1 (void)
10+{
11+ GDBusProxy *proxy;
12+ gchar *owner;
13+ gboolean success;
14+
15+ proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
16+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
17+ NULL,
18+ "org.freedesktop.login1",
19+ "/org/freedesktop/login1",
20+ "org.freedesktop.login1.Manager",
21+ NULL,
22+ NULL);
23+ if (!proxy)
24+ return FALSE;
25+
26+ owner = g_dbus_proxy_get_name_owner (proxy);
27+ g_object_unref (proxy);
28+
29+ success = (owner != NULL);
30+ g_free (owner);
31+
32+ return success;
33+}
34+
35 gboolean
36 login1_is_running (void)
37 {
38- return access ("/run/systemd/seats/", F_OK) >= 0;
39+ static gboolean have_checked = FALSE;
40+ static gboolean is_running = FALSE;
41+
42+ if (!have_checked)
43+ {
44+ have_checked = TRUE;
45+ is_running = check_login1();
46+ }
47+
48+ return is_running;
49 }
50
51 gchar *
52
53=== modified file 'tests/src/libsystem.c'
54--- tests/src/libsystem.c 2014-03-23 22:28:44 +0000
55+++ tests/src/libsystem.c 2014-05-14 20:19:19 +0000
56@@ -331,10 +331,6 @@
57 gchar *new_path = NULL;
58 int ret;
59
60- /* Look like systemd is always running */
61- if (strcmp (pathname, "/run/systemd/seats/") == 0)
62- return 1;
63-
64 _access = (int (*)(const char *pathname, int mode)) dlsym (RTLD_NEXT, "access");
65
66 new_path = redirect_path (pathname);

Subscribers

People subscribed via source and target branches