]> Pileus Git - ~andy/fetchmail/blobdiff - pop3.c
Minor cleanup patches.
[~andy/fetchmail] / pop3.c
diff --git a/pop3.c b/pop3.c
index c5b6d58c09ebcf552c4177752d9cdf7a76d9493b..718c09c8b52ffc6849b8791c676dc5db543cb09d 100644 (file)
--- a/pop3.c
+++ b/pop3.c
@@ -41,7 +41,7 @@ static char lastok[POPBUFSIZE+1];
 
 #define DOTLINE(s)     (s[0] == '.' && (s[1]=='\r'||s[1]=='\n'||s[1]=='\0'))
 
-int pop3_ok (int sock, char *argbuf)
+static int pop3_ok (int sock, char *argbuf)
 /* parse command response */
 {
     int ok;
@@ -49,8 +49,7 @@ int pop3_ok (int sock, char *argbuf)
     char *bufp;
 
     if ((ok = gen_recv(sock, buf, sizeof(buf))) == 0)
-    {
-       bufp = buf;
+    {  bufp = buf;
        if (*bufp == '+' || *bufp == '-')
            bufp++;
        else
@@ -99,6 +98,10 @@ int pop3_ok (int sock, char *argbuf)
                     /* these are blessed by RFC 2449 */
                     || strstr(bufp,"[IN-USE]")||strstr(bufp,"[LOGIN-DELAY]"))
                ok = PS_LOCKBUSY;
+           else if ((strstr(bufp,"Service")
+                    || strstr(bufp,"service"))
+                        && (strstr(bufp,"unavailable")))
+               ok = PS_SERVBUSY;
            else
                ok = PS_AUTHFAIL;
            /*
@@ -119,7 +122,7 @@ int pop3_ok (int sock, char *argbuf)
     return(ok);
 }
 
-int pop3_getauth(int sock, struct query *ctl, char *greeting)
+static int pop3_getauth(int sock, struct query *ctl, char *greeting)
 /* apply for connection authorization */
 {
     int ok;
@@ -195,7 +198,7 @@ int pop3_getauth(int sock, struct query *ctl, char *greeting)
 #endif /* defined(KERBEROS_V4) || defined(KERBEROS_V5) */
            flag has_cram = FALSE;
 #ifdef OPIE_ENABLE
-           flag has_opie = FALSE;
+           flag has_otp = FALSE;
 #endif /* OPIE_ENABLE */
            char buffer[64];
 
@@ -227,7 +230,7 @@ int pop3_getauth(int sock, struct query *ctl, char *greeting)
            if (has_cram)
                ctl->server.authenticate = A_CRAM_MD5;
 #ifdef OPIE_ENABLE
-           if (has_opie)
+           if (has_otp)
                ctl->server.authenticate = A_OTP;
 #endif /* OPIE_ENABLE */
 #if defined(GSSAPI)
@@ -244,25 +247,37 @@ int pop3_getauth(int sock, struct query *ctl, char *greeting)
         * OK, we have an authentication type now.
         */
 #if defined(KERBEROS_V4) || defined(KERBEROS_V5)
-       if (ctl->server.authenticate == A_KERBEROS_V4
-               || ctl->server.authenticate == A_KERBEROS_V5)
+       /* 
+        * Servers doing KPOP have to go through a dummy login sequence
+        * rather than doing SASL.
+        */
+       if (
+#if INET6_ENABLE
+           ctl->server.service && (strcmp(ctl->server.service, KPOP_PORT)!=0)
+#else /* INET6_ENABLE */
+           ctl->server.port != KPOP_PORT
+#endif /* INET6_ENABLE */
+           && (ctl->server.authenticate == A_KERBEROS_V4
+            || ctl->server.authenticate == A_KERBEROS_V5))
            return(do_rfc1731(sock, "AUTH", ctl->server.truename));
 #endif /* defined(KERBEROS_V4) || defined(KERBEROS_V5) */
 #if defined(GSSAPI)
-       if (ctl->server.authenticate==A_GSSAPI))
+       if (ctl->server.authenticate==A_GSSAPI)
            return(do_gssauth(sock, "AUTH", 
                              ctl->server.truename, ctl->remotename));
 #endif /* defined(GSSAPI) */
 #ifdef OPIE_ENABLE
        if (ctl->server.authenticate == A_OTP)
-           do_otp(sock, "AUTH", ctl)
+           do_otp(sock, "AUTH", ctl);
 #endif /* OPIE_ENABLE */
        if (ctl->server.authenticate == A_CRAM_MD5)
            return(do_cram_md5(sock, "AUTH", ctl));
 
        /* ordinary validation, no one-time password or RPA */ 
        gen_transact(sock, "USER %s", ctl->remotename);
+       strcpy(shroud, ctl->password);
        ok = gen_transact(sock, "PASS %s", ctl->password);
+       shroud[0] = '\0';
        break;
 
     case P_APOP:
@@ -332,8 +347,7 @@ int pop3_getauth(int sock, struct query *ctl, char *greeting)
     return(PS_SUCCESS);
 }
 
-static int
-pop3_gettopid( int sock, int num , char *id)
+static int pop3_gettopid( int sock, int num , char *id)
 {
     int ok;
     int got_it;
@@ -356,8 +370,7 @@ pop3_gettopid( int sock, int num , char *id)
     return 0;
 }
 
-static int
-pop3_slowuidl( int sock,  struct query *ctl, int *countp, int *newp)
+static int pop3_slowuidl( int sock,  struct query *ctl, int *countp, int *newp)
 {
     /* This approach tries to get the message headers from the
      * remote hosts and compares the message-id to the already known
@@ -718,7 +731,6 @@ const static struct method pop3 =
     FALSE,             /* this is not a tagged protocol */
     TRUE,              /* this uses a message delimiter */
     pop3_ok,           /* parse command response */
-    NULL,              /* no password canonicalization */
     pop3_getauth,      /* get authorization */
     pop3_getrange,     /* query range of messages */
     pop3_getsizes,     /* we can get a list of sizes */