]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
varlinkctl: add detailed error message when `--more` is needed
authorJelle van der Waa <jelle@vdwaa.nl>
Sat, 4 Oct 2025 13:11:05 +0000 (15:11 +0200)
committerMike Yuan <me@yhndnzj.com>
Sun, 5 Oct 2025 20:14:50 +0000 (22:14 +0200)
Instead of reporting a "Invalid exchange", tell the user the `--more`
flag is missing.

Closes: #39201
src/varlinkctl/varlinkctl.c
test/units/TEST-74-AUX-UTILS.varlinkctl.sh

index 808ae95348ce5e61efb004b7ba78ad109098f877..7768ca52058742d65517502312eb37588039d635 100644 (file)
@@ -783,7 +783,9 @@ static int verb_call(int argc, char *argv[], void *userdata) {
                                          "Method call %s() returned expected error: %s", method, error);
 
                                 r = 0;
-                        } else {
+                        } else if (streq(error, SD_VARLINK_ERROR_EXPECTED_MORE))
+                                r = log_error_errno(SYNTHETIC_ERRNO(EBADE), "Method call %s() failed: called without 'more' flag, but flag needs to be set.", method);
+                        else {
                                 r = sd_varlink_error_to_errno(error, reply);
                                 if (r != -EBADR)
                                         log_error_errno(r, "Method call %s() failed: %m", method);
index 49d0a171e500a1e72a1360d4466d0049e4aae804..b8983adaa25f5c0584717129bd781c2ce5a95f93 100755 (executable)
@@ -191,6 +191,7 @@ varlinkctl introspect /run/systemd/io.systemd.Manager io.systemd.Unit
 varlinkctl --more call /run/systemd/io.systemd.Manager io.systemd.Unit.List '{}'
 varlinkctl call /run/systemd/io.systemd.Manager io.systemd.Unit.List '{"name": "multi-user.target"}'
 varlinkctl call /run/systemd/io.systemd.Manager io.systemd.Unit.List '{"pid": {"pid": 0}}'
+(! varlinkctl call /run/systemd/io.systemd.Manager io.systemd.Unit.List '{}' |& grep -q "called without 'more' flag")
 (! varlinkctl call /run/systemd/io.systemd.Manager io.systemd.Unit.List '{"name": ""}')
 (! varlinkctl call /run/systemd/io.systemd.Manager io.systemd.Unit.List '{"name": "non-existent.service"}')
 (! varlinkctl call /run/systemd/io.systemd.Manager io.systemd.Unit.List '{"pid": {"pid": -1}}' )