From 7410616cd9dbbec97cf98d75324da5cda2b2f7a2 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 30 Apr 2015 20:21:00 +0200 Subject: core: rework unit name validation and manipulation logic A variety of changes: - Make sure all our calls distuingish OOM from other errors if OOM is not the only error possible. - Be much stricter when parsing escaped paths, do not accept trailing or leading escaped slashes. - Change unit validation to take a bit mask for allowing plain names, instance names or template names or an combination thereof. - Refuse manipulating invalid unit name --- src/core/dbus-unit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core/dbus-unit.c') diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c index 2699e81492..056c7117b2 100644 --- a/src/core/dbus-unit.c +++ b/src/core/dbus-unit.c @@ -940,7 +940,7 @@ static int bus_unit_set_transient_property( if (r < 0) return r; - if (!unit_name_is_valid(s, TEMPLATE_INVALID) || !endswith(s, ".slice")) + if (!unit_name_is_valid(s, UNIT_NAME_PLAIN) || !endswith(s, ".slice")) return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid slice name %s", s); if (isempty(s)) { @@ -988,7 +988,7 @@ static int bus_unit_set_transient_property( return r; while ((r = sd_bus_message_read(message, "s", &other)) > 0) { - if (!unit_name_is_valid(other, TEMPLATE_INVALID)) + if (!unit_name_is_valid(other, UNIT_NAME_PLAIN|UNIT_NAME_INSTANCE)) return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid unit name %s", other); if (mode != UNIT_CHECK) { -- cgit v1.2.3-54-g00ecf