diff --git a/src/portable/portable.c b/src/portable/portable.c index c1abe16985..2b398ec075 100644 --- a/src/portable/portable.c +++ b/src/portable/portable.c @@ -2164,7 +2164,7 @@ int portable_attach( return 0; } -static bool marker_matches_images(const char *marker, const char *name_or_path, char **extension_image_paths, bool match_all) { +static int marker_matches_images(const char *marker, const char *name_or_path, char **extension_image_paths, bool match_all) { _cleanup_strv_free_ char **root_and_extensions = NULL; int r; @@ -2190,7 +2190,7 @@ static bool marker_matches_images(const char *marker, const char *name_or_path, /* Ensure the number of images passed matches the number of images listed in the marker */ while (!isempty(marker)) STRV_FOREACH(image_name_or_path, root_and_extensions) { - _cleanup_free_ char *image = NULL, *base_image = NULL, *base_image_name_or_path = NULL; + _cleanup_free_ char *image = NULL, *base_image = NULL, *base_image_name_or_path = NULL, *base_picked_image = NULL; _cleanup_(pick_result_done) PickResult result = PICK_RESULT_NULL; r = extract_first_word(&marker, &image, ":", EXTRACT_UNQUOTE|EXTRACT_RETAIN_ESCAPE); @@ -2211,19 +2211,21 @@ static bool marker_matches_images(const char *marker, const char *name_or_path, ELEMENTSOF(pick_filter_image_any), PICK_ARCHITECTURE|PICK_TRIES|PICK_RESOLVE, &result); - if (r < 0) + if (r < 0 && r != -ENOENT) return r; - if (!result.path) - return log_debug_errno( - SYNTHETIC_ERRNO(ENOENT), - "No matching entry in .v/ directory %s found.", - *image_name_or_path); - r = path_extract_image_name(result.path, &base_image_name_or_path); + r = path_extract_image_name(*image_name_or_path, &base_image_name_or_path); if (r < 0) - return log_debug_errno(r, "Failed to extract image name from %s, ignoring: %m", result.path); + return log_debug_errno(r, "Failed to extract image name from %s, ignoring: %m", *image_name_or_path); - if (!streq(base_image, base_image_name_or_path)) { + if (!streq(base_image, base_image_name_or_path) && result.path) { + r = path_extract_image_name(result.path, &base_picked_image); + if (r < 0) + return log_debug_errno(r, "Failed to extract image name from %s, ignoring: %m", result.path); + } + + if (!streq(base_image, base_image_name_or_path) && + !streq_ptr(base_image, base_picked_image)) { if (match_all) return false; } else if (!match_all)