pop3-proxy.c revision 0745a5190c95a5ca80f7ff32e4db8e429dc2a03f
c25356d5978632df6203437e1953bcb29e0c736fTimo Sirainen/* Copyright (C) 2004 Timo Sirainen */
e0f4fbf127b192667c62af7875c4f2ca294b6c7aTimo Sirainenstatic void proxy_input(struct istream *input, struct ostream *output,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* remote authentication failed, we're just
105addcb709523868418cc3e3baad7ad3453a91eTimo Sirainen freeing the proxy */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* failed for some reason */
aef92409cf369afdd2ecd81a4f80083cd4082f46Timo Sirainen /* buffer full */
aef92409cf369afdd2ecd81a4f80083cd4082f46Timo Sirainen i_error("pop-proxy(%s): Remote input buffer full",
1175f27441385a7011629f295f42708f9a3a4ffcTimo Sirainen /* disconnected */
1175f27441385a7011629f295f42708f9a3a4ffcTimo Sirainen client_destroy(client, "Proxy: Remote disconnected");
c5794838af9995f50bfecb06a3cd4f9a0ac77858Timo Sirainen /* this is a banner */
e76f5e07be5bec4e5ca99c3e093ff7f11edbe1b7Timo Sirainen "Remote returned invalid banner: %s",
fee561b9d9162b130e662914fcebc9dd99b5c320Timo Sirainen /* send USER command */
041d312b44f8d41f0c9a5762c23e4d146ef7302bTimo Sirainen (void)o_stream_send(output, str_data(str), str_len(str));
1175f27441385a7011629f295f42708f9a3a4ffcTimo Sirainen /* USER successful, send PASS */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* Login successful. Send this line to client. */
ad48319996942463675b53877092ab7e13a7a75aTimo Sirainen (void)o_stream_send_str(client->output, line);
ad48319996942463675b53877092ab7e13a7a75aTimo Sirainen (void)o_stream_send(client->output, "\r\n", 2);
ad48319996942463675b53877092ab7e13a7a75aTimo Sirainen login_proxy_detach(client->proxy, client->input,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* Login failed. Send our own failure reply so client can't
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen figure out if user exists or not just by looking at the
659fe5d24825b160cae512538088020d97a60239Timo Sirainen reply string. */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen client_send_line(client, "-ERR "AUTH_FAILED_MSG);
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen /* allow client input again */
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainen client->io = io_add(client->common.fd, IO_READ,
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainenint pop3_proxy_new(struct pop3_client *client, const char *host,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen unsigned int port, const char *user, const char *password)
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen client->proxy = login_proxy_new(&client->common, host, port,
7797aa2479e99aeb71057b7a2584b2cb72e4d3f8Timo Sirainen /* disable input until authentication is finished */