pop3-proxy.c revision e3a838c80f54f024115fade93c6c87a0998f1fab
/* Copyright (c) 2004-2009 Dovecot authors, see the included COPYING file */
#include "common.h"
#include "ioloop.h"
#include "istream.h"
#include "ostream.h"
#include "base64.h"
#include "safe-memset.h"
#include "str.h"
#include "str-sanitize.h"
#include "client.h"
#include "pop3-proxy.h"
{
return;
}
{
if (send_line)
/* call this last - it may destroy the client */
}
{
}
{
switch (client->proxy_state) {
case 0:
/* this is a banner */
"proxy: Remote returned invalid banner: %s",
return -1;
}
/* send USER command */
} else {
/* master user login - use AUTH PLAIN. */
}
client->proxy_state++;
return 0;
case 1:
break;
/* USER successful, send PASS */
} else {
if (*line != '+')
break;
/* AUTH successful, send the authentication data */
}
client->proxy_state++;
return 0;
case 2:
break;
/* Login successful. Send this line to client. */
client->proxy_user) != 0) {
/* remote username is different, log it */
}
}
return 1;
}
/* Login failed. Pass through the error message to client.
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 :) */
else
if (login_settings->verbose_auth) {
client->proxy_user) != 0) {
/* remote username is different, log it */
}
}
else
}
return -1;
}
struct pop3_client *client)
{
const char *line;
/* 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:
"proxy: Remote input buffer full");
return;
case -1:
"proxy: Remote disconnected");
return;
}
break;
}
}
const char *password)
{
return -1;
}
/* connection_queue_add() decided that we were the oldest
connection and killed us. */
return -1;
}
return -1;
}
return -1;
}
client->proxy_state = 0;
/* disable input until authentication is finished */
return 0;
}