From 44376771cb4f0f60e6d731d3947de0a4ae8a3876 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Mon, 22 Aug 2016 21:00:51 +0200 Subject: [PATCH] Let dbus-daemon allow all supported auth mechanismen in case of empty auth tag in bus config file. https://bugs.freedesktop.org/show_bug.cgi?id=96577 --- bus/bus.c | 2 +- dbus/dbus-auth.c | 37 +++++++++++++++++++++++++++++++++++++ dbus/dbus-auth.h | 2 ++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/bus/bus.c b/bus/bus.c index 90d54d2..9a409bd 100644 --- a/bus/bus.c +++ b/bus/bus.c @@ -438,7 +438,7 @@ process_config_first_time_only (BusContext *context, } else { - auth_mechanisms = NULL; + auth_mechanisms = _dbus_auth_get_supported_mechanisms_list (); } /* Listen on our addresses */ diff --git a/dbus/dbus-auth.c b/dbus/dbus-auth.c index d6c458a..5a862fa 100644 --- a/dbus/dbus-auth.c +++ b/dbus/dbus-auth.c @@ -3043,6 +3043,43 @@ _dbus_auth_dump_supported_mechanisms (DBusString *buffer) return TRUE; } +/** + * Return a list containing all supported auth mechanisms. + * + * @returns pointer to string list + * @returns #NULL on oom + * @note The returned list need to be free'd with dbus_free_string_array(). + */ +char ** +_dbus_auth_get_supported_mechanisms_list () +{ + int i; + char **buffer, **p; + + i = 0; + while (all_mechanisms[i].mechanism != NULL) + i++; + + buffer = dbus_malloc ((i + 1) * sizeof(char *)); + if (!buffer) + return NULL; + + p = buffer; + i = 0; + while (all_mechanisms[i].mechanism != NULL) + { + char *s = strdup (all_mechanisms[i++].mechanism); + if (!s) + { + // clean up list + return NULL; + } + *p++ = s; + } + *p = NULL; + return buffer; +} + /** @} */ /* tests in dbus-auth-util.c */ diff --git a/dbus/dbus-auth.h b/dbus/dbus-auth.h index 991daca..a3ba887 100644 --- a/dbus/dbus-auth.h +++ b/dbus/dbus-auth.h @@ -96,6 +96,8 @@ DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_auth_is_supported_mechanism(DBusString *name); DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_auth_dump_supported_mechanisms(DBusString *buffer); +DBUS_PRIVATE_EXPORT +char ** _dbus_auth_get_supported_mechanisms_list (); DBUS_END_DECLS -- 2.6.6