]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/core/snapshot.c
core: rework unit name validation and manipulation logic
[thirdparty/systemd.git] / src / core / snapshot.c
index b70c3beb6023c1b75455c636bbaf8d8d9a0c0dc1..2c00680f1683bb7a1dbf0b1b4b235dae0e7d8c9d 100644 (file)
@@ -201,10 +201,10 @@ int snapshot_create(Manager *m, const char *name, bool cleanup, sd_bus_error *e,
         assert(_s);
 
         if (name) {
-                if (!unit_name_is_valid(name, TEMPLATE_INVALID))
+                if (!unit_name_is_valid(name, UNIT_NAME_PLAIN))
                         return sd_bus_error_setf(e, SD_BUS_ERROR_INVALID_ARGS, "Unit name %s is not valid.", name);
 
-                if (unit_name_to_type(name) != UNIT_SNAPSHOT)
+                if (!endswith(name, ".snapshot"))
                         return sd_bus_error_setf(e, SD_BUS_ERROR_INVALID_ARGS, "Unit name %s lacks snapshot suffix.", name);
 
                 if (manager_get_unit(m, name))