changeset 21653:8f374e21547a

lmtp: Fix lmtp_user_concurrency_limit when userdb changes the username Anvil LOOKUP was done with the original username, while CONNECT/DISCONNECT was done with the changed username. So LOOKUP always thought that there were zero concurrent sessions for the user.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Tue, 21 Feb 2017 13:48:36 +0200
parents e04d881da1fb
children 2c937505c112
files src/lmtp/commands.c
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lmtp/commands.c	Tue Feb 21 11:55:55 2017 +0200
+++ b/src/lmtp/commands.c	Tue Feb 21 13:48:36 2017 +0200
@@ -741,9 +741,13 @@
 		(void)cmd_rcpt_finish(client, rcpt);
 		return 0;
 	} else {
+		/* NOTE: username may change as the result of the userdb
+		   lookup. Look up the new one via service_user. */
+		const struct mail_storage_service_input *input =
+			mail_storage_service_user_get_input(rcpt->service_user);
 		const char *query = t_strconcat("LOOKUP\t",
 			master_service_get_name(master_service),
-			"/", str_tabescape(username), NULL);
+			"/", str_tabescape(input->username), NULL);
 		io_remove(&client->io);
 		rcpt->anvil_query = anvil_client_query(anvil, query,
 					rcpt_anvil_lookup_callback, rcpt);