chiark / gitweb /
logind: expose CanGraphical and CanTTY properties on seat objects
authorLennart Poettering <lennart@poettering.net>
Thu, 21 Jun 2012 11:48:01 +0000 (13:48 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 21 Jun 2012 11:48:01 +0000 (13:48 +0200)
Since we boot so fast now that gdm might get started before the
graphics drivers are properly loaded and probed we might end up
announcing seat0 to gdm before it has graphics capabilities. Which will
cause gdm/X11 cause to fail later on.

To fix this race, let's expose CanGraphical and CanTTY fields on all
seats, which clarify whether a seat is suitable for gdm resp, suitable
for text logins. gdm then needs to watch CanGraphical and spawn X11 on
it only if it is true.

This way:

USB graphics seats will expose CanGraphical=yes, CanTTY=no

Machines with no graphics drivers at all, but a text console:
CanGraphical=no, CanTTY=yes

Machines with CONFIG_VT turned off: CanGraphical=yes, CanTTY=no

And the most important case: seat0 where the graphics driver has not
been probed yet boot up with CanGraphical=no, CanTTY=yes first, which
then changes to CanGraphical=yes as soon as the probing is complete.

TODO
src/login/logind-device.c
src/login/logind-seat-dbus.c
src/login/logind-seat.c
src/login/logind-seat.h

diff --git a/TODO b/TODO
index 73230caae984bd869c73531db82a9d64cc62697a..872d66652c5909ab4609577a4cf22b4ef3f9303e 100644 (file)
--- a/TODO
+++ b/TODO
@@ -12,8 +12,6 @@ Bugfixes:
 
 * make anaconda write timeout=0 for encrypted devices
 
 
 * make anaconda write timeout=0 for encrypted devices
 
-* make sure timeouts are applied to Type=oneshot services.
-
 * Dangling symlinks of .automount unit files in .wants/ directories, set up
   automount points even when the original .automount file did not exist
   anymore. Only the .mount unit was still around.
 * Dangling symlinks of .automount unit files in .wants/ directories, set up
   automount points even when the original .automount file did not exist
   anymore. Only the .mount unit was still around.
@@ -27,16 +25,19 @@ Bugfixes:
 
 Features:
 
 
 Features:
 
-* introduce CanGraphics and CanText properties on seat objects, to combat races where gdm is started before the graphics driver is loaded and finished probing.
+* support rd.luks= kernel cmdline params in cryptsetup generator
+
+* support rd.fstab= kernel cmdline params in fstab generator
+
+* support rd.driver= kernel cmdline params in modules load
 
 
-* change $NOTIFY_SOCKET to use an abstract namespace socket, so that chroot() is compatible with this
-  https://bugzilla.redhat.com/show_bug.cgi?id=833105
+* supprto rd.xxx wherever else makes sense
 
 * readahead: merge the three tools into one binary
 
 * systemctl: when stopping a service which has triggres and warning about it actually check the TriggeredBy= deps fields
 
 
 * readahead: merge the three tools into one binary
 
 * systemctl: when stopping a service which has triggres and warning about it actually check the TriggeredBy= deps fields
 
-* send bus signal to upower on resume so that it can send out its dbus signal for compat
+* send SIGPWR to upower on resume so that it can send out its dbus signal for compat
 
 * vtconsole: don't override kernel cmdline utf8 override setting
 
 
 * vtconsole: don't override kernel cmdline utf8 override setting
 
index 828e1efe4a2b79d01a5a63a432d8c2f9fd1ba435..51b15358baa07684819d7c6717e46454ed1bd266 100644 (file)
@@ -65,22 +65,32 @@ void device_free(Device *d) {
 }
 
 void device_detach(Device *d) {
 }
 
 void device_detach(Device *d) {
+        Seat *s;
         assert(d);
 
         assert(d);
 
-        if (d->seat)
-                LIST_REMOVE(Device, devices, d->seat->devices, d);
+        if (!d->seat)
+                return;
 
 
-        seat_add_to_gc_queue(d->seat);
+        s = d->seat;
+        LIST_REMOVE(Device, devices, d->seat->devices, d);
         d->seat = NULL;
         d->seat = NULL;
+
+        seat_add_to_gc_queue(s);
+        seat_send_changed(s, "CanGraphical\0");
 }
 
 void device_attach(Device *d, Seat *s) {
         assert(d);
         assert(s);
 
 }
 
 void device_attach(Device *d, Seat *s) {
         assert(d);
         assert(s);
 
+        if (d->seat == s)
+                return;
+
         if (d->seat)
                 device_detach(d);
 
         d->seat = s;
         LIST_PREPEND(Device, devices, s->devices, d);
         if (d->seat)
                 device_detach(d);
 
         d->seat = s;
         LIST_PREPEND(Device, devices, s->devices, d);
+
+        seat_send_changed(s, "CanGraphical\0");
 }
 }
