]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
login-common: Added support for login services that handle their own input io.
authorStephan Bosch <stephan@rename-it.nl>
Mon, 26 Sep 2016 17:12:19 +0000 (19:12 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 11 Dec 2017 13:44:18 +0000 (15:44 +0200)
src/login-common/client-common-auth.c
src/login-common/client-common.c
src/login-common/client-common.h

index 752b5efcd0da72a451dd1f8e045c0bdf53458c81..05cee7a87785124f928a56a46a686b9b85222696 100644 (file)
@@ -71,8 +71,10 @@ static void client_auth_failed(struct client *client)
 
        io_remove(&client->io);
 
-       client->io = io_add(client->fd, IO_READ, client_input, client);
-       client_input(client);
+       if (!client_does_custom_io(client)) {
+               client->io = io_add(client->fd, IO_READ, client_input, client);
+               client_input(client);
+       }
 }
 
 static void client_auth_waiting_timeout(struct client *client)
@@ -580,7 +582,8 @@ void client_auth_respond(struct client *client, const char *response)
        client->auth_waiting = FALSE;
        client_set_auth_waiting(client);
        auth_client_request_continue(client->auth_request, response);
-       io_remove(&client->io);
+       if (!client_does_custom_io(client))
+               io_remove(&client->io);
 }
 
 void client_auth_abort(struct client *client)
@@ -752,9 +755,11 @@ sasl_callback(struct client *client, enum sasl_server_reply sasl_reply,
 
                i_assert(client->io == NULL);
                client->auth_waiting = TRUE;
-               client->io = io_add(client->fd, IO_READ,
-                                   client_auth_input, client);
-               client_auth_input(client);
+               if (!client_does_custom_io(client)) {
+                       client->io = io_add(client->fd, IO_READ,
+                                           client_auth_input, client);
+                       client_auth_input(client);
+               }
                return;
        }
 
@@ -831,7 +836,7 @@ void clients_notify_auth_connected(void)
 
                client_notify_auth_ready(client);
 
-               if (client->input_blocked) {
+               if (!client_does_custom_io(client) && client->input_blocked) {
                        client->input_blocked = FALSE;
                        client_input(client);
                }
index ed7905b9ad0ea671585ff807b854147b4470e5a1..8e0cdb5bde125be9e323957296dcc1c6518ba4ae 100644 (file)
@@ -493,7 +493,10 @@ int client_init_ssl(struct client *client)
 
        if (client->starttls) {
                io_remove(&client->io);
-               client->io = io_add_istream(client->input, client_input, client);
+               if (!client_does_custom_io(client)) {
+                       client->io = io_add_istream(client->input,
+                                                   client_input, client);
+               }
        }
        return 0;
 }
@@ -1078,6 +1081,7 @@ bool client_read(struct client *client)
 
 void client_input(struct client *client)
 {
+       i_assert(client->v.input != NULL);
        client->v.input(client);
 }
 
index 0164b67b5321b47d6804b8d8c98a1811657eb74a..a947cef35104860a79d54e494ac0b0f376eb6f4b 100644 (file)
@@ -282,8 +282,15 @@ void client_auth_fail(struct client *client, const char *text);
 const char *client_get_session_id(struct client *client);
 
 bool client_read(struct client *client);
+
 void client_input(struct client *client);
 
+static inline bool
+client_does_custom_io(struct client *client)
+{
+       return (client->v.input == NULL);
+}
+
 void client_notify_auth_ready(struct client *client);
 void client_notify_status(struct client *client, bool bad, const char *text);
 void client_notify_disconnect(struct client *client,