imap-proxy.c revision 493123e38ca1f27b07ac30dcbc59663c5fcdcba2
/* Copyright (c) 2004-2008 Dovecot authors, see the included COPYING file */
#include "common.h"
#include "ioloop.h"
#include "istream.h"
#include "ostream.h"
#include "str.h"
#include "str-sanitize.h"
#include "safe-memset.h"
#include "client.h"
#include "imap-quote.h"
#include "imap-proxy.h"
{
return FALSE;
line += 12;
/* skip over the capability */
while (*line != ' ') {
if (*line == '\0')
return FALSE;
line++;
}
line++;
}
return TRUE;
}
{
"\"x-originating-ip\" \"%s\" "
"\"x-originating-port\" \"%u\" "
"\"x-connected-ip\" \"%s\" "
"\"x-connected-port\" \"%u\")\r\n",
}
{
const char *msg;
if (!client->proxy_login_sent) {
/* this is a banner */
"proxy: Remote returned invalid banner: %s",
return -1;
}
/* send LOGIN command */
return 0;
/* Login successful. Send this line to client. */
(void)client_skip_line(client);
return -1;
/* If the backend server isn't Dovecot, the error message may
be different from Dovecot's "user doesn't exist" error. This
would allow an attacker to find out what users exist in the
system.
The optimal way to handle this would be to replace the
backend's "password failed" error message with Dovecot's
AUTH_FAILED_MSG, but this would require a new setting and
the sysadmin to actually bother setting it properly.
So for now we'll just forward the error message. This
shouldn't be a real problem since of course everyone will
be using only Dovecot as their backend :) */
/* allow client input again */
return -1;
} else {
/* probably some untagged reply */
return 0;
}
}
struct imap_client *client)
{
const char *line;
/* remote authentication failed, we're just
freeing the proxy */
return;
}
/* we came here from client_destroy() */
return;
}
/* failed for some reason, probably server disconnected */
return;
}
switch (i_stream_read(input)) {
case -2:
/* buffer full */
"proxy: Remote input buffer full");
return;
case -1:
/* disconnected */
return;
}
break;
}
}
{
return -1;
}
/* connection_queue_add() decided that we were the oldest
connection and killed us. */
return -1;
}
return -1;
/* disable input until authentication is finished */
return 0;
}