index 4bf9bf7b1ff84e2efeb2f7e80a1588a913430b13..7833d70a03425e8c8aa2025501afc79c73a2dee4 100644 (file)
@@ -36,6 +36,8 @@
         "  <property name=\"Id\" type=\"s\" access=\"read\"/>\n"        \
         "  <property name=\"ActiveSession\" type=\"so\" access=\"read\"/>\n" \
         "  <property name=\"CanMultiSession\" type=\"b\" access=\"read\"/>\n" \
         "  <property name=\"Id\" type=\"s\" access=\"read\"/>\n"        \
         "  <property name=\"ActiveSession\" type=\"so\" access=\"read\"/>\n" \
         "  <property name=\"CanMultiSession\" type=\"b\" access=\"read\"/>\n" \
+        "  <property name=\"CanTTY\" type=\"b\" access=\"read\"/>\n" \
+        "  <property name=\"CanGraphical\" type=\"b\" access=\"read\"/>\n" \
         "  <property name=\"Sessions\" type=\"a(so)\" access=\"read\"/>\n" \
         "  <property name=\"IdleHint\" type=\"b\" access=\"read\"/>\n"  \
         "  <property name=\"IdleSinceHint\" type=\"t\" access=\"read\"/>\n" \
         "  <property name=\"Sessions\" type=\"a(so)\" access=\"read\"/>\n" \
         "  <property name=\"IdleHint\" type=\"b\" access=\"read\"/>\n"  \
         "  <property name=\"IdleSinceHint\" type=\"t\" access=\"read\"/>\n" \
@@ -133,7 +135,7 @@ static int bus_seat_append_sessions(DBusMessageIter *i, const char *property, vo
         return 0;
 }
 
         return 0;
 }
 
