]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
*-login: Allow client.create() to return failure
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 5 Jan 2023 11:02:07 +0000 (13:02 +0200)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 20 Nov 2023 12:11:41 +0000 (14:11 +0200)
src/imap-login/imap-login-client.c
src/imap-urlauth-login/imap-urlauth-login.c
src/login-common/client-common.c
src/login-common/client-common.h
src/login-common/main.c
src/pop3-login/client.c
src/submission-login/client.c

index 7b3cfdd876f87b77486768bd24e43bfcc80e9836..0ecef9f26fb010f76fb33cfbe713bd621e600432 100644 (file)
@@ -376,7 +376,7 @@ static struct client *imap_client_alloc(pool_t pool)
        return &imap_client->common;
 }
 
-static void imap_client_create(struct client *client, void **other_sets)
+static int imap_client_create(struct client *client, void **other_sets)
 {
        struct imap_client *imap_client = (struct imap_client *)client;
 
@@ -388,6 +388,7 @@ static void imap_client_create(struct client *client, void **other_sets)
        if (imap_client->set->imap_literal_minus)
                imap_parser_enable_literal_minus(imap_client->parser);
        client->io = io_add_istream(client->input, client_input, client);
+       return 0;
 }
 
 static void imap_client_destroy(struct client *client)
index 04cbaf23fb42748db7813e3b2bd1bd7b7d5d51fb..12df297d732a313977ef7e8484acc7f9b19dcaf9 100644 (file)
@@ -143,7 +143,7 @@ static struct client *imap_urlauth_client_alloc(pool_t pool)
        return &uauth_client->common;
 }
 
-static void imap_urlauth_client_create
+static int imap_urlauth_client_create
 (struct client *client, void **other_sets)
 {
        struct imap_urlauth_client *uauth_client =
@@ -151,6 +151,7 @@ static void imap_urlauth_client_create
 
        uauth_client->set = other_sets[0];
        client->io = io_add_istream(client->input, client_input, client);
+       return 0;
 }
 
 static void imap_urlauth_client_notify_auth_ready(struct client *client)
index 0cd07027ff86a9cb30c3d2fdd166601fec141824..89025fe33b233ffeed09d0f6c2d63670f69a8c80 100644 (file)
@@ -285,7 +285,7 @@ client_alloc(int fd, pool_t pool,
        return client;
 }
 
-void client_init(struct client *client, void **other_sets)
+int client_init(struct client *client, void **other_sets)
 {
        if (last_client == NULL)
                last_client = client;
@@ -298,7 +298,8 @@ void client_init(struct client *client, void **other_sets)
                            client_idle_disconnect_timeout, client);
 
        hook_login_client_allocated(client);
-       client->v.create(client, other_sets);
+       if (client->v.create(client, other_sets) < 0)
+               return -1;
        client->create_finished = TRUE;
 
        if (auth_client_is_connected(auth_client))
@@ -307,6 +308,7 @@ void client_init(struct client *client, void **other_sets)
                client_set_auth_waiting(client);
 
        login_refresh_proctitle();
+       return 0;
 }
 
 static void client_disconnected_log(struct event *event, const char *reason,
index 823439decc52801f0ec1fe0cce83164b2dbf7ec3..11ba054af855c216cdb925c6b0a565f56363cd48 100644 (file)
@@ -119,7 +119,7 @@ struct client_auth_reply {
 
 struct client_vfuncs {
        struct client *(*alloc)(pool_t pool);
-       void (*create)(struct client *client, void **other_sets);
+       int (*create)(struct client *client, void **other_sets);
        void (*destroy)(struct client *client);
        void (*notify_auth_ready)(struct client *client);
        void (*notify_disconnect)(struct client *client,
@@ -319,7 +319,7 @@ client_alloc(int fd, pool_t pool,
             const struct login_settings *set,
             const struct master_service_ssl_settings *ssl_set,
             const struct master_service_ssl_server_settings *ssl_server_set);
-void client_init(struct client *client, void **other_sets);
+int client_init(struct client *client, void **other_sets);
 void client_disconnect(struct client *client, const char *reason,
                       bool add_disconnected_prefix);
 void client_destroy(struct client *client, const char *reason);
index 63ac7f91822adb5e974af9180a30a76b16fdff5a..2c7f487da141cc3978c8e8d56a6d7d62ebb44326 100644 (file)
@@ -186,7 +186,10 @@ client_connected(struct master_service_connection *conn)
                        return;
                }
        }
-       client_init(client, other_sets);
+       if (client_init(client, other_sets) < 0) {
+               client_destroy(client, "Failed to initialize client");
+               return;
+       }
        client->event_auth = event_create(client->event);
        event_add_category(client->event_auth, &event_category_auth);
        event_set_min_log_level(client->event_auth, set->auth_verbose ?
index 2e0abc2f4f8a5bb8a84ae647557d79ae9bc417b2..b1042344ad78dc2be3cfef16a54f952139b8d06b 100644 (file)
@@ -207,9 +207,10 @@ static struct client *pop3_client_alloc(pool_t pool)
        return &pop3_client->common;
 }
 
-static void pop3_client_create(struct client *client ATTR_UNUSED,
-                              void **other_sets ATTR_UNUSED)
+static int pop3_client_create(struct client *client ATTR_UNUSED,
+                             void **other_sets ATTR_UNUSED)
 {
+       return 0;
 }
 
 static void pop3_client_destroy(struct client *client)
index 42a79f3d66c3a8b70dd3f1720a797cd760fd3a16..6ba53caef388006cb8ea2df88b4be625b2f33c50 100644 (file)
@@ -90,8 +90,8 @@ static struct client *submission_client_alloc(pool_t pool)
        return &subm_client->common;
 }
 
-static void submission_client_create(struct client *client,
-                                    void **other_sets)
+static int submission_client_create(struct client *client,
+                                   void **other_sets)
 {
        static const char *const xclient_extensions[] =
                { "FORWARD", NULL };
@@ -122,6 +122,7 @@ static void submission_client_create(struct client *client,
                smtp_server, client->input, client->output,
                &client->real_remote_ip, client->real_remote_port,
                &smtp_set, &smtp_callbacks, subm_client);
+       return 0;
 }
 
 static void submission_client_destroy(struct client *client)