aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1997-12-01 06:32:59 +0000
committerEric S. Raymond <esr@thyrsus.com>1997-12-01 06:32:59 +0000
commit68834c0eb81a1478b9eade24e57c0c3f89570b16 (patch)
tree747c77e893b86c78dc2ac177ca4f876f565dfc59
parent763db6c239904dcec27afd088e15640e99fa84cf (diff)
downloadfetchmail-68834c0eb81a1478b9eade24e57c0c3f89570b16.tar.gz
fetchmail-68834c0eb81a1478b9eade24e57c0c3f89570b16.tar.bz2
fetchmail-68834c0eb81a1478b9eade24e57c0c3f89570b16.zip
Better POP3 error messages.
svn path=/trunk/; revision=1550
-rw-r--r--NEWS1
-rw-r--r--pop3.c23
2 files changed, 22 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 396d88aa..00bdedd9 100644
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,7 @@ fetchmail-4.3.4 (Sat Nov 22 01:51:41 EST 1997)
* Allow `--quit' to be given with other options to shut down a running daemon
before anything else gets done (suggested by Greg Stark).
* Added Gordon Matzigkeit's warning about -F to the man page.
+* Improved POP3 protocol-synchronization error messages.
There are 277 people on fetchmail-friends and 92 on fetchmail-announce.
diff --git a/pop3.c b/pop3.c
index 152d86c3..ce9d7999 100644
--- a/pop3.c
+++ b/pop3.c
@@ -27,6 +27,12 @@
extern char *strstr(); /* needed on sysV68 R3V7.1. */
#endif /* strstr */
+static int phase;
+#define PHASE_GETAUTH 0
+#define PHASE_GETRANGE 1
+#define PHASE_GETSIZES 2
+#define PHASE_FETCH 3
+#define PHASE_LOGOUT 4
static int last;
#if HAVE_LIBOPIE
@@ -63,6 +69,8 @@ int pop3_ok (int sock, char *argbuf)
}
else if (strcmp(buf,"-ERR") == 0)
{
+ if (phase > PHASE_GETAUTH)
+ ok = PS_PROTOCOL;
/*
* We're checking for "lock busy", "unable to lock",
* "already locked" etc. here. This indicates that we
@@ -73,7 +81,7 @@ int pop3_ok (int sock, char *argbuf)
* versions the Berkeley popper; QPOP (version 2.2) and
* QUALCOMM Pop server derived from UCB (version 2.1.4-R3)
*/
- if (strstr(bufp,"lock")||strstr(bufp,"Lock")||strstr(bufp,"LOCK"))
+ else if (strstr(bufp,"lock")||strstr(bufp,"Lock")||strstr(bufp,"LOCK"))
ok = PS_LOCKBUSY;
else
ok = PS_AUTHFAIL;
@@ -100,6 +108,8 @@ int pop3_getauth(int sock, struct query *ctl, char *greeting)
char *challenge;
#endif /* HAVE_LIBOPIE */
+ phase = PHASE_GETAUTH;
+
switch (ctl->server.protocol) {
case P_POP3:
ok = gen_transact(sock, "USER %s", ctl->remotename);
@@ -339,6 +349,8 @@ static int pop3_getrange(int sock,
int ok;
char buf [POPBUFSIZE+1];
+ phase = PHASE_GETRANGE;
+
/* Ensure that the new list is properly empty */
ctl->newsaved = (struct idlist *)NULL;
@@ -424,6 +436,8 @@ static int pop3_getsizes(int sock, int count, int *sizes)
{
int ok;
+ /* phase = PHASE_GETSIZES */
+
if ((ok = gen_transact(sock, "LIST")) != 0)
return(ok);
else
@@ -461,6 +475,8 @@ static int pop3_fetch(int sock, struct query *ctl, int number, int *lenp)
int ok;
char buf [POPBUFSIZE+1];
+ /* phase = PHASE_FETCH */
+
gen_send(sock, "RETR %d", number);
if ((ok = pop3_ok(sock, buf)) != 0)
return(ok);
@@ -480,8 +496,11 @@ static int pop3_delete(int sock, struct query *ctl, int number)
static int pop3_logout(int sock, struct query *ctl)
/* send logout command */
{
- int ok = gen_transact(sock, "QUIT");
+ int ok;
+
+ /* phase = PHASE_LOGOUT */
+ ok = gen_transact(sock, "QUIT");
if (!ok)
expunge_uids(ctl);