]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
*-login: Abstract out SASL continue reply sending (for managesieve).
authorTimo Sirainen <tss@iki.fi>
Wed, 12 Aug 2009 20:43:41 +0000 (16:43 -0400)
committerTimo Sirainen <tss@iki.fi>
Wed, 12 Aug 2009 20:43:41 +0000 (16:43 -0400)
--HG--
branch : HEAD

src/imap-login/client.c
src/login-common/client-common-auth.c
src/login-common/client-common.c
src/login-common/client-common.h
src/pop3-login/client.c

index 965be1199d4ef396bb32e5231fe2741aea013f09..7be47509339deb6cf56f54e5bee80a90f981284f 100644 (file)
@@ -432,6 +432,7 @@ struct client_vfuncs client_vfuncs = {
        imap_client_input,
        imap_client_send_line,
        imap_client_auth_handle_reply,
+       NULL,
        imap_proxy_reset,
        imap_proxy_parse_line
 };
index 557e6b3ea552e5fe5fac7e3c9bfbe4c60f628ef7..965ef8827c3d8b29012954279bd50b8bf6891638 100644 (file)
@@ -337,13 +337,25 @@ static void client_auth_input(struct client *client)
        }
 }
 
+void client_auth_send_continue(struct client *client, const char *data)
+{
+       struct const_iovec iov[3];
+
+       iov[0].iov_base = "+ ";
+       iov[0].iov_len = 2;
+       iov[1].iov_base = data;
+       iov[1].iov_len = strlen(data);
+       iov[2].iov_base = "\r\n";
+       iov[2].iov_len = 2;
+
+       (void)o_stream_sendv(client->output, iov, 3);
+}
+
 static void
 sasl_callback(struct client *client, enum sasl_server_reply sasl_reply,
              const char *data, const char *const *args)
 {
-       struct const_iovec iov[3];
        struct client_auth_reply reply;
-       size_t data_len;
 
        i_assert(!client->destroyed ||
                 sasl_reply == SASL_SERVER_REPLY_AUTH_ABORTED ||
@@ -398,17 +410,7 @@ sasl_callback(struct client *client, enum sasl_server_reply sasl_reply,
                }
                break;
        case SASL_SERVER_REPLY_CONTINUE:
-               data_len = strlen(data);
-               iov[0].iov_base = "+ ";
-               iov[0].iov_len = 2;
-               iov[1].iov_base = data;
-               iov[1].iov_len = data_len;
-               iov[2].iov_base = "\r\n";
-               iov[2].iov_len = 2;
-
-               /* don't check return value here. it gets tricky if we try
-                  to call client_destroy() in here. */
-               (void)o_stream_sendv(client->output, iov, 3);
+               client->v.auth_send_continue(client, data);
 
                if (client->to_auth_waiting != NULL)
                        timeout_remove(&client->to_auth_waiting);
index be67626d751d5def3708e2535ee83eec7f62ff4e..6008a36f6278a44066422a3c01531f9c75890cfb 100644 (file)
@@ -62,6 +62,9 @@ struct client *client_create(int fd, bool ssl, pool_t pool,
 
        client = client_vfuncs.alloc(pool);
        client->v = client_vfuncs;
+       if (client->v.auth_send_continue == NULL)
+               client->v.auth_send_continue = client_auth_send_continue;
+
        client->created = ioloop_time;
        client->refcount = 1;
 
index ae1d01cc2c3eb8d5b45950000d434d94e78dcf92..58803f3742fef43cd9b8ec918c4d6c37ba6fe4bd 100644 (file)
@@ -62,6 +62,7 @@ struct client_vfuncs {
                          const char *text);
        bool (*auth_handle_reply)(struct client *client,
                                  const struct client_auth_reply *reply);
+       void (*auth_send_continue)(struct client *client, const char *data);
        void (*proxy_reset)(struct client *client);
        int (*proxy_parse_line)(struct client *client, const char *line);
 };
@@ -153,6 +154,7 @@ void client_send_raw_data(struct client *client, const void *data, size_t size);
 void client_send_raw(struct client *client, const char *data);
 
 void client_set_auth_waiting(struct client *client);
+void client_auth_send_continue(struct client *client, const char *data);
 int client_auth_begin(struct client *client, const char *mech_name,
                      const char *init_resp);
 bool client_check_plaintext_auth(struct client *client, bool pass_sent);
index b82dad4e43cb452360ed06e885c1c9d1696a1a9c..9df176d4d53aec8007f4c2a0d783bbd3a00bdd9c 100644 (file)
@@ -219,6 +219,7 @@ struct client_vfuncs client_vfuncs = {
        pop3_client_input,
        pop3_client_send_line,
        pop3_client_auth_handle_reply,
+       NULL,
        pop3_proxy_reset,
        pop3_proxy_parse_line
 };