From 27eaf870be99c4e980bb0ce3b9003fd04d9a722d Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 31 Jan 2017 07:29:38 +0100 Subject: [PATCH] Let dbus-daemon return allowed auth mechanisms in case of rejected auth. Allowed auth mechanisms are the ones that are implemented and configured in bus config file. https://bugs.freedesktop.org/show_bug.cgi?id=96577 Bug: https://bugs.freedesktop.org/show_bug.cgi?id=99621 --- dbus/dbus-auth.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dbus/dbus-auth.c b/dbus/dbus-auth.c index 7190e97..4e26aaf 100644 --- a/dbus/dbus-auth.c +++ b/dbus/dbus-auth.c @@ -1770,9 +1770,14 @@ send_rejected (DBusAuth *auth) "REJECTED")) goto nomem; - i = 0; - while (all_mechanisms[i].mechanism != NULL) + for (i = 0; all_mechanisms[i].mechanism != NULL; i++) { + /* skip mechanisms that aren't allowed */ + if (auth->allowed_mechs != NULL && + !_dbus_string_array_contains ((const char**)auth->allowed_mechs, + all_mechanisms[i].mechanism)) + continue; + if (!_dbus_string_append (&command, " ")) goto nomem; @@ -1780,8 +1785,6 @@ send_rejected (DBusAuth *auth) if (!_dbus_string_append (&command, all_mechanisms[i].mechanism)) goto nomem; - - ++i; } if (!_dbus_string_append (&command, "\r\n")) -- 2.6.6