From 42e543408b07780a4605c11f037c6e4105e6b438 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Sat, 4 Oct 2025 15:11:05 +0200 Subject: [PATCH] varlinkctl: add detailed error message when `--more` is needed Instead of reporting a "Invalid exchange", tell the user the `--more` flag is missing. Closes: #39201 --- src/varlinkctl/varlinkctl.c | 4 +++- test/units/TEST-74-AUX-UTILS.varlinkctl.sh | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/varlinkctl/varlinkctl.c b/src/varlinkctl/varlinkctl.c index 808ae95348..7768ca5205 100644 --- a/src/varlinkctl/varlinkctl.c +++ b/src/varlinkctl/varlinkctl.c @@ -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); diff --git a/test/units/TEST-74-AUX-UTILS.varlinkctl.sh b/test/units/TEST-74-AUX-UTILS.varlinkctl.sh index 49d0a171e5..b8983adaa2 100755 --- a/test/units/TEST-74-AUX-UTILS.varlinkctl.sh +++ b/test/units/TEST-74-AUX-UTILS.varlinkctl.sh @@ -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}}' )