fetchmail-friends
[Top] [All Lists]

[fetchmail][PATCH] POP3 STLS support

2002-03-07 13:18:30
Howdy,

The following patch adds POP3 STLS support.  I don't know that
the behavior if it fails to setup SSL is correct, so let me know
if you'd like it changed.

Matt

diff -ur fetchmail-5.9.8/pop3.c fetchmail/pop3.c
--- fetchmail-5.9.8/pop3.c      Mon Sep 24 10:48:50 2001
+++ fetchmail/pop3.c    Thu Mar  7 12:00:01 2002
@@ -141,6 +141,9 @@
 #ifdef OPIE_ENABLE
     flag has_otp = FALSE;
 #endif /* OPIE_ENABLE */
+#ifdef SSL_ENABLE
+    flag has_ssl = FALSE;
+#endif /* SSL_ENABLE */
 
 #ifdef SDPS_ENABLE
     /*
@@ -207,6 +210,10 @@
            {
                if (DOTLINE(buffer))
                    break;
+#ifdef SSL_ENABLE
+               if (strstr(buffer, "STLS"))
+                   has_ssl = TRUE;
+#endif /* SSL_ENABLE */
 #if defined(GSSAPI)
                if (strstr(buffer, "GSSAPI"))
                    has_gssapi = TRUE;
@@ -223,6 +230,29 @@
                    has_cram = TRUE;
            }
        }
+
+#ifdef SSL_ENABLE
+       if (has_ssl &&
+#if INET6_ENABLE
+           ctl->server.service && (strcmp(ctl->server.service, "pop3s"))
+#else /* INET6_ENABLE */
+           ctl->server.port != 995
+#endif /* INET6_ENABLE */
+           )
+       {
+           char *realhost;
+
+           realhost = ctl->server.via ? ctl->server.via : ctl->server.pollname;
+           gen_transact(sock, "STLS");
+           if 
(SSLOpen(sock,ctl->sslcert,ctl->sslkey,ctl->sslproto,ctl->sslcertck,
+                       
ctl->sslcertpath,ctl->sslfingerprint,realhost,ctl->server.pollname) == -1)
+           {
+               report(stderr, 
+                      GT_("SSL connection failed.\n"));
+               return(PS_AUTHFAIL);
+           }
+       }
+#endif /* SSL_ENABLE */
 
        /*
         * OK, we have an authentication type now.

Attachment: pgpBllfRpVors.pgp
Description: PGP signature

<Prev in Thread] Current Thread [Next in Thread>
  • [fetchmail][PATCH] POP3 STLS support, Matt Kraai <=