[dovecot-cvs] dovecot/src/pop3-login client.h, 1.15, 1.16 pop3-proxy.c, 1.5, 1.6

cras at dovecot.org cras at dovecot.org
Wed Oct 27 17:20:24 EEST 2004


Update of /var/lib/cvs/dovecot/src/pop3-login
In directory talvi:/tmp/cvs-serv1759/pop3-login

Modified Files:
	client.h pop3-proxy.c 
Log Message:
Keep proxy_user stored until proxy is destroyed.



Index: client.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/pop3-login/client.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- client.h	18 Oct 2004 23:07:02 -0000	1.15
+++ client.h	27 Oct 2004 14:20:21 -0000	1.16
@@ -18,6 +18,7 @@
 
 	struct login_proxy *proxy;
 	char *proxy_user, *proxy_password;
+	int proxy_state;
 
 	time_t last_input;
 	unsigned int bad_counter;

Index: pop3-proxy.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/pop3-login/pop3-proxy.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- pop3-proxy.c	20 Oct 2004 13:59:34 -0000	1.5
+++ pop3-proxy.c	27 Oct 2004 14:20:21 -0000	1.6
@@ -46,7 +46,8 @@
 	if (line == NULL)
 		return;
 
-	if (client->proxy_user != NULL) {
+	switch (client->proxy_state) {
+	case 0:
 		/* this is a banner */
 		if (strncmp(line, "+OK", 3) != 0) {
 			i_error("pop3-proxy(%s): "
@@ -63,52 +64,67 @@
 		str_append(str, "\r\n");
 		(void)o_stream_send(output, str_data(str), str_len(str));
 
-		i_free(client->proxy_user);
-		client->proxy_user = NULL;
-	} else if (strncmp(line, "+OK", 3) == 0) {
-		if (client->proxy_password != NULL) {
-			/* USER successful, send PASS */
-			str = t_str_new(128);
-			str_append(str, "PASS ");
-			str_append(str, client->proxy_password);
-			str_append(str, "\r\n");
-			(void)o_stream_send(output, str_data(str),
-					    str_len(str));
+		client->proxy_state++;
+		return;
+	case 1:
+		if (strncmp(line, "+OK", 3) != 0)
+			break;
 
-			safe_memset(client->proxy_password, 0,
-				    strlen(client->proxy_password));
-			i_free(client->proxy_password);
-			client->proxy_password = NULL;
-		} else {
-			/* Login successful. Send this line to client. */
-			(void)o_stream_send_str(client->output, line);
-			(void)o_stream_send(client->output, "\r\n", 2);
+		/* USER successful, send PASS */
+		str = t_str_new(128);
+		str_append(str, "PASS ");
+		str_append(str, client->proxy_password);
+		str_append(str, "\r\n");
+		(void)o_stream_send(output, str_data(str),
+				    str_len(str));
 
-			login_proxy_detach(client->proxy, client->input,
-					   client->output);
+		safe_memset(client->proxy_password, 0,
+			    strlen(client->proxy_password));
+		i_free(client->proxy_password);
+		client->proxy_password = NULL;
 
-			client->proxy = NULL;
-			client->input = NULL;
-			client->output = NULL;
-			client->common.fd = -1;
-			client_destroy(client,
-				t_strdup_printf("proxy(%s): started",
-						client->common.virtual_user));
-		}
-	} else {
-		/* Login failed. Send our own failure reply so client can't
-		   figure out if user exists or not just by looking at the
-		   reply string. */
-		client_send_line(client, "-ERR "AUTH_FAILED_MSG);
+		client->proxy_state++;
+		return;
+	case 2:
+		/* Login successful. Send this line to client. */
+		(void)o_stream_send_str(client->output, line);
+		(void)o_stream_send(client->output, "\r\n", 2);
 
-		/* allow client input again */
-		i_assert(client->io == NULL);
-		client->io = io_add(client->common.fd, IO_READ,
-				    client_input, client);
+		login_proxy_detach(client->proxy, client->input,
+				   client->output);
 
-		login_proxy_free(client->proxy);
 		client->proxy = NULL;
+		client->input = NULL;
+		client->output = NULL;
+		client->common.fd = -1;
+		client_destroy(client,
+			       t_strdup_printf("proxy(%s): started",
+					       client->common.virtual_user));
+		return;
 	}
+
+	/* Login failed. Send our own failure reply so client can't
+	   figure out if user exists or not just by looking at the
+	   reply string. */
+	client_send_line(client, "-ERR "AUTH_FAILED_MSG);
+
+	/* allow client input again */
+	i_assert(client->io == NULL);
+	client->io = io_add(client->common.fd, IO_READ,
+			    client_input, client);
+
+	login_proxy_free(client->proxy);
+	client->proxy = NULL;
+
+	if (client->proxy_password != NULL) {
+		safe_memset(client->proxy_password, 0,
+			    strlen(client->proxy_password));
+		i_free(client->proxy_password);
+		client->proxy_password = NULL;
+	}
+
+	i_free(client->proxy_user);
+	client->proxy_user = NULL;
 }
 
 int pop3_proxy_new(struct pop3_client *client, const char *host,
@@ -127,6 +143,7 @@
 	if (client->proxy == NULL)
 		return -1;
 
+	client->proxy_state = 0;
 	client->proxy_user = i_strdup(user);
 	client->proxy_password = i_strdup(password);
 



More information about the dovecot-cvs mailing list