sasl-server.c revision e59faf65ce864fe95dc00f5d52b8323cdbd0608a
2454dfa32c93c20a8522c6ed42fe057baaac9f9aStephan Bosch/* Copyright (c) 2002-2010 Dovecot authors, see the included COPYING file */
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainen "Maximum number of connections from user+IP exceeded " \
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainen "(mail_max_userip_connections)"
f36c4185474823594a78b3f252e79d8923522c36Timo Sirainen unsigned char cookie[MASTER_AUTH_COOKIE_SIZE];
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainensasl_server_get_advertised_mechs(struct client *client, unsigned int *count_r)
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainen unsigned int i, j, count;
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainen mech = auth_client_get_available_mechs(auth_client, &count);
f300f927771a39549ce6cb7607129508e9041b4aStephan Bosch ret_mech = t_new(struct auth_mech_desc, count);
1e11a94ec50fc9b57eb2c859771c6a326ccaf86fAki Tuomi for (i = j = 0; i < count; i++) {
e60c3e17c656c53da60f0ac51aa15e9ef2742d77Stephan Bosch /* a) transport is secured
1e11a94ec50fc9b57eb2c859771c6a326ccaf86fAki Tuomi b) auth mechanism isn't plaintext
1e11a94ec50fc9b57eb2c859771c6a326ccaf86fAki Tuomi c) we allow insecure authentication
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainen if ((mech[i].flags & MECH_SEC_PRIVATE) == 0 &&
45ead232666a47819e89dc71dec57767340d0b62Timo Sirainen (client->secured || !client->set->disable_plaintext_auth ||
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainen ssl_proxy_has_valid_client_cert(client->ssl_proxy))
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainen auth_flags |= AUTH_REQUEST_FLAG_VALID_CLIENT_CERT;
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainencall_client_callback(struct client *client, enum sasl_server_reply reply,
5e327e031d1591f8bff17b67eba7139afbd36cddTimo Sirainen i_assert(reply != SASL_SERVER_REPLY_CONTINUE);
c6be98b5270900746f35ebe28bd636019976e29eTimo Sirainen /* NOTE: client may be destroyed now */
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainenmaster_auth_callback(const struct master_auth_reply *reply, void *context)
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainen enum sasl_server_reply sasl_reply = SASL_SERVER_REPLY_MASTER_FAILED;
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainen call_client_callback(client, sasl_reply, data, NULL);
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainenstatic void master_send_request(struct anvil_request *anvil_request)
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainen struct client *client = anvil_request->client;
2d1892aaeb63b9774237b6e60d6bb04bf6f8259cTimo Sirainen const unsigned char *data;
107659c01b2359b0ee426bde020c8d4e29ede30dTimo Sirainen memcpy(req.cookie, anvil_request->cookie, sizeof(req.cookie));
107659c01b2359b0ee426bde020c8d4e29ede30dTimo Sirainen buf = buffer_create_dynamic(pool_datastack_create(), 256);
107659c01b2359b0ee426bde020c8d4e29ede30dTimo Sirainen buffer_append(buf, client->master_data_prefix,
107659c01b2359b0ee426bde020c8d4e29ede30dTimo Sirainen data = i_stream_get_data(client->input, &size);
c1fc5a97a15332f1253ee13a9cab65a7b4b6cd5fTimo Sirainen master_auth_request(master_auth, client->fd, &req, buf->data,
c1fc5a97a15332f1253ee13a9cab65a7b4b6cd5fTimo Sirainen master_auth_callback, client, &client->master_tag);
c1fc5a97a15332f1253ee13a9cab65a7b4b6cd5fTimo Sirainenstatic void anvil_lookup_callback(const char *reply, void *context)
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainen strtoul(reply, NULL, 10) < client->set->mail_max_userip_connections)
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainen call_client_callback(client, SASL_SERVER_REPLY_MASTER_FAILED,
bool nologin;
switch (status) {
case AUTH_REQUEST_STATUS_OK:
if (nologin) {
case AUTH_REQUEST_STATUS_FAIL:
const char *initial_resp_base64,
const char *auth_name =