summaryrefslogtreecommitdiffstats
path: root/src/varlinkctl
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2024-08-23 10:41:44 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2024-08-23 16:10:58 +0200
commita3f17a8f88f7332d0bef67a2d523c41f23f164b6 (patch)
tree77128b99d39d907d17a4fba090da75f788439822 /src/varlinkctl
parentupdatectl: fix typo and drop space in empty lines (diff)
downloadsystemd-a3f17a8f88f7332d0bef67a2d523c41f23f164b6.tar.xz
systemd-a3f17a8f88f7332d0bef67a2d523c41f23f164b6.zip
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.
Diffstat (limited to 'src/varlinkctl')
-rw-r--r--src/varlinkctl/varlinkctl.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/varlinkctl/varlinkctl.c b/src/varlinkctl/varlinkctl.c
index 77cecdbf4e..e99ea34964 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 = "<argv[4]>";