chiark / gitweb /
systemctl: fix 'systemctl enable getty@.service'
[elogind.git] / src / unit-name.c
index 0e86b554c2eee4382c742fdd2f107b2e8ce01aed..cd6e3cea5c5398fd9572c9301130e0ea00504bd3 100644 (file)
@@ -32,7 +32,7 @@
         "ABCDEFGHIJKLMNOPQRSTUVWXYZ"            \
         ":-_.\\"
 
-bool unit_name_is_valid_no_type(const char *n) {
+bool unit_name_is_valid_no_type(const char *n, bool template_ok) {
         const char *e, *i, *at;
 
         /* Valid formats:
@@ -63,7 +63,7 @@ bool unit_name_is_valid_no_type(const char *n) {
                 if (at == n)
                         return false;
 
-                if (at[1] == '.')
+                if (!template_ok && at+1 == e)
                         return false;
         }
 
@@ -150,7 +150,7 @@ char *unit_name_change_suffix(const char *n, const char *suffix) {
         size_t a, b;
 
         assert(n);
-        assert(unit_name_is_valid_no_type(n));
+        assert(unit_name_is_valid_no_type(n, true));
         assert(suffix);
 
         assert_se(e = strrchr(n, '.'));