From 93da967641535fd51178d3b43fd49a8cfb59a1ad Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 2 Oct 1997 20:49:28 +0000 Subject: Apply Wolf Schmidt's fixes to the RPA dialogue. svn path=/trunk/; revision=1468 --- pop3.c | 77 ++++++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 42 insertions(+), 35 deletions(-) diff --git a/pop3.c b/pop3.c index 356feb36..9e6fe993 100644 --- a/pop3.c +++ b/pop3.c @@ -100,12 +100,50 @@ int pop3_getauth(int sock, struct query *ctl, char *greeting) switch (ctl->server.protocol) { case P_POP3: - if ((ok = gen_transact(sock, "USER %s", ctl->remotename)) != 0) - break; + ok = gen_transact(sock, "USER %s", ctl->remotename); + + if (ok != 0) +#ifdef RPA_ENABLE + /* if CompuServe rejected our userid, try RPA */ + if (strstr(greeting, "csi.com")) + { + /* AUTH command should return a list of available mechanisms */ + if (gen_transact(sock, "AUTH") == 0) + { + char buffer[10]; + flag has_rpa = FALSE; + flag authenticated = FALSE; + + while ((ok = gen_recv(sock, buffer, sizeof(buffer))) == 0) + { + + if (buffer[0] == '.') + break; + if (strncasecmp(buffer, "rpa", 3) == 0) + has_rpa = TRUE; + } + if(has_rpa) { + if (POP3_auth_rpa(ctl->remotename, + ctl->password, sock) == PS_SUCCESS) + { + authenticated = TRUE; + break; + } + } + if (authenticated) { + /* we could return(PS_SUCCESS) here */ + ok = PS_SUCCESS; + break; + } + } + } + else /* not a CompuServe host, fail in the ordinary way */ +#endif /* RPA_ENABLE */ + break; #if defined(HAVE_LIBOPIE) && defined(OPIE_ENABLE) /* see RFC1938: A One-Time Password System */ - if (challenge = strstr(greeting, "otp-")) + if (challenge = strstr(lastok, "otp-")) { char response[OPIE_RESPONSE_MAX+1]; @@ -120,37 +158,6 @@ int pop3_getauth(int sock, struct query *ctl, char *greeting) } #endif /* defined(HAVE_LIBOPIE) && defined(OPIE_ENABLE) */ -#ifdef ENABLE_RPA - /* if we're talking to CompuServe, try RPA */ - if (strstr(greeting, "csi.com")) - { - /* AUTH command should return a list of available mechanisms */ - if (gen_transact(sock, "AUTH") == 0) - { - char buffer[10]; - flag authenticated = FALSE; - - while ((ok = gen_recv(sock, buffer, sizeof(buffer))) == 0) - { - if (buffer[0] == '.') - break; - if (strncasecmp(buffer, "rpa", 3) == 0) - { - if (POP3_auth_rpa(ctl->remotename, - ctl->password, sock) == PS_SUCCEED) - { - authenticated = TRUE; - break; - } - } - } - - if (authenticated) - break; - } - } -#endif /* ENABLE_RPA */ - /* ordinary validation, no one-time password or RPA */ ok = gen_transact(sock, "PASS %s", ctl->password); break; @@ -216,7 +223,7 @@ int pop3_getauth(int sock, struct query *ctl, char *greeting) sleep(3); /* to be _really_ safe, probably need sleep(5)! */ /* we're approved */ - return(0); + return(PS_SUCCESS); } static int -- cgit v1.2.3