From: Aki Tuomi Date: Mon, 4 Aug 2025 14:47:21 +0000 (+0300) Subject: login-common: Extract client_reload_settings() X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8773e2d25f42aab7b02e6938a984460ed07f1314;p=thirdparty%2Fdovecot%2Fcore.git login-common: Extract client_reload_settings() --- diff --git a/src/login-common/client-common.c b/src/login-common/client-common.c index 8e15d26586..508b799d00 100644 --- a/src/login-common/client-common.c +++ b/src/login-common/client-common.c @@ -704,18 +704,8 @@ void clients_destroy_all(void) clients_destroy_all_reason(MASTER_SERVICE_SHUTTING_DOWN_MSG); } -int client_sni_callback(const char *name, const char **error_r, - void *context) +int client_settings_reload(struct client *client, const char **error_r) { - struct client *client = context; - struct ssl_iostream_context *ssl_ctx; - const struct ssl_iostream_settings *ssl_set; - int ret; - - if (client->ssl_servername_settings_read) - return 0; - client->ssl_servername_settings_read = TRUE; - const struct login_settings *old_set = client->set; const struct ssl_settings *old_ssl_set = client->ssl_set; const struct ssl_server_settings *old_ssl_server_set = @@ -724,11 +714,6 @@ 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_get(client, error_r) < 0 || (client->v.reload_config != NULL && client->v.reload_config(client, error_r) < 0)) { @@ -743,6 +728,28 @@ int client_sni_callback(const char *name, const char **error_r, settings_free(old_set); settings_free(old_ssl_set); settings_free(old_ssl_server_set); + return 0; +} + +int client_sni_callback(const char *name, const char **error_r, + void *context) +{ + struct client *client = context; + struct ssl_iostream_context *ssl_ctx; + const struct ssl_iostream_settings *ssl_set; + int ret; + + if (client->ssl_servername_settings_read) + return 0; + client->ssl_servername_settings_read = TRUE; + + /* 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_reload(client, error_r) < 0) + return -1; ssl_server_settings_to_iostream_set(client->ssl_set, client->ssl_server_set, &ssl_set); diff --git a/src/login-common/client-common.h b/src/login-common/client-common.h index d3a5f87224..4a83672924 100644 --- a/src/login-common/client-common.h +++ b/src/login-common/client-common.h @@ -357,6 +357,9 @@ void client_destroy_success(struct client *client, const char *reason); void client_ref(struct client *client); bool client_unref(struct client **client) ATTR_NOWARN_UNUSED_RESULT; +int client_settings_reload(struct client *client, const char **error_r) + ATTR_WARN_UNUSED_RESULT; + void client_rawlog_init(struct client *client); void client_rawlog_deinit(struct client *client);