diff options
author | Lennart Poettering <lennart@poettering.net> | 2024-08-23 10:41:44 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-08-23 16:10:58 +0200 |
commit | a3f17a8f88f7332d0bef67a2d523c41f23f164b6 (patch) | |
tree | 77128b99d39d907d17a4fba090da75f788439822 /src/varlinkctl | |
parent | updatectl: fix typo and drop space in empty lines (diff) | |
download | systemd-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.c | 7 |
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]>"; |