]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: ldap - Add ldap_connection_group
authorMarco Bettini <marco.bettini@open-xchange.com>
Fri, 12 Jul 2024 09:45:40 +0000 (09:45 +0000)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Feb 2025 10:34:13 +0000 (12:34 +0200)
src/auth/db-ldap-settings.c
src/auth/db-ldap-settings.h
src/auth/db-ldap.c

index 5f07218e3d9e90722c67f2aa68e3892f92f8b8da..d848c186228dae20b5f3ffe27e38fa77e539a440 100644 (file)
@@ -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 = "",
index 9cba46e615bda8e986d0038f9ee297b74efd9f08..bd351c0703df869b44b8be87bb3209578cb99122 100644 (file)
@@ -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;
 
index 52eec16ddbe7c07008c3aa309fadd5d18bbe1f84..36d572ab24f89fdd9a11b83a7a1ff7ba77e377c8 100644 (file)
@@ -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) &&