imap-proxy.c revision feb665db52583259a1f42037c6e8a22852aa8889
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen/* Copyright (C) 2004 Timo Sirainen */
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainenstatic int proxy_input_line(struct imap_client *client,
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen /* this is a banner */
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen "Remote returned invalid banner: %s",
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen /* send LOGIN command */
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen imap_quote_append_string(str, client->proxy_user, FALSE);
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen imap_quote_append_string(str, client->proxy_password, FALSE);
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen (void)o_stream_send(output, str_data(str), str_len(str));
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen /* Login successful. Send this line to client. */
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen (void)o_stream_send_str(client->output, client->cmd_tag);
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen (void)o_stream_send_str(client->output, line + 1);
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen (void)o_stream_send(client->output, "\r\n", 2);
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen login_proxy_detach(client->proxy, client->input,
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen client_destroy(client, t_strdup_printf("proxy(%s): started",
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen /* Login failed. Send our own failure reply so client can't
378e6cb162b355d6f103526505bc00b9a78962e7Timo Sirainen figure out if user exists or not just by looking at the
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen reply string. */
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen client_send_tagline(client, "NO "AUTH_FAILED_MSG);
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen /* allow client input again */
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen client->io = io_add(client->common.fd, IO_READ,
25ec868bd8b5375e1c1c4c3331d761667ddfe26cTimo Sirainen /* probably some untagged reply */
25ec868bd8b5375e1c1c4c3331d761667ddfe26cTimo Sirainenstatic void proxy_input(struct istream *input, struct ostream *output,
378e6cb162b355d6f103526505bc00b9a78962e7Timo Sirainen /* remote authentication failed, we're just
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen freeing the proxy */
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen /* failed for some reason, probably server disconnected */
c076ad69e28e7d41af83ada84e12019793ffcfa2Timo Sirainen client_send_line(client, "* BYE Temporary login failure.");
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen /* buffer full */
2686ef87921233609d1d8ec8dee2883facc2c5ebTimo Sirainen i_error("imap-proxy(%s): Remote input buffer full",