client-authenticate.c revision 3557b4f31edaa9f9ae87f89e34b286cbc5c6992f
/* Copyright (c) 2002-2008 Dovecot authors, see the included COPYING file */
#include "common.h"
#include "base64.h"
#include "buffer.h"
#include "ioloop.h"
#include "istream.h"
#include "ostream.h"
#include "safe-memset.h"
#include "str.h"
#include "str-sanitize.h"
#include "imap-resp-code.h"
#include "imap-parser.h"
#include "auth-client.h"
#include "client.h"
#include "client-authenticate.h"
#include "imap-proxy.h"
#include <stdlib.h>
#define AUTH_FAILURE_DELAY_INCREASE_MSECS 5000
#define IMAP_SERVICE_NAME "imap"
#define IMAP_AUTHZ_FAILED_MSG \
const char *client_authenticate_get_capabilities(bool secured)
{
const struct auth_mech_desc *mech;
unsigned int i, count;
for (i = 0; i < count; i++) {
/* a) transport is secured
b) auth mechanism isn't plaintext
c) we allow insecure authentication
*/
(secured || !disable_plaintext_auth ||
}
}
}
{
char *line;
if (!client_read(client))
return;
return;
}
/* @UNSAFE */
return;
"Authentication aborted");
} else {
/* clear sensitive data */
}
}
{
/* get back to normal client input. */
}
{
unsigned int delay_msecs;
if (client->auth_initializing)
return;
if (nodelay) {
return;
}
/* increase the timeout after each unsuccessful attempt, but don't
increase it so high that the idle timeout would be triggered */
}
bool *nodelay_r)
{
const char *master_user = NULL;
unsigned int port = 143;
bool authz_failure = FALSE;
/* already handled in login-common */
} else if (auth_debug) {
i_info("Ignoring unknown passdb extra field: %s",
*args);
}
}
proxy_self = proxy &&
if (proxy && !proxy_self) {
/* we want to proxy the connection to another server.
don't do this unless authentication succeeded. with
master user proxying we can get FAIL with proxy still set.
proxy host=.. [port=..] [destuser=..] pass=.. */
if (!success)
return FALSE;
pass) < 0)
return TRUE;
}
/* IMAP referral
[nologin] referral host=.. [port=..] [destuser=..]
[reason=..]
NO [REFERRAL imap://destuser;AUTH=..@host:port/] Can't login.
OK [...] Logged in, but you should use this server instead.
.. [REFERRAL ..] (Reason from auth server)
*/
if (port != 143)
else if (nologin)
else {
"this server instead.");
}
if (!nologin) {
return TRUE;
}
} else if (nologin || proxy_self) {
/* Authentication went ok, but for some reason user isn't
allowed to log in. Shouldn't probably happen. */
if (proxy_self) {
"Proxying loops to itself");
}
else if (temp || proxy_self) {
} else if (authz_failure) {
} else {
}
} else {
return FALSE;
}
return TRUE;
}
{
const char *msg;
bool nodelay;
switch (reply) {
break;
}
break;
break;
}
break;
else {
/* authentication itself succeeded, we just hit some
internal failure. */
}
break;
/* don't check return value here. it gets tricky if we try
to call client_destroy() in here. */
return;
}
}
const char *init_resp)
{
return 1;
/* don't handle input until we get the initial auth reply */
return 0;
}
{
/* we want only one argument: authentication mechanism name */
return -1;
/* optional SASL initial response */
return -1;
}
if (*mech_name == '\0')
return -1;
}
{
/* two arguments: username and password */
return -1;
return -1;
return -1;
if (verbose_auth) {
"Plaintext authentication disabled");
}
"* BAD [ALERT] Plaintext authentication not allowed "
"If anyone was listening, the password was exposed.");
return 1;
}
/* authorization ID \0 authentication ID \0 pass */
}