client-authenticate.c revision 6a3487123ea51203c01b99af3e309a07d3444a0f
/* Copyright (c) 2002-2007 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-parser.h"
#include "auth-client.h"
#include "client.h"
#include "client-authenticate.h"
#include "imap-proxy.h"
#include <stdlib.h>
#define IMAP_SERVICE_NAME "imap"
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 */
}
}
{
unsigned int port = 143;
}
if (proxy &&
/* 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;
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) {
/* Authentication went ok, but for some reason user isn't
allowed to log in. Shouldn't probably happen. */
else if (temp)
else
} else {
return FALSE;
}
/* get back to normal client input. */
}
return TRUE;
}
{
const char *msg;
switch (reply) {
break;
}
break;
break;
}
NULL);
/* get back to normal client input. */
}
break;
else {
}
break;
/* don't check return value here. it gets tricky if we try
to call client_destroy() in here. */
return;
}
}
{
/* we want only one argument: authentication mechanism name */
return -1;
/* optional SASL initial response */
return -1;
}
if (*mech_name == '\0')
return -1;
return 1;
/* don't handle input until we get the initial auth reply */
return 0;
}
{
/* two arguments: username and password */
return -1;
return -1;
return -1;
if (verbose_auth) {
"Plaintext authentication disabled");
}
"* BAD [ALERT] Plaintext authentication is disabled, "
"but your client sent password in plaintext anyway. "
"If anyone was listening, the password was exposed.");
return 1;
}
/* authorization ID \0 authentication ID \0 pass */
return 1;
/* don't read any input from client until login is finished */
return 0;
}