]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
login-common: Add client_vfuncs.iostream_change_pre/post()
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 13 Mar 2024 11:08:18 +0000 (13:08 +0200)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 18 Mar 2024 08:35:39 +0000 (10:35 +0200)
src/login-common/client-common.c
src/login-common/client-common.h

index fc44d2bc294bc14cb35e47a25c0dabc80a64d0fc..17765fbfcb538b7897f6897efd2a6afa8d27ba25 100644 (file)
@@ -566,9 +566,14 @@ int client_init_ssl(struct client *client)
                        "Failed to initialize SSL server context: %s", error);
                return -1;
        }
-       if (io_stream_create_ssl_server(ssl_ctx, &ssl_set,
-                                       &client->input, &client->output,
-                                       &client->ssl_iostream, &error) < 0) {
+       if (client->v.iostream_change_pre != NULL)
+               client->v.iostream_change_pre(client);
+       int ret = io_stream_create_ssl_server(ssl_ctx, &ssl_set,
+                                             &client->input, &client->output,
+                                             &client->ssl_iostream, &error);
+       if (client->v.iostream_change_post != NULL)
+               client->v.iostream_change_post(client);
+       if (ret < 0) {
                e_error(client->event,
                        "Failed to initialize SSL connection: %s", error);
                ssl_iostream_context_unref(&ssl_ctx);
index a21dea12f0b3ee2bf6baf30b55e1be4cbe98236e..1bc57f08afa71b4dcd3fb33f79b7a0a595ae3337 100644 (file)
@@ -129,6 +129,14 @@ struct client_vfuncs {
        void (*notify_starttls)(struct client *client,
                                bool success, const char *text);
        void (*starttls)(struct client *client);
+
+       /* Called just before client iostreams are changed (e.g. STARTTLS).
+          iostream_change_post() is guaranteed to be called. */
+       void (*iostream_change_pre)(struct client *client);
+       /* Called just after client iostreams may have changed. Nothing may
+          have happened in case of unexpected errors. */
+       void (*iostream_change_post)(struct client *client);
+
        void (*input)(struct client *client);
        bool (*sasl_filter_mech)(struct client *client,
                                 struct auth_mech_desc *mech);