X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fcore%2Fdbus-cgroup.c;h=775825bee912edd6bef66b878c1e52e907313b85;hp=413ace403084f3814a962a3ca06baf3d3696273a;hb=01efdf13a6ee9a14fd6d8b41a5d522d5917e1fbc;hpb=556089dc57b10a12a03edd3d3e90ca17398ad206 diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c index 413ace403..775825bee 100644 --- a/src/core/dbus-cgroup.c +++ b/src/core/dbus-cgroup.c @@ -135,17 +135,17 @@ static int property_get_device_allow( const sd_bus_vtable bus_cgroup_vtable[] = { SD_BUS_VTABLE_START(0), - SD_BUS_PROPERTY("CPUAccounting", "b", bus_property_get_bool, offsetof(CGroupContext, cpu_accounting), SD_BUS_VTABLE_PROPERTY_CONST), - SD_BUS_PROPERTY("CPUShares", "t", bus_property_get_ulong, offsetof(CGroupContext, cpu_shares), SD_BUS_VTABLE_PROPERTY_CONST), - SD_BUS_PROPERTY("BlockIOAccounting", "b", bus_property_get_bool, offsetof(CGroupContext, blockio_accounting), SD_BUS_VTABLE_PROPERTY_CONST), - SD_BUS_PROPERTY("BlockIOWeight", "t", bus_property_get_ulong, offsetof(CGroupContext, blockio_weight), SD_BUS_VTABLE_PROPERTY_CONST), - SD_BUS_PROPERTY("BlockIODeviceWeight", "a(st)", property_get_blockio_device_weight, 0, SD_BUS_VTABLE_PROPERTY_CONST), - SD_BUS_PROPERTY("BlockIOReadBandwidth", "a(st)", property_get_blockio_device_bandwidths, 0, SD_BUS_VTABLE_PROPERTY_CONST), - SD_BUS_PROPERTY("BlockIOWriteBandwidth", "a(st)", property_get_blockio_device_bandwidths, 0, SD_BUS_VTABLE_PROPERTY_CONST), - SD_BUS_PROPERTY("MemoryAccounting", "b", bus_property_get_bool, offsetof(CGroupContext, memory_accounting), SD_BUS_VTABLE_PROPERTY_CONST), - SD_BUS_PROPERTY("MemoryLimit", "t", NULL, offsetof(CGroupContext, memory_limit), SD_BUS_VTABLE_PROPERTY_CONST), - SD_BUS_PROPERTY("DevicePolicy", "s", property_get_cgroup_device_policy, offsetof(CGroupContext, device_policy), SD_BUS_VTABLE_PROPERTY_CONST), - SD_BUS_PROPERTY("DeviceAllow", "a(ss)", property_get_device_allow, 0, SD_BUS_VTABLE_PROPERTY_CONST), + SD_BUS_PROPERTY("CPUAccounting", "b", bus_property_get_bool, offsetof(CGroupContext, cpu_accounting), 0), + SD_BUS_PROPERTY("CPUShares", "t", bus_property_get_ulong, offsetof(CGroupContext, cpu_shares), 0), + SD_BUS_PROPERTY("BlockIOAccounting", "b", bus_property_get_bool, offsetof(CGroupContext, blockio_accounting), 0), + SD_BUS_PROPERTY("BlockIOWeight", "t", bus_property_get_ulong, offsetof(CGroupContext, blockio_weight), 0), + SD_BUS_PROPERTY("BlockIODeviceWeight", "a(st)", property_get_blockio_device_weight, 0, 0), + SD_BUS_PROPERTY("BlockIOReadBandwidth", "a(st)", property_get_blockio_device_bandwidths, 0, 0), + SD_BUS_PROPERTY("BlockIOWriteBandwidth", "a(st)", property_get_blockio_device_bandwidths, 0, 0), + SD_BUS_PROPERTY("MemoryAccounting", "b", bus_property_get_bool, offsetof(CGroupContext, memory_accounting), 0), + SD_BUS_PROPERTY("MemoryLimit", "t", NULL, offsetof(CGroupContext, memory_limit), 0), + SD_BUS_PROPERTY("DevicePolicy", "s", property_get_cgroup_device_policy, offsetof(CGroupContext, device_policy), 0), + SD_BUS_PROPERTY("DeviceAllow", "a(ss)", property_get_device_allow, 0, 0), SD_BUS_VTABLE_END }; @@ -278,6 +278,10 @@ int bus_cgroup_set_property( if (r < 0) return r; + r = sd_bus_message_exit_container(message); + if (r < 0) + return r; + if (mode != UNIT_CHECK) { CGroupBlockIODeviceBandwidth *a, *next; _cleanup_free_ char *buf = NULL; @@ -321,10 +325,9 @@ int bus_cgroup_set_property( if (r < 0) return r; - while (( r = sd_bus_message_read(message, "(st)", &path, &u64)) > 0) { - unsigned long ul; + while ((r = sd_bus_message_read(message, "(st)", &path, &u64)) > 0) { + unsigned long ul = u64; - ul = (unsigned long) u64; if (ul < 10 || ul > 1000) return sd_bus_error_set_errnof(error, EINVAL, "BlockIODeviceWeight out of range"); @@ -357,6 +360,10 @@ int bus_cgroup_set_property( n++; } + r = sd_bus_message_exit_container(message); + if (r < 0) + return r; + if (mode != UNIT_CHECK) { _cleanup_free_ char *buf = NULL; _cleanup_fclose_ FILE *f = NULL; @@ -443,8 +450,11 @@ int bus_cgroup_set_property( while ((r = sd_bus_message_read(message, "(ss)", &path, &rwm)) > 0) { - if (!path_startswith(path, "/dev")) - return sd_bus_error_set_errnof(error, EINVAL, "DeviceAllow= requires device node"); + if ((!startswith(path, "/dev/") && + !startswith(path, "block-") && + !startswith(path, "char-")) || + strpbrk(path, WHITESPACE)) + return sd_bus_error_set_errnof(error, EINVAL, "DeviceAllow= requires device node"); if (isempty(rwm)) rwm = "rwm"; @@ -479,11 +489,16 @@ int bus_cgroup_set_property( a->r = !!strchr(rwm, 'r'); a->w = !!strchr(rwm, 'w'); a->m = !!strchr(rwm, 'm'); - } n++; } + if (r < 0) + return r; + + r = sd_bus_message_exit_container(message); + if (r < 0) + return r; if (mode != UNIT_CHECK) { _cleanup_free_ char *buf = NULL;