diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-04-22 02:56:42 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-04-22 02:56:42 +0200 |
commit | 4f0f902fc8837999e5c9f3a6f7e2592cc6f096eb (patch) | |
tree | 5c752a0e2776784686d57376d48b426bc9952e54 /dbus-manager.c | |
parent | c497c7a9e4db487eab4f92421a74d721d9558186 (diff) |
manager: enforce limit on accepted number of names
Diffstat (limited to 'dbus-manager.c')
-rw-r--r-- | dbus-manager.c | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/dbus-manager.c b/dbus-manager.c index 9263248111..47fb403f11 100644 --- a/dbus-manager.c +++ b/dbus-manager.c @@ -78,8 +78,10 @@ " <property name=\"Version\" type=\"s\" access=\"read\"/>" \ " <property name=\"RunningAs\" type=\"s\" access=\"read\"/>" \ " <property name=\"BootTimestamp\" type=\"t\" access=\"read\"/>" \ - " <property name=\"LogLevel\" type=\"s\" access=\"readwrite\"/>" \ - " <property name=\"LogTarget\" type=\"s\" access=\"readwrite\"/>" \ + " <property name=\"LogLevel\" type=\"s\" access=\"read\"/>" \ + " <property name=\"LogTarget\" type=\"s\" access=\"read\"/>" \ + " <property name=\"NNames\" type=\"u\" access=\"read\"/>" \ + " <property name=\"NJobs\" type=\"u\" access=\"read\"/>" \ " </interface>" \ BUS_PROPERTIES_INTERFACE \ BUS_INTROSPECTABLE_INTERFACE @@ -119,6 +121,36 @@ static int bus_manager_append_log_level(Manager *m, DBusMessageIter *i, const ch return 0; } +static int bus_manager_append_n_names(Manager *m, DBusMessageIter *i, const char *property, void *data) { + uint32_t u; + + assert(m); + assert(i); + assert(property); + + u = hashmap_size(m->units); + + if (!dbus_message_iter_append_basic(i, DBUS_TYPE_UINT32, &u)) + return -ENOMEM; + + return 0; +} + +static int bus_manager_append_n_jobs(Manager *m, DBusMessageIter *i, const char *property, void *data) { + uint32_t u; + + assert(m); + assert(i); + assert(property); + + u = hashmap_size(m->jobs); + + if (!dbus_message_iter_append_basic(i, DBUS_TYPE_UINT32, &u)) + return -ENOMEM; + + return 0; +} + static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, DBusMessage *message, void *data) { Manager *m = data; @@ -128,6 +160,8 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection { "org.freedesktop.systemd1.Manager", "BootTimestamp", bus_property_append_uint64, "t", &m->boot_timestamp }, { "org.freedesktop.systemd1.Manager", "LogLevel", bus_manager_append_log_level, "s", NULL }, { "org.freedesktop.systemd1.Manager", "LogTarget", bus_manager_append_log_target, "s", NULL }, + { "org.freedesktop.systemd1.Manager", "NNames", bus_manager_append_n_names, "u", NULL }, + { "org.freedesktop.systemd1.Manager", "NJobs", bus_manager_append_n_jobs, "u", NULL }, { NULL, NULL, NULL, NULL, NULL } }; |