Skip to content

Commit

Permalink
lmtp: Add username to recipient event.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanbosch committed Mar 12, 2019
1 parent 2cad948 commit 05a5ae3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/lmtp/lmtp-commands.c
Expand Up @@ -70,6 +70,18 @@ int client_default_cmd_rcpt(struct client *client,
smtp_address_detail_parse_temp(
client->unexpanded_lda_set->recipient_delimiter,
rcpt->path, &username, &delim, &detail);

/* Make user name and detail available in the recipient event. The
mail_user event (for local delivery) also adds the user field, but
adding it here makes it available to the recipient event in general.
Additionally, the auth lookups performed for local and proxy delivery
can further override the "user" recipient event when the auth service
returns a different user name. In any case, we provide the initial
value here.
*/
event_add_str(rcpt->event, "user", username);
event_add_str(rcpt->event, "detail", detail);

if (client->lmtp_set->lmtp_proxy) {
/* proxied? */
if ((ret=lmtp_proxy_rcpt(client, cmd, lrcpt,
Expand Down
5 changes: 5 additions & 0 deletions src/lmtp/lmtp-proxy.c
Expand Up @@ -519,6 +519,11 @@ int lmtp_proxy_rcpt(struct client *client,
return 0;
}
if (strcmp(username, orig_username) != 0) {
/* the existing "user" event field is overridden with the new
user name, while old username is available as "orig_user" */
event_add_str(rcpt->event, "user", username);
event_add_str(rcpt->event, "orig_user", orig_username);

if (smtp_address_parse_username(pool_datastack_create(),
username, &user, &errstr) < 0) {
i_error("%s: Username `%s' returned by passdb lookup is not a valid SMTP address",
Expand Down

0 comments on commit 05a5ae3

Please sign in to comment.