From: dongshengyuan <545258830@qq.com> Date: Wed, 15 Jul 2026 08:36:02 +0000 (+0800) Subject: portablectl: normalize read-only image paths X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=57c64f7c6947462eba54cd0dab97d8476f8a25de;p=thirdparty%2Fsystemd.git portablectl: normalize read-only image paths Run read-only image arguments through determine_image() before sending them over D-Bus. This gives relative paths the same normalized form as other portablectl image operations. Reproducer: cd /tmp portablectl read-only ./portable-repro true Before: ./portable-repro was sent unchanged to portabled and rejected as an invalid image name/path. The same image worked when passed as an absolute path, so relative paths behaved inconsistently. Follow-up: 61d0578b07b97cbffebfd350bac481274e310d39 --- diff --git a/src/portable/portablectl.c b/src/portable/portablectl.c index 1c479f1134a..641fc1365fc 100644 --- a/src/portable/portablectl.c +++ b/src/portable/portablectl.c @@ -1399,6 +1399,7 @@ VERB(verb_read_only_image, "read-only", "NAME|PATH [BOOL]", 2, 3, 0, static int verb_read_only_image(int argc, char *argv[], uintptr_t _data, void *userdata) { _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL; + _cleanup_free_ char *image = NULL; int b = true, r; if (argc > 2) { @@ -1407,13 +1408,17 @@ static int verb_read_only_image(int argc, char *argv[], uintptr_t _data, void *u return log_error_errno(b, "Failed to parse boolean argument: %s", argv[2]); } + r = determine_image(argv[1], false, &image); + if (r < 0) + return r; + r = acquire_bus(&bus); if (r < 0) return r; (void) polkit_agent_open_if_enabled(arg_transport, arg_ask_password); - r = bus_call_method(bus, bus_portable_mgr, "MarkImageReadOnly", &error, NULL, "sb", argv[1], b); + r = bus_call_method(bus, bus_portable_mgr, "MarkImageReadOnly", &error, NULL, "sb", image, b); if (r < 0) return log_error_errno(r, "Could not mark image read-only: %s", bus_error_message(&error, r));