From: Arran Cudbard-Bell Date: Fri, 6 Jun 2025 06:03:54 +0000 (-0600) Subject: Print list of attributes we're retrieving X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f2bbf2fe2f2887783d88c00cde84ebcf61361a97;p=thirdparty%2Ffreeradius-server.git Print list of attributes we're retrieving --- diff --git a/src/lib/ldap/base.c b/src/lib/ldap/base.c index 5aa690c0523..19dd4f756b2 100644 --- a/src/lib/ldap/base.c +++ b/src/lib/ldap/base.c @@ -33,8 +33,10 @@ USES_APPLE_DEPRECATED_API #define LOG_PREFIX handle_config->name #include +#include #include #include +#include LDAP *ldap_global_handle; //!< Hack for OpenLDAP libldap global initialisation. @@ -555,12 +557,24 @@ fr_ldap_rcode_t fr_ldap_search_async(int *msgid, request_t *request, */ memcpy(&search_attrs, &attrs, sizeof(attrs)); - if (filter) { - ROPTIONAL(RDEBUG2, DEBUG2, "Performing search in \"%s\" with filter \"%s\", scope \"%s\"", dn, filter, - fr_table_str_by_value(fr_ldap_scope, scope, "")); - } else { - ROPTIONAL(RDEBUG2, DEBUG2, "Performing unfiltered search in \"%s\", scope \"%s\"", dn, - fr_table_str_by_value(fr_ldap_scope, scope, "")); + if ((request && RDEBUG_ENABLED2) || DEBUG_ENABLED2) { + fr_sbuff_t *log_msg; + + FR_SBUFF_TALLOC_THREAD_LOCAL(&log_msg, 128, SIZE_MAX); + + fr_sbuff_in_sprintf(log_msg, "Performing search in \"%s\"", dn); + if (filter) { + fr_sbuff_in_sprintf(log_msg, " with filter \"%s\"", filter); + } else { + fr_sbuff_in_strcpy_literal(log_msg, " with no filter"); + } + fr_sbuff_in_sprintf(log_msg, ", scope \"%s\"", + fr_table_str_by_value(fr_ldap_scope, scope, "")); + if (attrs) { + fr_sbuff_in_strcpy(log_msg, ", attrs "); + fr_sbuff_in_array(log_msg, attrs, ", "); + } + ROPTIONAL(RDEBUG2, DEBUG2, "%s", fr_sbuff_start(log_msg)); } if (ldap_search_ext(pconn->handle, dn, scope, filter, search_attrs,