portablectl: normalize set-limit image paths

Normalize the image argument for per-image SetImageLimit requests while
leaving the single-argument pool limit mode unchanged. This aligns quota
handling with other path-taking verbs.

Reproducer:
  cd /tmp
  portablectl set-limit ./portable-repro 1G

Before:
  ./portable-repro was sent unchanged to portabled and rejected as an
  invalid image name/path. Per-image quota changes worked for absolute
  paths but not for equivalent relative paths.

Follow-up: 61d0578b07
This commit is contained in:
dongshengyuan
2026-07-15 18:16:29 +08:00
parent 018c2b229f
commit f21e820631
+8 -3
View File
@@ -1468,6 +1468,7 @@ VERB(verb_set_limit, "set-limit", "[NAME|PATH] LIMIT", 2, 3, 0,
static int verb_set_limit(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;
uint64_t limit;
int r;
@@ -1485,10 +1486,14 @@ static int verb_set_limit(int argc, char *argv[], uintptr_t _data, void *userdat
return log_error_errno(r, "Failed to parse size: %s", argv[argc-1]);
}
if (argc > 2)
if (argc > 2) {
/* With two arguments changes the quota limit of the specified image */
r = bus_call_method(bus, bus_portable_mgr, "SetImageLimit", &error, NULL, "st", argv[1], limit);
else
r = determine_image(argv[1], false, &image);
if (r < 0)
return r;
r = bus_call_method(bus, bus_portable_mgr, "SetImageLimit", &error, NULL, "st", image, limit);
} else
/* With one argument changes the pool quota limit */
r = bus_call_method(bus, bus_portable_mgr, "SetPoolLimit", &error, NULL, "t", limit);