dovecot-2.0: lmtp proxy: Fixed passdb username change.
dovecot at dovecot.org
dovecot at dovecot.org
Mon Jun 7 22:50:11 EEST 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/d2037445feed
changeset: 11495:d2037445feed
user: Timo Sirainen <tss at iki.fi>
date: Mon Jun 07 20:50:08 2010 +0100
description:
lmtp proxy: Fixed passdb username change.
diffstat:
src/lmtp/commands.c | 32 +++++++++++++++++++++++++++-----
1 files changed, 27 insertions(+), 5 deletions(-)
diffs (64 lines):
diff -r 68287c257c0a -r d2037445feed src/lmtp/commands.c
--- 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;
}
More information about the dovecot-cvs
mailing list