From: Lennart Poettering Date: Fri, 23 Aug 2024 08:41:44 +0000 (+0200) Subject: varlinkctl: output an expressive error message in case invalid method/interface names... X-Git-Tag: v257-rc1~637 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a3f17a8f88f7332d0bef67a2d523c41f23f164b6;p=thirdparty%2Fsystemd.git varlinkctl: output an expressive error message in case invalid method/interface names are specified 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. --- 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 = "";