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.
This commit is contained in:
Thomas Haller 2021-08-03 18:07:50 +02:00
parent 1e71a00817
commit dbd459ec92
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -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(