X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Flogin%2Flogind-user-dbus.c;h=ddf9d9d5cfcb46ead1ddba81b551e4e6da86005e;hp=3673a28bd4ceb6c7eeb64427b731536d8f32422b;hb=409133be63387fc04d927e8aecd2f6ba03d2f143;hpb=4bba9156da3e1df2cee24d10d7cd88c776ef4179 diff --git a/src/login/logind-user-dbus.c b/src/login/logind-user-dbus.c index 3673a28bd..ddf9d9d5c 100644 --- a/src/login/logind-user-dbus.c +++ b/src/login/logind-user-dbus.c @@ -6,16 +6,16 @@ Copyright 2011 Lennart Poettering systemd is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. systemd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License + You should have received a copy of the GNU Lesser General Public License along with systemd; If not, see . ***/ @@ -38,7 +38,7 @@ " \n" \ " \n" \ " \n" \ - " \n" \ + " \n" \ " \n" \ " \n" \ " \n" \ @@ -189,6 +189,26 @@ static int bus_user_append_idle_hint_since(DBusMessageIter *i, const char *prope return 0; } +static int bus_user_append_default_cgroup(DBusMessageIter *i, const char *property, void *data) { + User *u = data; + char *t; + int r; + bool success; + + assert(i); + assert(property); + assert(u); + + r = cg_join_spec(SYSTEMD_CGROUP_CONTROLLER, u->cgroup_path, &t); + if (r < 0) + return r; + + success = dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &t); + free(t); + + return success ? 0 : -ENOMEM; +} + static int get_user_for_path(Manager *m, const char *path, User **_u) { User *u; unsigned long lu; @@ -213,29 +233,29 @@ static int get_user_for_path(Manager *m, const char *path, User **_u) { return 0; } +static const BusProperty bus_login_user_properties[] = { + { "UID", bus_property_append_uid, "u", offsetof(User, uid) }, + { "GID", bus_property_append_gid, "u", offsetof(User, gid) }, + { "Name", bus_property_append_string, "s", offsetof(User, name), true }, + { "Timestamp", bus_property_append_usec, "t", offsetof(User, timestamp.realtime) }, + { "TimestampMonotonic", bus_property_append_usec, "t", offsetof(User, timestamp.monotonic) }, + { "RuntimePath", bus_property_append_string, "s", offsetof(User, runtime_path), true }, + { "DefaultControlGroup", bus_user_append_default_cgroup, "s", 0 }, + { "Service", bus_property_append_string, "s", offsetof(User, service), true }, + { "Display", bus_user_append_display, "(so)", 0 }, + { "State", bus_user_append_state, "s", 0 }, + { "Sessions", bus_user_append_sessions, "a(so)", 0 }, + { "IdleHint", bus_user_append_idle_hint, "b", 0 }, + { "IdleSinceHint", bus_user_append_idle_hint_since, "t", 0 }, + { "IdleSinceHintMonotonic", bus_user_append_idle_hint_since, "t", 0 }, + { NULL, } +}; + static DBusHandlerResult user_message_dispatch( User *u, DBusConnection *connection, DBusMessage *message) { - const BusProperty properties[] = { - { "org.freedesktop.login1.User", "UID", bus_property_append_uid, "u", &u->uid }, - { "org.freedesktop.login1.User", "GID", bus_property_append_gid, "u", &u->gid }, - { "org.freedesktop.login1.User", "Name", bus_property_append_string, "s", u->name }, - { "org.freedesktop.login1.User", "Timestamp", bus_property_append_usec, "t", &u->timestamp.realtime }, - { "org.freedesktop.login1.User", "TimestampMonotonic", bus_property_append_usec, "t", &u->timestamp.monotonic }, - { "org.freedesktop.login1.User", "RuntimePath", bus_property_append_string, "s", u->runtime_path }, - { "org.freedesktop.login1.User", "ControlGroupPath", bus_property_append_string, "s", u->cgroup_path }, - { "org.freedesktop.login1.User", "Service", bus_property_append_string, "s", u->service }, - { "org.freedesktop.login1.User", "Display", bus_user_append_display, "(so)", u }, - { "org.freedesktop.login1.User", "State", bus_user_append_state, "s", u }, - { "org.freedesktop.login1.User", "Sessions", bus_user_append_sessions, "a(so)", u }, - { "org.freedesktop.login1.User", "IdleHint", bus_user_append_idle_hint, "b", u }, - { "org.freedesktop.login1.User", "IdleSinceHint", bus_user_append_idle_hint_since, "t", u }, - { "org.freedesktop.login1.User", "IdleSinceHintMonotonic", bus_user_append_idle_hint_since, "t", u }, - { NULL, NULL, NULL, NULL, NULL } - }; - DBusError error; DBusMessage *reply = NULL; int r; @@ -274,8 +294,14 @@ static DBusHandlerResult user_message_dispatch( if (!reply) goto oom; - } else - return bus_default_message_handler(connection, message, INTROSPECTION, INTERFACES_LIST, properties); + } else { + const BusBoundProperties bps[] = { + { "org.freedesktop.login1.User", bus_login_user_properties, u }, + { NULL, } + }; + + return bus_default_message_handler(connection, message, INTROSPECTION, INTERFACES_LIST, bps); + } if (reply) { if (!dbus_connection_send(connection, reply, NULL))