From: dongshengyuan <545258830@qq.com> Date: Wed, 15 Jul 2026 08:39:16 +0000 (+0800) Subject: portablectl: normalize remove image paths X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=018c2b229f956daf8549e0cdfadffe8336746319;p=thirdparty%2Fsystemd.git portablectl: normalize remove image paths Normalize each remove argument with determine_image() before building the RemoveImage request. Relative paths are converted before reaching portabled. Reproducer: cd /tmp portablectl remove ./portable-repro Before: ./portable-repro was sent unchanged to portabled and rejected as an invalid image name/path. Removing an image by a relative path failed even though the path referred to a valid local image. Follow-up: 61d0578b07b97cbffebfd350bac481274e310d39 --- diff --git a/src/portable/portablectl.c b/src/portable/portablectl.c index 641fc1365fc..27cc440437c 100644 --- a/src/portable/portablectl.c +++ b/src/portable/portablectl.c @@ -1440,12 +1440,17 @@ static int verb_remove_image(int argc, char *argv[], uintptr_t _data, void *user for (i = 1; i < argc; i++) { _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; + _cleanup_free_ char *image = NULL; + + r = determine_image(argv[i], false, &image); + if (r < 0) + return r; r = bus_message_new_method_call(bus, &m, bus_portable_mgr, "RemoveImage"); if (r < 0) return bus_log_create_error(r); - r = sd_bus_message_append(m, "s", argv[i]); + r = sd_bus_message_append(m, "s", image); if (r < 0) return bus_log_create_error(r); diff --git a/test/units/TEST-29-PORTABLE.directory.sh b/test/units/TEST-29-PORTABLE.directory.sh index 1cedeea72b1..a1951ee6e1f 100755 --- a/test/units/TEST-29-PORTABLE.directory.sh +++ b/test/units/TEST-29-PORTABLE.directory.sh @@ -24,6 +24,11 @@ rm -rf /tmp/mismatched-name cp -a /tmp/minimal_0 /tmp/mismatched-name portablectl inspect /tmp/mismatched-name | grep -F "minimal-app0.service" >/dev/null +rm -rf /tmp/remove-relative +cp -a /tmp/minimal_0 /tmp/remove-relative +(cd /tmp && portablectl remove ./remove-relative) +test ! -e /tmp/remove-relative + rm -rf /tmp/symlink-unit cp -a /tmp/minimal_0 /tmp/symlink-unit printf '[Service]\nExecStart=/bin/true\n' >/tmp/portable-host-unit