client-common-auth.c revision d3a7d023b47d2a137f01109e7b38702dca3f11d3
76b43e4417bab52e913da39b5f5bc2a130d3f149Timo Sirainen/* Copyright (c) 2002-2009 Dovecot authors, see the included COPYING file */
f6c1297c26b355c4aec2a08978f51ec3efecb351Timo Sirainen/* If we've been waiting auth server to respond for over this many milliseconds,
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen send a "waiting" message. */
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen#if CLIENT_LOGIN_IDLE_TIMEOUT_MSECS < AUTH_REQUEST_TIMEOUT*1000
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen# error client idle timeout must be larger than authentication timeout
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainenstatic void client_authfail_delay_timeout(struct client *client)
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen /* get back to normal client input. */
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen client->io = io_add(client->fd, IO_READ, client_input, client);
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainenvoid client_auth_failed(struct client *client, bool nodelay)
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen client->io = io_add(client->fd, IO_READ, client_input, client);
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen /* increase the timeout after each unsuccessful attempt, but don't
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen increase it so high that the idle timeout would be triggered */
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen delay_msecs = client->auth_attempts * AUTH_FAILURE_DELAY_INCREASE_MSECS;
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen if (delay_msecs > CLIENT_LOGIN_IDLE_TIMEOUT_MSECS)
2769eecf814bd243033dcbf5bdc38f4162d3202dTimo Sirainen delay_msecs = CLIENT_LOGIN_IDLE_TIMEOUT_MSECS - 1000;
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen timeout_add(delay_msecs, client_authfail_delay_timeout, client);
2769eecf814bd243033dcbf5bdc38f4162d3202dTimo Sirainenstatic void client_auth_waiting_timeout(struct client *client)
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen client_send_line(client, CLIENT_CMD_REPLY_STATUS,
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen AUTH_SERVER_WAITING_MSG : AUTH_MASTER_WAITING_MSG);
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainenvoid client_set_auth_waiting(struct client *client)
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainenstatic void client_auth_parse_args(struct client *client,
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen const char *const *args,
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen reply_r->ssl_flags |= PROXY_SSL_FLAG_STARTTLS;
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen /* already handled in login-common */
6ef7e31619edfaa17ed044b45861d106a86191efTimo Sirainen i_info("Ignoring unknown passdb extra field: %s", key);
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainenstatic void proxy_free_password(struct client *client)
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen safe_memset(client->proxy_password, 0, strlen(client->proxy_password));
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainenvoid client_proxy_finish_destroy_client(struct client *client)
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen str_printfa(str, "proxy(%s): started proxying to %s:%u",
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen if (strcmp(client->virtual_user, client->proxy_user) != 0) {
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen /* remote username is different, log it */
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen str_printfa(str, " (master %s)", client->proxy_master_user);
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen login_proxy_detach(client->login_proxy, client->input, client->output);
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainenvoid client_proxy_log_failure(struct client *client, const char *line)
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen str_printfa(str, "proxy(%s): Login failed to %s:%u",
66a872b4569c048e804f0731680d89c6042d8890Timo Sirainen if (strcmp(client->virtual_user, client->proxy_user) != 0) {
66a872b4569c048e804f0731680d89c6042d8890Timo Sirainen /* remote username is different, log it */
f8da06de93e28b5d3e039a427cdde7e1e15daec8Timo Sirainen str_printfa(str, " (master %s)", client->proxy_master_user);
if (send_line) {
const char *line;
if (!success)
return FALSE;
return TRUE;
char *line;
switch (sasl_reply) {
data);
const char *init_resp)
return TRUE;
if (pass_sent) {
return FALSE;
void clients_notify_auth_connected(void)