]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
portablectl: normalize set-limit image paths
authordongshengyuan <545258830@qq.com>
Wed, 15 Jul 2026 08:41:15 +0000 (16:41 +0800)
committerdongshengyuan <545258830@qq.com>
Wed, 15 Jul 2026 10:16:29 +0000 (18:16 +0800)
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: 61d0578b07b97cbffebfd350bac481274e310d39

src/portable/portablectl.c

index 27cc440437c273d62ef1248ceb2849023f615d23..58eb6f37247da6e2959e26af80ab91ecb1ceba34 100644 (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);