]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
portable: clarify error when detach fails to match to existing unit
authorLuca Boccassi <bluca@debian.org>
Thu, 24 Mar 2022 14:47:00 +0000 (14:47 +0000)
committerLuca Boccassi <luca.boccassi@gmail.com>
Sat, 26 Mar 2022 11:20:39 +0000 (11:20 +0000)
Clarify that it's looking at attached units, not at units inside the referenced
image. Also take into account extensions.

src/portable/portable.c

index 691aad5238d609d0c566f64743aeadf40182b2d2..3051760d0b992e8e24fce7fd52a8c37cb1a393ed 100644 (file)
@@ -1520,6 +1520,7 @@ int portable_detach(
 
         _cleanup_(lookup_paths_free) LookupPaths paths = {};
         _cleanup_set_free_ Set *unit_files = NULL, *markers = NULL;
+        _cleanup_free_ char *extensions = NULL;
         _cleanup_closedir_ DIR *d = NULL;
         const char *where, *item;
         int ret = 0;
@@ -1674,8 +1675,17 @@ int portable_detach(
         return ret;
 
 not_found:
-        log_debug("No unit files associated with '%s' found. Image not attached?", name_or_path);
-        return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT, "No unit files associated with '%s' found. Image not attached?", name_or_path);
+        extensions = strv_join(extension_image_paths, ", ");
+        if (!extensions)
+                return -ENOMEM;
+
+        r = sd_bus_error_setf(error,
+                              BUS_ERROR_NO_SUCH_UNIT,
+                              "No unit files associated with '%s%s%s' found attached to the system. Image not attached?",
+                              name_or_path,
+                              isempty(extensions) ? "" : "' or any of its extensions '",
+                              isempty(extensions) ? "" : extensions);
+        return log_debug_errno(r, "%s", error->message);
 }
 
 static int portable_get_state_internal(