diff options
author | Thomas Haller <thaller@redhat.com> | 2020-04-06 13:57:47 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-04-10 10:44:53 +0200 |
commit | b0759e9662fa94dd7bc0420117b82760e3878527 (patch) | |
tree | 66ecf8a7d1498851ce4177e187f85b1ce98c673f | |
parent | 0dbb9c279e84272a1d1ce1d957306d22cece89c6 (diff) | |
download | NetworkManager-b0759e9662fa94dd7bc0420117b82760e3878527.tar.gz |
cli/polkit: reject unknown D-Bus methods
-rw-r--r-- | clients/common/nm-polkit-listener.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/clients/common/nm-polkit-listener.c b/clients/common/nm-polkit-listener.c index ddab9f6a5c..a536d9a0aa 100644 --- a/clients/common/nm-polkit-listener.c +++ b/clients/common/nm-polkit-listener.c @@ -47,6 +47,8 @@ #define NM_POLKIT_LISTENER_DBUS_CONNECTION "dbus-connection" #define NM_POLKIT_LISTENER_SESSION_AGENT "session-agent" +#define POLKIT_DBUS_ERROR_FAILED "org.freedesktop.PolicyKit1.Error.Failed" + /*****************************************************************************/ enum { @@ -665,16 +667,36 @@ dbus_method_call_cb (GDBusConnection *connection, uid_to_name (uid), cookie); begin_authentication (request); - } else if (nm_streq (method_name, "CancelAuthentication")) { + return; + } + + if (nm_streq (method_name, "CancelAuthentication")) { g_variant_get (parameters, "&s", &cookie); request = get_request (listener, cookie); - if (request) { - complete_authentication (request, FALSE); + if (!request) { + gs_free char *msg = NULL; + + msg = g_strdup_printf ("No pending authentication request for cookie '%s'", + cookie); + g_dbus_method_invocation_return_dbus_error (invocation, + POLKIT_DBUS_ERROR_FAILED, + msg); + return; } + + /* Complete a cancelled request with success. */ + complete_authentication (request, TRUE); + return; } + + g_dbus_method_invocation_return_error (invocation, + G_DBUS_ERROR, + G_DBUS_ERROR_UNKNOWN_METHOD, + "Unknown method %s", + method_name); } static gboolean |