]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
login-common: Stop reading per-connection settings
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 8 Mar 2023 14:44:49 +0000 (16:44 +0200)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 20 Nov 2023 12:20:55 +0000 (14:20 +0200)
This is no longer necessary. The filtering is done by
master_service_settings_get().

This commit also adds "local_name" field to client's event when TLS SNI is
used.

src/login-common/client-common.c
src/login-common/login-settings.c
src/login-common/login-settings.h
src/login-common/main.c

index 446679dc12907ea124fce724a7b4b55fb3ffc560..f84191eb8254ebb7061ee88b1fd64be57d214265 100644 (file)
@@ -210,13 +210,11 @@ client_var_expand_callback(struct event *event,
        *tab_r = get_var_expand_table(client);
 }
 
-static int client_settings_read(struct client *client, const char **error_r)
+static int client_settings_get(struct client *client, const char **error_r)
 {
        i_assert(client->set == NULL);
 
-       if (login_settings_read(&client->local_ip, &client->ip,
-                               client->local_name, error_r) < 0 ||
-           master_service_settings_get(client->event,
+       if (master_service_settings_get(client->event,
                                        &login_setting_parser_info,
                                        0, &client->set, error_r) < 0 ||
            master_service_settings_get(client->event,
@@ -278,7 +276,7 @@ int client_alloc(int fd, const struct master_service_connection *conn,
        event_set_ptr(client->event, MASTER_SERVICE_VAR_EXPAND_CALLBACK,
                      client_var_expand_callback);
        event_set_ptr(client->event, "client", client);
-       if (client_settings_read(client, &error) < 0) {
+       if (client_settings_get(client, &error) < 0) {
                e_error(client->event, "%s", error);
                event_unref(&client->event);
                pool_unref(&client->pool);
@@ -681,8 +679,12 @@ static int client_sni_callback(const char *name, const char **error_r,
        client->ssl_set = NULL;
        client->ssl_server_set = NULL;
 
+       /* Add local_name also to event. This is especially important to get
+          local_name { .. } config filters to work when looking up the settings
+          again. */
+       event_add_str(client->event, "local_name", name);
        client->local_name = p_strdup(client->pool, name);
-       if (client_settings_read(client, error_r) < 0) {
+       if (client_settings_get(client, error_r) < 0) {
                client->set = old_set;
                client->ssl_set = old_ssl_set;
                client->ssl_server_set = old_ssl_server_set;
index 9b76be3c01e817464708c09795f86a5f91b3e85f..04b1b928f92f53607ccffda64e245b1ea9740fc7 100644 (file)
@@ -103,24 +103,3 @@ static bool login_settings_check(void *_set, pool_t pool,
        return TRUE;
 }
 /* </settings checks> */
-
-int login_settings_read(const struct ip_addr *local_ip,
-                       const struct ip_addr *remote_ip,
-                       const char *local_name, const char **error_r)
-{
-       struct master_service_settings_input input;
-       struct master_service_settings_output output;
-
-       i_zero(&input);
-       input.service = login_binary->protocol;
-       input.local_name = local_name;
-       input.disable_check_settings = TRUE;
-
-       if (local_ip != NULL)
-               input.local_ip = *local_ip;
-       if (remote_ip != NULL)
-               input.remote_ip = *remote_ip;
-
-       return master_service_settings_read(master_service, &input,
-                                           &output, error_r);
-}
index e41a714cd96063dd2cb74398403adce1639bfc2e..90f5accb96f125ddf7aff93bb0c6b42b4c3e610b 100644 (file)
@@ -38,9 +38,4 @@ struct login_settings {
 
 extern const struct setting_parser_info login_setting_parser_info;
 
-int login_settings_read(const struct ip_addr *local_ip,
-                       const struct ip_addr *remote_ip,
-                       const char *local_name, const char **error_r)
-       ATTR_NULL(1, 2, 3);
-
 #endif
index b61514a7ff90fb8dfaf429629dded5541894bccb..d93d655ddd8bada87893e0a725bc811425ba51fb 100644 (file)
@@ -499,7 +499,13 @@ int login_binary_run(struct login_binary *binary,
 
        login_binary->preinit();
 
-       if (login_settings_read(NULL, NULL, NULL, &error) < 0 ||
+       struct master_service_settings_input input = {
+               .service = login_binary->protocol,
+               .disable_check_settings = TRUE,
+       };
+       struct master_service_settings_output output;
+       if (master_service_settings_read(master_service, &input,
+                                        &output, &error) < 0 ||
            master_service_settings_get(NULL, &login_setting_parser_info,
                                        MASTER_SERVICE_SETTINGS_GET_FLAG_NO_EXPAND,
                                        &global_login_settings, &error) < 0)