From: Marco Bettini Date: Fri, 12 Jul 2024 09:45:40 +0000 (+0000) Subject: auth: ldap - Add ldap_connection_group X-Git-Tag: 2.4.1~758 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb9d02a1f2b935ec75c510e6bdab5d02888d8028;p=thirdparty%2Fdovecot%2Fcore.git auth: ldap - Add ldap_connection_group --- diff --git a/src/auth/db-ldap-settings.c b/src/auth/db-ldap-settings.c index 5f07218e3d..d848c18622 100644 --- a/src/auth/db-ldap-settings.c +++ b/src/auth/db-ldap-settings.c @@ -20,6 +20,7 @@ static const struct setting_define ldap_setting_defines[] = { { .type = SET_FILTER_NAME, .key = "userdb_ldap", }, DEF(STR, hosts), DEF(STR, uris), + DEF(STR, connection_group), DEF(STR, auth_dn), DEF(STR, auth_dn_password), DEF(STR, auth_sasl_mechanism), @@ -36,6 +37,7 @@ static const struct setting_define ldap_setting_defines[] = { static const struct ldap_settings ldap_default_settings = { .hosts = "", .uris = "", + .connection_group = "", .auth_dn = "", .auth_dn_password = "", .auth_sasl_mechanism = "", diff --git a/src/auth/db-ldap-settings.h b/src/auth/db-ldap-settings.h index 9cba46e615..bd351c0703 100644 --- a/src/auth/db-ldap-settings.h +++ b/src/auth/db-ldap-settings.h @@ -6,6 +6,18 @@ struct ldap_settings { const char *hosts; const char *uris; + + /* This field prevents ldap_conn_find() from reusing the same + connection across stanzas that would otherwise do it. + + Settings with different connection_group will NOT share the + connections, allowing parallel async execution if configured. + + Note that this field is not explicitly used anywhere, but it + affects how ldap_conn_find() compares the settings against an + existing connection */ + const char *connection_group; + const char *auth_dn; const char *auth_dn_password; diff --git a/src/auth/db-ldap.c b/src/auth/db-ldap.c index 52eec16ddb..36d572ab24 100644 --- a/src/auth/db-ldap.c +++ b/src/auth/db-ldap.c @@ -1523,6 +1523,10 @@ void db_ldap_result_iterate_deinit(struct db_ldap_result_iterate_context **_ctx) static struct ldap_connection * db_ldap_conn_find(const struct ldap_settings *set, const struct ssl_settings *ssl_set) { + /* Note that set->connection_group is implicitly used to control + which settings can chare the same connections. Settings with + different values for set->connection_group will NOT share + the connection. */ struct ldap_connection *conn; for (conn = ldap_connections; conn != NULL; conn = conn->next) { if (settings_equal(&ldap_setting_parser_info, set, conn->set, NULL) &&