]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
*-login: Allow backend to parse SASL responses from client (for managesieve).
authorTimo Sirainen <tss@iki.fi>
Thu, 13 Aug 2009 17:00:43 +0000 (13:00 -0400)
committerTimo Sirainen <tss@iki.fi>
Thu, 13 Aug 2009 17:00:43 +0000 (13:00 -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 7be47509339deb6cf56f54e5bee80a90f981284f..e53b2aa6265f5f9e134710504b08a489c064d17b 100644 (file)
@@ -433,6 +433,7 @@ struct client_vfuncs client_vfuncs = {
        imap_client_send_line,
        imap_client_auth_handle_reply,
        NULL,
+       NULL,
        imap_proxy_reset,
        imap_proxy_parse_line
 };
index fc086496e6ab39e6f61f216d6333e5467a2aaa5b..23e9dc0f1f551db7f6e4375603815349a2cdde0c 100644 (file)
@@ -324,31 +324,40 @@ client_auth_handle_reply(struct client *client,
        return client->v.auth_handle_reply(client, reply);
 }
 
-static void client_auth_input(struct client *client)
+int client_auth_parse_response(struct client *client, char **data_r)
 {
-       char *line;
-
        if (!client_read(client))
-               return;
+               return 0;
 
        /* @UNSAFE */
-       line = i_stream_next_line(client->input);
-       if (line == NULL)
-               return;
+       *data_r = i_stream_next_line(client->input);
+       if (*data_r == NULL)
+               return 0;
 
-       if (strcmp(line, "*") == 0)
+       if (strcmp(*data_r, "*") == 0) {
                sasl_server_auth_abort(client);
-       else {
-               client_set_auth_waiting(client);
-               auth_client_request_continue(client->auth_request, line);
-               io_remove(&client->io);
-
-               /* clear sensitive data */
-               safe_memset(line, 0, strlen(line));
+               return -1;
        }
+       return 1;
+}
+
+static void client_auth_input(struct client *client)
+{
+       char *line;
+       int ret;
+
+       if ((ret = client->v.auth_parse_response(client, &line)) <= 0)
+               return;
+
+       client_set_auth_waiting(client);
+       auth_client_request_continue(client->auth_request, line);
+       io_remove(&client->io);
+
+       /* clear sensitive data */
+       safe_memset(line, 0, strlen(line));
 }
 
-void client_auth_send_continue(struct client *client, const char *data)
+void client_auth_send_challenge(struct client *client, const char *data)
 {
        struct const_iovec iov[3];
 
@@ -421,7 +430,7 @@ sasl_callback(struct client *client, enum sasl_server_reply sasl_reply,
                }
                break;
        case SASL_SERVER_REPLY_CONTINUE:
-               client->v.auth_send_continue(client, data);
+               client->v.auth_send_challenge(client, data);
 
                if (client->to_auth_waiting != NULL)
                        timeout_remove(&client->to_auth_waiting);
index 6008a36f6278a44066422a3c01531f9c75890cfb..91d8b52d44aea44764c3ec400613129f86781ae1 100644 (file)
@@ -62,8 +62,10 @@ 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;
+       if (client->v.auth_send_challenge == NULL)
+               client->v.auth_send_challenge = client_auth_send_challenge;
+       if (client->v.auth_parse_response == NULL)
+               client->v.auth_parse_response = client_auth_parse_response;
 
        client->created = ioloop_time;
        client->refcount = 1;
index ccece2a4c65ba77af09f278832f6e499bd9b7b01..c0b7149d2babb5925645fa2818293894120023e9 100644 (file)
@@ -63,7 +63,8 @@ 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 (*auth_send_challenge)(struct client *client, const char *data);
+       int (*auth_parse_response)(struct client *client, char **data_r);
        void (*proxy_reset)(struct client *client);
        int (*proxy_parse_line)(struct client *client, const char *line);
 };
@@ -155,7 +156,8 @@ 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);
+void client_auth_send_challenge(struct client *client, const char *data);
+int client_auth_parse_response(struct client *client, char **data_r);
 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 9df176d4d53aec8007f4c2a0d783bbd3a00bdd9c..bc4ce91b6826c1a4b85973ab381dfc4290af26bd 100644 (file)
@@ -220,6 +220,7 @@ struct client_vfuncs client_vfuncs = {
        pop3_client_send_line,
        pop3_client_auth_handle_reply,
        NULL,
+       NULL,
        pop3_proxy_reset,
        pop3_proxy_parse_line
 };