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];
}
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);
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;
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);
};
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);