From a3f17a8f88f7332d0bef67a2d523c41f23f164b6 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 23 Aug 2024 10:41:44 +0200 Subject: [PATCH] varlinkctl: output an expressive error message in case invalid method/interface names are specified MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Inspired by #34098 → let's make it easier for users to understand and correct the mistakes they made: let's early refuse invalid interface/method names. --- src/varlinkctl/varlinkctl.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/varlinkctl/varlinkctl.c b/src/varlinkctl/varlinkctl.c index 77cecdbf4e9..e99ea349641 100644 --- a/src/varlinkctl/varlinkctl.c +++ b/src/varlinkctl/varlinkctl.c @@ -334,6 +334,10 @@ static int verb_introspect(int argc, char *argv[], void *userdata) { url = argv[1]; interfaces = strv_skip(argv, 2); + STRV_FOREACH(i, interfaces) + if (!varlink_idl_interface_name_is_valid(*i)) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Not a valid Varlink interface name: '%s'", *i); + r = varlink_connect_auto(&vl, url); if (r < 0) return r; @@ -498,6 +502,9 @@ static int verb_call(int argc, char *argv[], void *userdata) { * leave incomplete lines hanging around. */ arg_json_format_flags |= SD_JSON_FORMAT_NEWLINE; + if (!varlink_idl_qualified_symbol_name_is_valid(method)) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Not a valid qualified method name: '%s' (Expected valid Varlink interface name, followed by a dot, followed by a valid Varlink symbol name.)", method); + if (parameter) { source = ""; -- 2.47.3