anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

Blame SOURCES/0298-core-improve-error-message-when-starting-template-wi.patch

803fb7
From 9b33863a2cfa31bbe57bab685776b64731f528f1 Mon Sep 17 00:00:00 2001
803fb7
From: Lukas Nykryn <lnykryn@redhat.com>
803fb7
Date: Wed, 30 Mar 2016 13:49:50 +0200
803fb7
Subject: [PATCH] core: improve error message when starting template without
803fb7
 instance
803fb7
803fb7
Cherry-picked from: 5d512d54429aa9d2f4a0ca215bb2e982db720d6b
803fb7
Resolves: #1142369
803fb7
---
803fb7
 src/core/manager.c | 6 +++++-
803fb7
 1 file changed, 5 insertions(+), 1 deletion(-)
803fb7
803fb7
diff --git a/src/core/manager.c b/src/core/manager.c
803fb7
index bde17ce0b..bb5050303 100644
803fb7
--- a/src/core/manager.c
803fb7
+++ b/src/core/manager.c
803fb7
@@ -1328,8 +1328,12 @@ int manager_load_unit_prepare(
803fb7
 
803fb7
         t = unit_name_to_type(name);
803fb7
 
803fb7
-        if (t == _UNIT_TYPE_INVALID || !unit_name_is_valid(name, UNIT_NAME_PLAIN|UNIT_NAME_INSTANCE))
803fb7
+        if (t == _UNIT_TYPE_INVALID || !unit_name_is_valid(name, UNIT_NAME_PLAIN|UNIT_NAME_INSTANCE)) {
803fb7
+                if (unit_name_is_valid(name, UNIT_NAME_TEMPLATE))
803fb7
+                        return sd_bus_error_setf(e, SD_BUS_ERROR_INVALID_ARGS, "Unit name %s is missing the instance name.", name);
803fb7
+
803fb7
                 return sd_bus_error_setf(e, SD_BUS_ERROR_INVALID_ARGS, "Unit name %s is not valid.", name);
803fb7
+        }
803fb7
 
803fb7
         ret = manager_get_unit(m, name);
803fb7
         if (ret) {