summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2021-08-03 18:07:50 +0200
committerThomas Haller <thaller@redhat.com>2021-08-04 09:41:09 +0200
commitdbd459ec9253fe97441e7c54b136c929074c4762 (patch)
tree58ae3095ac02382c3102710c18b94051d6f315a4
parent1e71a0081719d9cb6fe35e681489239c714a151f (diff)
downloadNetworkManager-dbd459ec9253fe97441e7c54b136c929074c4762.tar.gz
nm-sudo: expect unknown interface in _bus_method_call()
GDBus will invoke the method_call callback also for the Get/Set functions. Thus, we need to check the interface_name and handle them (actually, there is nothing to handle, no properties exist). Also, "Ping" method only exists for testing. It is usually not called in production, so check for "GetFD" first.
-rw-r--r--src/nm-sudo/nm-sudo.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/nm-sudo/nm-sudo.c b/src/nm-sudo/nm-sudo.c
index c199d8994b..d8cf42f3c8 100644
--- a/src/nm-sudo/nm-sudo.c
+++ b/src/nm-sudo/nm-sudo.c
@@ -290,14 +290,26 @@ _bus_method_call(GDBusConnection * connection,
method_name,
g_variant_get_type_string(parameters));
+ if (!nm_streq(interface_name, NM_SUDO_DBUS_IFACE_NAME))
+ goto out_unknown_method;
+
+ if (nm_streq(method_name, "GetFD")) {
+ g_variant_get(parameters, "(u)", &arg_u);
+ _handle_get_fd(gl, invocation, arg_u);
+ return;
+ }
if (nm_streq(method_name, "Ping")) {
g_variant_get(parameters, "(&s)", &arg_s);
_handle_ping(gl, invocation, arg_s);
- } else if (nm_streq(method_name, "GetFD")) {
- g_variant_get(parameters, "(u)", &arg_u);
- _handle_get_fd(gl, invocation, arg_u);
- } else
- nm_assert_not_reached();
+ return;
+ }
+
+out_unknown_method:
+ g_dbus_method_invocation_return_error(invocation,
+ G_DBUS_ERROR,
+ G_DBUS_ERROR_UNKNOWN_METHOD,
+ "Unknown method %s",
+ method_name);
}
static GDBusInterfaceInfo *const interface_info = NM_DEFINE_GDBUS_INTERFACE_INFO(