From 5dc68d27d1e979147642d4682044751f029b817c Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 13 Oct 1996 03:19:51 +0000 Subject: [PATCH] Fixes for UIDL and Kerberos problems. svn path=/trunk/; revision=319 --- Makefile.in | 2 +- NEWS | 14 -------------- README | 22 ++++++---------------- driver.c | 2 +- fetchmail.h | 1 + pop3.c | 28 ++++++++-------------------- rcfile_y.y | 2 +- sample.rcfile | 1 - uid.c | 16 +++++++++++++++- 9 files changed, 33 insertions(+), 55 deletions(-) diff --git a/Makefile.in b/Makefile.in index b3e85b31..a180b817 100644 --- a/Makefile.in +++ b/Makefile.in @@ -158,7 +158,7 @@ $(mandir)/$(instname).$(manext): fetchmail.man $(INSTALL_DATA) $(srcdir)/fetchmail.man $@ fetchmail.spec: Makefile.in - specgen.sh $(VERS) >fetchmail.spec + $(srcdir)/specgen.sh $(VERS) >fetchmail.spec .PHONY: clean realclean distclean mostlyclean clean: diff --git a/NEWS b/NEWS index fb9866b0..537dfe4a 100644 --- a/NEWS +++ b/NEWS @@ -1,17 +1,3 @@ ------------------------------------------------------------------------------ - * * * WARNING * * * - -This release contains untested features! It includes new code for Kerberos -authentication and POP3 UID support, but my integration of these features -required changes which have not yet been tested by the people who sent the -enhancements. - -I'm issuing it to put paid to two minor but annoying bugs, in option -processing and IMAP queries of multiple sites. For other changes, see -below. - ------------------------------------------------------------------------------ - Release Notes: fetchmail-1.8 (Fri Oct 11 15:08:10 EDT 1996): diff --git a/README b/README index e75593a5..35ee9746 100644 --- a/README +++ b/README @@ -1,19 +1,5 @@ fetchmail README ------------------------------------------------------------------------------ - * * * WARNING * * * - -This release contains untested features! It includes new code for Kerberos -authentication and POP3 UID support, but my integration of these features -required changes which have not yet been tested by the people who sent the -enhancements. - -I'm issuing it to put paid to two minor but annoying bugs, in option -processing and IMAP queries of multiple sites. For other changes, see -the release notes in the NEWS file. - ------------------------------------------------------------------------------ - fetchmail is a full-featured, robust, well-documented POP2, POP3, APOP, and IMAP batch mail retrieval/forwarding utility intended to be used over on-demand TCP/IP links (such as SLIP or PPP connections). @@ -79,7 +65,7 @@ with **. You could use fetchmail to test and debug server implementatations. * Carefully written, comprehensive and up-to-date man page describing - not only modes of operation but also (**) how to interpret the most + not only modes of operation but also (**) how to diagnose the most common kinds of problems and what to do about deficient servers * Rugged, simple, and well-tested code -- the author relies on it @@ -90,7 +76,11 @@ with **. user base from Carl Harris's popclient community. This means feedback is rapid, bugs get found and fixed rapidly. -You can easily find the latest version of fetchmail from Eric's home page: +You can easily fetch the latest version of fetchmail via FTP from: + + ftp://ftp.ccil.org/pub/esr/fetchmail-1.9.tar.gz + +Or you can get it from Eric's home page: http://www.ccil.org/~esr diff --git a/driver.c b/driver.c index 5987ed4e..9fb1e69f 100644 --- a/driver.c +++ b/driver.c @@ -628,7 +628,7 @@ struct method *proto; } #ifdef KERBEROS_V4 - if (queryctl->authentication == A_KERBEROS) + if (queryctl->authenticate == A_KERBEROS) { ok = (kerberos_auth (socket, queryctl->servername)); if (ok != 0) diff --git a/fetchmail.h b/fetchmail.h index 82471678..24d8d0ab 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -149,6 +149,7 @@ void save_uid(struct idlist **, int, char *); void free_uid_list(struct idlist **); int delete_uid(struct idlist **, int); int uid_in_list(struct idlist **, char *); +char *uid_find(struct idlist **, int); void update_uid_lists(struct hostrec *); void write_saved_lists(struct hostrec *, char *); diff --git a/pop3.c b/pop3.c index 5c5eed11..92089e0e 100644 --- a/pop3.c +++ b/pop3.c @@ -129,6 +129,9 @@ int *countp; int ok; char buf [POPBUFSIZE+1]; + /* Ensure that the new list is properly empty */ + queryctl->newsaved = (struct idlist *)NULL; + /* get the total message count */ gen_send(socket, "STAT"); ok = pop3_ok(socket, buf); @@ -158,14 +161,14 @@ int *countp; /* grab the mailbox's UID list */ gen_send(socket, "UIDL"); - if ((ok = pop3_ok(buf, socket)) == 0) { + if ((ok = pop3_ok(socket, buf)) == 0) { while (SockGets(socket, buf, sizeof(buf)) >= 0) { if (outlevel == O_VERBOSE) fprintf(stderr,"%s\n",buf); - if (strcmp(buf, ".\n") == 0) { + if (strcmp(buf, ".") == 0) { break; } - if (sscanf(buf, "%d %s\n", &num, id) == 2) + if (sscanf(buf, "%d %s", &num, id) == 2) save_uid(&queryctl->newsaved, num, id); } } @@ -183,23 +186,8 @@ int num; if (!queryctl->oldsaved) return (num <= last); else - { - char buf [POPBUFSIZE+1]; - int ok; - - gen_send(socket, "UIDL %d", num); - if ((ok = pop3_ok(socket, buf)) != 0) - return(ok); - else - { - char id[IDLEN+1]; - - if (sscanf(buf, "%*d %s", id) == 2) - return(uid_in_list(&queryctl->oldsaved, id)); - else - return(0); - } - } + return (uid_in_list(&queryctl->oldsaved, + uid_find (&queryctl->newsaved, num))); } static int pop3_fetch(socket, number, lenp) diff --git a/rcfile_y.y b/rcfile_y.y index 90a9f474..b3650880 100644 --- a/rcfile_y.y +++ b/rcfile_y.y @@ -68,7 +68,7 @@ serv_option : PROTOCOL PROTO {prc_setproto($2);} prc_setauth(A_KERBEROS); prc_setport(KPOP_PORT); } - | PORT STRING {prc_setport($2);} + | PORT STRING {prc_setport(atoi($2));} | SKIP {prc_setskip($1==FLAG_TRUE);} | AUTHENTICATE PASSWORD {prc_setauth(A_PASSWORD);} | AUTHENTICATE KERBEROS {prc_setauth(A_KERBEROS);} diff --git a/sample.rcfile b/sample.rcfile index e2f5663a..42ad1362 100644 --- a/sample.rcfile +++ b/sample.rcfile @@ -28,7 +28,6 @@ # is # remotefolder (or remote) # password (or pass) -# mailbox # smtphost (or smtp) # mda # keep diff --git a/uid.c b/uid.c index eb87d4dc..186d4b35 100644 --- a/uid.c +++ b/uid.c @@ -140,7 +140,7 @@ int uid_in_list(idl, str) struct idlist **idl; char *str; { - if (*idl == (struct idlist *)NULL) + if (*idl == (struct idlist *)NULL || str == (char *) NULL) return(0); else if (strcmp(str, (*idl)->id) == 0) return(1); @@ -148,6 +148,19 @@ char *str; return(uid_in_list(&(*idl)->next, str)); } +char *uid_find(idl, number) +/* return the id of the given number in the given list. */ +struct idlist **idl; +int number; +{ + if (*idl == (struct idlist *) 0) + return((char *) 0); + else if (number == (*idl)->num) + return((*idl)->id); + else + return(uid_find(&(*idl)->next, number)); +} + int delete_uid(idl, num) /* delete given message from given list */ struct idlist **idl; @@ -175,6 +188,7 @@ struct hostrec *hostp; { free_uid_list(&hostp->oldsaved); hostp->oldsaved = hostp->newsaved; + hostp->newsaved = (struct idlist *) NULL; } void write_saved_lists(hostlist, idfile) -- 2.43.2