From 63ec46b40356c988c698bde7a8ec9f49e60c8cd8 Mon Sep 17 00:00:00 2001
From: "Eric S. Raymond" <esr@thyrsus.com>
Date: Sat, 12 May 2001 06:38:56 +0000
Subject: Fix the double-authentication bug.

svn path=/trunk/; revision=3304
---
 pop3.c | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/pop3.c b/pop3.c
index 93c2516b..771de46a 100644
--- a/pop3.c
+++ b/pop3.c
@@ -241,36 +241,43 @@ static int pop3_getauth(int sock, struct query *ctl, char *greeting)
 	    && (ctl->server.authenticate == A_KERBEROS_V4
 	     || ctl->server.authenticate == A_KERBEROS_V5
 	     || ctl->server.authenticate == A_ANY))
-	    if(ok = do_rfc1731(sock, "AUTH", ctl->server.truename))
-	        if(ctl->server.authenticate != A_ANY)
-                    break;
+	{
+	    ok = do_rfc1731(sock, "AUTH", ctl->server.truename);
+	    if (ok == PS_SUCCESS || ctl->server.authenticate != A_ANY)
+		break;
+	}
 #endif /* defined(KERBEROS_V4) || defined(KERBEROS_V5) */
 
 #if defined(GSSAPI)
 	if (has_gssapi &&
 	    (ctl->server.authenticate == A_GSSAPI ||
 	     ctl->server.authenticate == A_ANY))
-	    if(ok = do_gssauth(sock, "AUTH", 
-			       ctl->server.truename, ctl->remotename))
-	        if(ctl->server.authenticate != A_ANY)
-                    break;
+	{
+	    ok = do_gssauth(sock,"AUTH",ctl->server.truename,ctl->remotename);
+	    if (ok == PS_SUCCESS || ctl->server.authenticate != A_ANY)
+		break;
+	}
 #endif /* defined(GSSAPI) */
 
 #ifdef OPIE_ENABLE
 	if (has_otp &&
 	    (ctl->server.authenticate == A_OTP ||
 	     ctl->server.authenticate == A_ANY))
-	    if(ok = do_otp(sock, "AUTH", ctl))
-	        if(ctl->server.authenticate != A_ANY)
-                    break;
+	{
+	    ok = do_otp(sock, "AUTH", ctl);
+	    if (ok == PS_SUCCESS || ctl->server.authenticate != A_ANY)
+		break;
+	}
 #endif /* OPIE_ENABLE */
 
 	if (has_cram &&
 	    (ctl->server.authenticate == A_CRAM_MD5 ||
 	     ctl->server.authenticate == A_ANY))
-	    if(ok = do_cram_md5(sock, "AUTH", ctl))
-	        if(ctl->server.authenticate != A_ANY)
-                    break;
+	{
+	    ok = do_cram_md5(sock, "AUTH", ctl);
+	    if (ok == PS_SUCCESS || ctl->server.authenticate != A_ANY)
+		break;
+	}
 
 	/* ordinary validation, no one-time password or RPA */ 
 	gen_transact(sock, "USER %s", ctl->remotename);
-- 
cgit v1.2.3