diff --git a/src/basic/unit-name.h b/src/basic/unit-name.h index 15ce4e24955..1cd33396d8e 100644 --- a/src/basic/unit-name.h +++ b/src/basic/unit-name.h @@ -13,6 +13,7 @@ typedef enum UnitNameFlags { UNIT_NAME_TEMPLATE = 1 << 1, /* Allow foo@.service */ UNIT_NAME_INSTANCE = 1 << 2, /* Allow foo@bar.service */ UNIT_NAME_ANY = UNIT_NAME_PLAIN|UNIT_NAME_TEMPLATE|UNIT_NAME_INSTANCE, + _UNIT_NAME_INVALID = -1, } UnitNameFlags; bool unit_name_is_valid(const char *n, UnitNameFlags flags) _pure_; diff --git a/src/test/test-unit-name.c b/src/test/test-unit-name.c index 5d18711a5ed..6e294c72d62 100644 --- a/src/test/test-unit-name.c +++ b/src/test/test-unit-name.c @@ -78,6 +78,10 @@ static void test_unit_name_is_valid(void) { test_unit_name_is_valid_one("foo@%%i.service", UNIT_NAME_INSTANCE, false); test_unit_name_is_valid_one("foo@%%i%f.service", UNIT_NAME_INSTANCE, false); test_unit_name_is_valid_one("foo@%F.service", UNIT_NAME_INSTANCE, false); + + test_unit_name_is_valid_one("foo.target.wants/plain.service", UNIT_NAME_ANY, false); + test_unit_name_is_valid_one("foo.target.conf/foo.conf", UNIT_NAME_ANY, false); + test_unit_name_is_valid_one("foo.target.requires/plain.socket", UNIT_NAME_ANY, false); } static void test_unit_name_replace_instance_one(const char *pattern, const char *repl, const char *expected, int ret) {