bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2009-2018 Dovecot authors, see the included COPYING file */
ebdfdb765f3ce2176c3483b5416b51af9593aca2Stephan Bosch * MAIL command
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch struct smtp_server_cmd_mail *data ATTR_UNUSED)
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch struct client *client = (struct client *)conn_ctx;
6de95f63d4590814354fa5e35e92946c58d4562eTimo Sirainen if (client->lmtp_set->lmtp_user_concurrency_limit > 0) {
6de95f63d4590814354fa5e35e92946c58d4562eTimo Sirainen /* connect to anvil before dropping privileges */
ebdfdb765f3ce2176c3483b5416b51af9593aca2Stephan Bosch * RCPT command
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Boschint cmd_rcpt(void *conn_ctx, struct smtp_server_cmd_ctx *cmd,
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch struct client *client = (struct client *)conn_ctx;
3d7828efd92ecc0d08049f727d9be0154d1d681bStephan Bosch client->unexpanded_lda_set->recipient_delimiter,
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch /* proxied? */
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch /* local delivery */
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch return lmtp_local_rcpt(client, cmd, data, username, detail);
ebdfdb765f3ce2176c3483b5416b51af9593aca2Stephan Bosch * DATA command
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Boschcmd_data_create_added_headers(struct client *client,
2b7d6fbaadd62e66c858bae0358232c02369b43bStephan Bosch /* headers for local deliveries only */
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch lmtp_local_add_headers(client->local, trans, str);
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch /* headers for local and proxied messages */
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch smtp_server_transaction_write_trace_record(str, trans);
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch client->state.added_headers_local + proxy_offset;
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch struct istream *input_msg, *input_local, *input_proxy;
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch client->state.data_end_timeval = ioloop_timeval;
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch /* finish the message */
b8b2cc4e58aef3759ed071d78afaa8319266afc4Stephan Bosch input_msg = iostream_temp_finish(&state->mail_data_output,
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch /* formulate prepended headers for both local and proxy delivery */
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch cmd_data_create_added_headers(client, cmd, trans);
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch /* construct message streams for local and proxy delivery */
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch i_stream_set_name(input_local, "<lmtp DATA local>");
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch i_stream_set_name(input_proxy, "<lmtp DATA proxy>");
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch /* local delivery */
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch lmtp_local_data(client, cmd, trans, input_local);
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch /* proxy delivery */
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch lmtp_proxy_data(client, cmd, trans, input_proxy);
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Boschint cmd_data_continue(void *conn_ctx, struct smtp_server_cmd_ctx *cmd,
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch struct client *client = (struct client *)conn_ctx;
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch struct istream *data_input = (struct istream *)trans->context;
f0a4f00d0312c101a69e2d5b2612d6300bb89367Stephan Bosch while ((ret = i_stream_read(data_input)) > 0 || ret == -2) {
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch "Temporary internal failure");
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch if (ret < 0 && data_input->stream_errno != 0) {
85f8811e47003717620cbe066bb05494124308faTimo Sirainen /* client probably disconnected */
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch /* the ending "." line was seen. finish delivery. */
b73539ef2de3db3abc0ad5f729406e695e4cb76bStephan Bosch struct client *client = (struct client *)conn_ctx;
b8b2cc4e58aef3759ed071d78afaa8319266afc4Stephan Bosch i_assert(client->state.mail_data_output == NULL);
b8b2cc4e58aef3759ed071d78afaa8319266afc4Stephan Bosch mail_user_set_get_temp_prefix(path, client->raw_mail_user->set);
b8b2cc4e58aef3759ed071d78afaa8319266afc4Stephan Bosch iostream_temp_create_named(str_c(path), 0, "(lmtp data)");