From: Luca Boccassi Date: Thu, 9 Nov 2023 20:22:26 +0000 (+0000) Subject: portablectl: fix detaching when an extension image has been deleted X-Git-Tag: v255-rc2~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ba8eda568c760cc1b4eb9edcfd1b29818619ce70;p=thirdparty%2Fsystemd.git portablectl: fix detaching when an extension image has been deleted --- diff --git a/src/portable/portablectl.c b/src/portable/portablectl.c index 6f804e65ee5..532e8d93455 100644 --- a/src/portable/portablectl.c +++ b/src/portable/portablectl.c @@ -108,7 +108,10 @@ static int attach_extensions_to_message(sd_bus_message *m, const char *method, c STRV_FOREACH(p, extensions) { _cleanup_free_ char *resolved_extension_image = NULL; - r = determine_image(*p, false, &resolved_extension_image); + r = determine_image( + *p, + startswith_strv(method, STRV_MAKE("Get", "Detach")), + &resolved_extension_image); if (r < 0) return r; diff --git a/test/units/testsuite-29.sh b/test/units/testsuite-29.sh index 66256a40c8d..536827311b9 100755 --- a/test/units/testsuite-29.sh +++ b/test/units/testsuite-29.sh @@ -186,7 +186,11 @@ status="$(portablectl is-attached --extension /tmp/app10.raw /usr/share/minimal_ portablectl inspect --force --cat --extension /tmp/app10.raw /usr/share/minimal_0.raw app0 | grep -q -F "Extension Release: /tmp/app10.raw" -portablectl detach --force --now --runtime --extension /tmp/app10.raw /usr/share/minimal_0.raw app0 +# Ensure that we can detach even when an image has been deleted already (stop the unit manually as +# portablectl won't find it) +rm -f /tmp/app10.raw +systemctl stop app0.service +portablectl detach --force --runtime --extension /tmp/app10.raw /usr/share/minimal_0.raw app0 # portablectl also accepts confexts portablectl "${ARGS[@]}" attach --now --runtime --extension /usr/share/app0.raw --extension /usr/share/conf0.raw /usr/share/minimal_0.raw app0