From a30ed7453e2417d723907a3be5059b147be2470d 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 e64cc8f..4fd120b 100644 --- a/bus/bus.c +++ b/bus/bus.c @@ -459,7 +459,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 265b424..dc29a1c 100644 --- a/dbus/dbus-auth.c +++ b/dbus/dbus-auth.c @@ -2878,6 +2878,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 (void) +{ + 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..46ab4ab 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 (void); DBUS_END_DECLS -- 1.8.4.5