[dovecot-cvs] dovecot/src/pop3-login pop3-proxy.c,1.3,1.4

cras at dovecot.org cras at dovecot.org
Wed Oct 20 16:49:07 EEST 2004


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

Modified Files:
	pop3-proxy.c 
Log Message:
Use USER/PASS instad for AUTH PLAIN. Also don't require "+OK" to have
parameters.



Index: pop3-proxy.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/pop3-login/pop3-proxy.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- pop3-proxy.c	19 Oct 2004 15:47:45 -0000	1.3
+++ pop3-proxy.c	20 Oct 2004 13:49:04 -0000	1.4
@@ -14,7 +14,7 @@
 			void *context)
 {
 	struct pop3_client *client = context;
-	string_t *auth, *str;
+	string_t *str;
 	const char *line;
 
 	if (input == NULL) {
@@ -48,7 +48,7 @@
 
 	if (client->proxy_user != NULL) {
 		/* this is a banner */
-		if (strncmp(line, "+OK ", 4) != 0) {
+		if (strncmp(line, "+OK", 3) != 0) {
 			i_error("pop3-proxy(%s): "
 				"Remote returned invalid banner: %s",
 				client->common.virtual_user, line);
@@ -56,39 +56,44 @@
 			return;
 		}
 
-		/* send AUTH command */
-		auth = t_str_new(128);
-		str_append_c(auth, '\0');
-		str_append(auth, client->proxy_user);
-		str_append_c(auth, '\0');
-		str_append(auth, client->proxy_password);
-
+		/* send USER command */
 		str = t_str_new(128);
-		str_append(str, "AUTH PLAIN ");
-		base64_encode(str_data(auth), str_len(auth), str);
+		str_append(str, "USER ");
+		str_append(str, client->proxy_user);
 		str_append(str, "\r\n");
 		(void)o_stream_send(output, str_data(str), str_len(str));
 
-		safe_memset(client->proxy_password, 0,
-			    strlen(client->proxy_password));
 		i_free(client->proxy_user);
-		i_free(client->proxy_password);
 		client->proxy_user = NULL;
-		client->proxy_password = NULL;
-	} else if (strncmp(line, "+OK ", 4) == 0) {
-		/* Login successful. Send this line to client. */
-		(void)o_stream_send_str(client->output, line);
-		(void)o_stream_send(client->output, "\r\n", 2);
+	} 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));
 
-		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;
+		} 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);
 
-		client->proxy = NULL;
-		client->input = NULL;
-		client->output = NULL;
-		client->common.fd = -1;
-		client_destroy(client, t_strconcat(
-			"Proxy: ", client->common.virtual_user, NULL));
+			login_proxy_detach(client->proxy, client->input,
+					   client->output);
+
+			client->proxy = NULL;
+			client->input = NULL;
+			client->output = NULL;
+			client->common.fd = -1;
+			client_destroy(client, t_strconcat(
+				"Proxy: ", client->common.virtual_user, NULL));
+		}
 	} else {
 		/* Login failed. Send our own failure reply so client can't
 		   figure out if user exists or not just by looking at the



More information about the dovecot-cvs mailing list