-static int bus_seat_append_multi_session(DBusMessageIter *i, const char *property, void *data) {
+static int bus_seat_append_can_multi_session(DBusMessageIter *i, const char *property, void *data) {
         Seat *s = data;
         dbus_bool_t b;
 
         Seat *s = data;
         dbus_bool_t b;
 
@@ -149,6 +151,38 @@ static int bus_seat_append_multi_session(DBusMessageIter *i, const char *propert
         return 0;
 }
 
         return 0;
 }
 
+static int bus_seat_append_can_tty(DBusMessageIter *i, const char *property, void *data) {
+        Seat *s = data;
+        dbus_bool_t b;
+
+        assert(i);
+        assert(property);
+        assert(s);
+
+        b = seat_can_tty(s);
+
+        if (!dbus_message_iter_append_basic(i, DBUS_TYPE_BOOLEAN, &b))
+                return -ENOMEM;
+
+        return 0;
+}
+
+static int bus_seat_append_can_graphical(DBusMessageIter *i, const char *property, void *data) {
+        Seat *s = data;
+        dbus_bool_t b;
+
+        assert(i);
+        assert(property);
+        assert(s);
+
+        b = seat_can_graphical(s);
+
+        if (!dbus_message_iter_append_basic(i, DBUS_TYPE_BOOLEAN, &b))
+                return -ENOMEM;
+
+        return 0;
+}
+
 static int bus_seat_append_idle_hint(DBusMessageIter *i, const char *property, void *data) {
         Seat *s = data;
         dbus_bool_t b;
 static int bus_seat_append_idle_hint(DBusMessageIter *i, const char *property, void *data) {
         Seat *s = data;
         dbus_bool_t b;
@@ -210,7 +244,9 @@ static int get_seat_for_path(Manager *m, const char *path, Seat **_s) {
 static const BusProperty bus_login_seat_properties[] = {
         { "Id",                     bus_property_append_string,      "s", offsetof(Seat, id), true },
         { "ActiveSession",          bus_seat_append_active,       "(so)", 0 },
 static const BusProperty bus_login_seat_properties[] = {
         { "Id",                     bus_property_append_string,      "s", offsetof(Seat, id), true },
         { "ActiveSession",          bus_seat_append_active,       "(so)", 0 },
-        { "CanMultiSession",        bus_seat_append_multi_session,   "b", 0 },
+        { "CanMultiSession",        bus_seat_append_can_multi_session, "b", 0 },
+        { "CanTTY",                 bus_seat_append_can_tty,         "b", 0 },
+        { "CanGraphical",           bus_seat_append_can_graphical,   "b", 0 },
         { "Sessions",               bus_seat_append_sessions,    "a(so)", 0 },
         { "IdleHint",               bus_seat_append_idle_hint,       "b", 0 },
         { "IdleSinceHint",          bus_seat_append_idle_hint_since, "t", 0 },
         { "Sessions",               bus_seat_append_sessions,    "a(so)", 0 },
         { "IdleHint",               bus_seat_append_idle_hint,       "b", 0 },
         { "IdleSinceHint",          bus_seat_append_idle_hint_since, "t", 0 },
index 755f20c03a8eb3658df78114a078aab871c45c17..045712192a35e0feecb9ff5044de1759aae2480a 100644 (file)
@@ -104,9 +104,13 @@ int seat_save(Seat *s) {
         fprintf(f,
                 "# This is private data. Do not parse.\n"
                 "IS_VTCONSOLE=%i\n"
         fprintf(f,
                 "# This is private data. Do not parse.\n"
                 "IS_VTCONSOLE=%i\n"
-                "CAN_MULTI_SESSION=%i\n",
+                "CAN_MULTI_SESSION=%i\n"
+                "CAN_TTY=%i\n"
+                "CAN_GRAPHICAL=%i\n",
                 seat_is_vtconsole(s),
                 seat_is_vtconsole(s),
-                seat_can_multi_session(s));
+                seat_can_multi_session(s),
+                seat_can_tty(s),
+                seat_can_graphical(s));
 
         if (s->active) {
                 assert(s->active->user);
 
         if (s->active) {
                 assert(s->active->user);
@@ -427,6 +431,18 @@ bool seat_can_multi_session(Seat *s) {
         return s->manager->console_active_fd >= 0;
 }
 
         return s->manager->console_active_fd >= 0;
 }
 
+bool seat_can_tty(Seat *s) {
+        assert(s);
+
+        return seat_is_vtconsole(s);
+}
+
+bool seat_can_graphical(Seat *s) {
+        assert(s);
+
+        return !!s->devices;
+}
+
 int seat_get_idle_hint(Seat *s, dual_timestamp *t) {
         Session *session;
         bool idle_hint = true;
 int seat_get_idle_hint(Seat *s, dual_timestamp *t) {
         Session *session;
         bool idle_hint = true;
index d41320da46aef0b88d951328b6fd718da444dd47..1abbc344ecbf7fd11562fc4f521923bd4f869e60 100644 (file)
@@ -63,6 +63,9 @@ int seat_attach_session(Seat *s, Session *session);
 
 bool seat_is_vtconsole(Seat *s);
 bool seat_can_multi_session(Seat *s);
 
 bool seat_is_vtconsole(Seat *s);
 bool seat_can_multi_session(Seat *s);
+bool seat_can_tty(Seat *s);
+bool seat_can_graphical(Seat *s);
+
 int seat_get_idle_hint(Seat *s, dual_timestamp *t);
 
 int seat_start(Seat *s);
 int seat_get_idle_hint(Seat *s, dual_timestamp *t);
 
 int seat_start(Seat *s);