From: Timo Sirainen Date: Wed, 8 Mar 2023 14:44:49 +0000 (+0200) Subject: login-common: Stop reading per-connection settings X-Git-Tag: 2.4.0~2234 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=629fcaa33f587dac673868c5eec451e46f5f55dd;p=thirdparty%2Fdovecot%2Fcore.git login-common: Stop reading per-connection settings 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. --- diff --git a/src/login-common/client-common.c b/src/login-common/client-common.c index 446679dc12..f84191eb82 100644 --- a/src/login-common/client-common.c +++ b/src/login-common/client-common.c @@ -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; diff --git a/src/login-common/login-settings.c b/src/login-common/login-settings.c index 9b76be3c01..04b1b928f9 100644 --- a/src/login-common/login-settings.c +++ b/src/login-common/login-settings.c @@ -103,24 +103,3 @@ static bool login_settings_check(void *_set, pool_t pool, return TRUE; } /* */ - -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); -} diff --git a/src/login-common/login-settings.h b/src/login-common/login-settings.h index e41a714cd9..90f5accb96 100644 --- a/src/login-common/login-settings.h +++ b/src/login-common/login-settings.h @@ -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 diff --git a/src/login-common/main.c b/src/login-common/main.c index b61514a7ff..d93d655ddd 100644 --- a/src/login-common/main.c +++ b/src/login-common/main.c @@ -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)