diff options
author | Lennart Poettering <lennart@poettering.net> | 2011-06-27 22:44:12 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2011-06-27 22:44:12 +0200 |
commit | 4d6d6518c301c844be59c1b3a0d2092a3218572f (patch) | |
tree | cd41151f7bcecd6eaf1694c2146cb9cef2701952 /src/logind-dbus.c | |
parent | cd58752a158ccab3db77d355410b31b457df4cfc (diff) |
logind: automatically deduce seat from display
Diffstat (limited to 'src/logind-dbus.c')
-rw-r--r-- | src/logind-dbus.c | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/src/logind-dbus.c b/src/logind-dbus.c index 136f610cb6..050eb7160e 100644 --- a/src/logind-dbus.c +++ b/src/logind-dbus.c @@ -53,9 +53,10 @@ " <method name=\"CreateSession\">\n" \ " <arg name=\"uid\" type=\"u\" direction=\"in\"/>\n" \ " <arg name=\"leader\" type=\"u\" direction=\"in\"/>\n" \ - " <arg name=\"sevice\" type=\"s\" direction=\"in\"/>\n" \ + " <arg name=\"sevice\" type=\"s\" direction=\"in\"/>\n" \ " <arg name=\"type\" type=\"s\" direction=\"in\"/>\n" \ " <arg name=\"seat\" type=\"s\" direction=\"in\"/>\n" \ + " <arg name=\"vtnr\" type=\"u\" direction=\"in\"/>\n" \ " <arg name=\"tty\" type=\"s\" direction=\"in\"/>\n" \ " <arg name=\"display\" type=\"s\" direction=\"in\"/>\n" \ " <arg name=\"remote\" type=\"b\" direction=\"in\"/>\n" \ @@ -177,7 +178,7 @@ static int bus_manager_create_session(Manager *m, DBusMessage *message, DBusMess DBusMessageIter iter; int r; char *id = NULL, *p; - int vtnr = -1; + uint32_t vtnr = 0; int pipe_fds[2] = { -1, -1 }; DBusMessage *reply = NULL; bool b; @@ -228,26 +229,48 @@ static int bus_manager_create_session(Manager *m, DBusMessage *message, DBusMess } if (!dbus_message_iter_next(&iter) || + dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_UINT32) + return -EINVAL; + + dbus_message_iter_get_basic(&iter, &vtnr); + + if (!dbus_message_iter_next(&iter) || dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) return -EINVAL; dbus_message_iter_get_basic(&iter, &tty); if (tty_is_vc(tty)) { + int v; if (!s) s = m->vtconsole; else if (s != m->vtconsole) return -EINVAL; - vtnr = vtnr_from_tty(tty); + v = vtnr_from_tty(tty); + + if (v <= 0) + return v < 0 ? v : -EINVAL; if (vtnr <= 0) - return vtnr < 0 ? vtnr : -EINVAL; + vtnr = (uint32_t) v; + else if (vtnr != (uint32_t) v) + return -EINVAL; - } else if (s == m->vtconsole) + } else if (!isempty(tty) && seat_is_vtconsole(s)) return -EINVAL; + if (s) { + if (seat_is_vtconsole(s)) { + if (vtnr <= 0 || vtnr > 63) + return -EINVAL; + } else { + if (vtnr > 0) + return -EINVAL; + } + } + if (!dbus_message_iter_next(&iter) || dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) return -EINVAL; |