[prev in list] [next in list] [prev in thread] [next in thread] 

List:       stunnel-users
Subject:    Patch for POP3 STARTTLS server negotiation
From:       <nathan () 0x00 ! org>
Date:       2001-09-30 17:28:59
[Download RAW message or body]

Hey,
	A simple patch to add support for server negotiation of STARTTLS with POP3.
See attached.

-n

["pop3-stls-server.patch" (TEXT/PLAIN)]

--- protocol.c.orig	Sun Sep 30 13:21:15 2001
+++ protocol.c	Sun Sep 30 13:21:22 2001
@@ -171,8 +171,43 @@
 }
 
 static int pop3_server(int local_rd, int local_wr, int remote) {
-    log(LOG_ERR, "Protocol not supported in server mode");
-    return -1;
+	char line[STRLEN];
+
+	fdscanf(remote, "%[^\n]", line);
+	if(fdprintf(local_wr, "%s + stunnel", line)<0) {
+		return -1;
+	}
+
+	fdscanf(local_wr, "%[^\n]", line);
+
+	if (!strncmp(line, "CAPA", 4)) {
+		if (fdprintf(remote, "CAPA")<0)
+			return -1;
+
+		fdscanf(remote, "%[^\n]", line);
+		if (!strncmp(line, "+OK ", 4) && 0) {
+			if (fdprintf(local_wr, "STLS")<0)
+				return -1;
+			do {
+				fdscanf(remote, "%[^\n]", line);
+				if (fdprintf(local_wr, line)<0)
+					return -1;
+			} while (strncmp(line, ".", 1));
+		} else {
+			if (fdprintf(local_wr, "+OK ")<0 ||
+					fdprintf(local_wr, "STLS")<0 ||
+					fdprintf(local_wr, ".")<0)
+				return -1;
+		}
+		fdscanf(local_wr, "%[^\n]", line);
+	}
+
+	if (strncmp(line, "STLS", 4))
+		return -1;
+	if (fdprintf(local_wr, "+OK ")<0)
+		return -1;
+
+	return 0;
 }
 
 static int nntp_client(int local_rd, int local_wr, int remote) {


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic