Mercurial > dovecot > core-2.2
changeset 11495:d2037445feed HEAD
lmtp proxy: Fixed passdb username change.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 07 Jun 2010 20:50:08 +0100 |
parents | 68287c257c0a |
children | 2d6cf78982dc |
files | src/lmtp/commands.c |
diffstat | 1 files changed, 27 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lmtp/commands.c Mon Jun 07 19:51:59 2010 +0100 +++ b/src/lmtp/commands.c Mon Jun 07 20:50:08 2010 +0100 @@ -149,7 +149,8 @@ i_error("proxy: Unknown protocol %s", value); return FALSE; } - } else if (strcmp(key, "user") == 0) { + } else if (strcmp(key, "user") == 0 || + strcmp(key, "destuser") == 0) { /* changing the username */ *address = value; } else { @@ -179,8 +180,24 @@ return TRUE; } +static const char * +address_add_detail(struct client *client, const char *username, + const char *detail) +{ + const char *delim = client->set->recipient_delimiter; + const char *domain; + + domain = strchr(username, '@'); + if (domain == NULL) + return t_strconcat(username, delim, detail, NULL); + else { + username = t_strdup_until(username, domain); + return t_strconcat(username, delim, detail, domain, NULL); + } +} + static bool client_proxy_rcpt(struct client *client, const char *address, - const char *username) + const char *username, const char *detail) { struct auth_master_connection *auth_conn; struct lmtp_proxy_settings set; @@ -228,8 +245,13 @@ pool_unref(&pool); return FALSE; } - if (strcmp(username, orig_username) == 0 && - client_proxy_is_ourself(client, &set)) { + if (strcmp(username, orig_username) != 0) { + /* username changed. change the address as well */ + if (*detail == '\0') + address = username; + else + address = address_add_detail(client, username, detail); + } else if (client_proxy_is_ourself(client, &set)) { i_error("Proxying to <%s> loops to itself", username); client_send_line(client, "554 5.4.6 <%s> " "Proxying loops to itself", address); @@ -349,7 +371,7 @@ rcpt_address_parse(client, address, &username, &detail); if (client->lmtp_set->lmtp_proxy) { - if (client_proxy_rcpt(client, address, username)) + if (client_proxy_rcpt(client, address, username, detail)) return 0; }