struct smtp_server_recipient *rcpt)
{
struct client *client = (struct client *)conn_ctx;
+ struct smtp_server_transaction *trans;
struct lmtp_recipient *lrcpt;
- lrcpt = lmtp_recipient_create(client, rcpt);
+ trans = smtp_server_connection_get_transaction(rcpt->conn);
+ i_assert(trans != NULL); /* MAIL command is synchronous */
+
+ lrcpt = lmtp_recipient_create(client, trans, rcpt);
if (cmd_rcpt_handle_forward_fields(cmd, lrcpt) < 0)
return -1;
struct lmtp_local_recipient {
struct lmtp_recipient *rcpt;
- char *session_id;
char *detail;
}
}
-int lmtp_local_rcpt(struct client *client, struct smtp_server_cmd_ctx *cmd,
+int lmtp_local_rcpt(struct client *client,
+ struct smtp_server_cmd_ctx *cmd ATTR_UNUSED,
struct lmtp_recipient *lrcpt, const char *username,
const char *detail)
{
- struct smtp_server_connection *conn = cmd->conn;
struct smtp_server_recipient *rcpt = lrcpt->rcpt;
- struct smtp_server_transaction *trans;
struct lmtp_local_recipient *llrcpt;
struct mail_storage_service_input input;
struct mail_storage_service_user *service_user;
- const char *session_id, *error = NULL;
+ const char *error = NULL;
int ret = 0;
- trans = smtp_server_connection_get_transaction(conn);
- i_assert(trans != NULL); /* MAIL command is synchronous */
-
- /* Use a unique session_id for each mail delivery. This is especially
- important for stats process to not see duplicate sessions. */
- client->state.session_id_seq++;
- session_id = t_strdup_printf("%s:%u",
- trans->id, client->state.session_id_seq);
-
i_zero(&input);
input.module = input.service = "lmtp";
input.username = username;
input.remote_ip = client->remote_ip;
input.local_port = client->local_port;
input.remote_port = client->remote_port;
- input.session_id = session_id;
+ input.session_id = lrcpt->session_id;
input.conn_ssl_secured =
smtp_server_connection_is_ssl_secured(client->conn);
input.conn_secured = input.conn_ssl_secured ||
smtp_server_connection_is_trusted(client->conn);
input.forward_fields = lrcpt->forward_fields;
-
- event_add_str(rcpt->event, "session", session_id);
input.event_parent = rcpt->event;
ret = mail_storage_service_lookup(storage_service, &input,
llrcpt->rcpt = lrcpt;
llrcpt->detail = p_strdup(rcpt->pool, detail);
llrcpt->service_user = service_user;
- llrcpt->session_id = p_strdup(rcpt->pool, session_id);
lrcpt->type = LMTP_RECIPIENT_TYPE_LOCAL;
lrcpt->backend_context = llrcpt;
}
i_zero(&lldctx);
- lldctx.session_id = llrcpt->session_id;
+ lldctx.session_id = lrcpt->session_id;
lldctx.src_mail = src_mail;
lldctx.session = session;
/* Copyright (c) 2018 Dovecot authors, see the included COPYING file */
-#include "lib.h"
+#include "lmtp-common.h"
#include "array.h"
#include "smtp-server.h"
#include "lmtp-recipient.h"
struct lmtp_recipient *
lmtp_recipient_create(struct client *client,
+ struct smtp_server_transaction *trans,
struct smtp_server_recipient *rcpt)
{
struct lmtp_recipient *lrcpt;
p_array_init(&lrcpt->module_contexts, rcpt->pool, 5);
+ /* Use a unique session_id for each mail delivery. This is especially
+ important for stats process to not see duplicate sessions. */
+ client->state.session_id_seq++;
+ lrcpt->session_id = p_strdup_printf(rcpt->pool, "%s:%u", trans->id,
+ client->state.session_id_seq);
+
+ event_add_str(rcpt->event, "session", lrcpt->session_id);
+
return lrcpt;
}