diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2002-09-09 13:43:55 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2002-09-09 13:43:55 +0000 |
commit | 91341f7be66f2865fe4000dae05dd78f448b3ca6 (patch) | |
tree | 23ca050519a599578303e560be32a2a2d1ff8638 | |
parent | dc688e8c7f7165d0019a56c0079df651d704664b (diff) | |
download | fetchmail-91341f7be66f2865fe4000dae05dd78f448b3ca6.tar.gz fetchmail-91341f7be66f2865fe4000dae05dd78f448b3ca6.tar.bz2 fetchmail-91341f7be66f2865fe4000dae05dd78f448b3ca6.zip |
Sunil Shetye's latest fix patch.
svn path=/trunk/; revision=3707
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | driver.c | 48 | ||||
-rw-r--r-- | imap.c | 13 | ||||
-rw-r--r-- | options.c | 2 | ||||
-rw-r--r-- | rcfile_y.y | 3 | ||||
-rw-r--r-- | sink.c | 13 |
6 files changed, 54 insertions, 28 deletions
@@ -3,6 +3,7 @@ (The `lines' figures total .c, .h, .l, and .y files under version control.) * Nerijus Baliunas's patch to support STARTTLS over IMAP. +* More cleanups and minor bugfixes from Sunil Shetye. fetchmail-5.9.14 (Fri Sep 6 05:03:25 EDT 2002), 21932 lines: @@ -49,7 +50,7 @@ fetchmail-5.9.12 (Tue Jun 4 14:57:47 EDT 2002), 21669 lines: * Cygwin port patch from Jason Tishler. * Sunil Shetye's fix for password shrouding. * Various Debian fixes from HMH. -* Arun A Tharuvai's patch to avoid speaking KPOP to an IMAP server. +* Arun A. Tharuvai's patch to avoid speaking KPOP to an IMAP server. * Added Richard Harris's PopDel.py utility to the contrib directory. There are 505 people on fetchmail-friends and 670 on fetchmail-announce. @@ -67,7 +67,7 @@ int stage; /* where are we? */ int phase; /* where are we, for error-logging purposes? */ int batchcount; /* count of messages sent in current batch */ flag peek_capable; /* can we peek for better error recovery? */ -int mailserver_socket_temp; /* socket to free if connect timeout */ +int mailserver_socket_temp = -1; /* socket to free if connect timeout */ static int timeoutcount; /* count consecutive timeouts */ @@ -442,9 +442,7 @@ static int fetch_messages(int mailserver_socket, struct query *ctl, report_build(stdout, GT_(" (length -1)")); break; case MSGLEN_TOOLARGE: - report_build(stdout, - GT_(" (oversized, %d octets)"), - msgsizes[num-1]); + report_build(stdout, GT_(" (oversized)")); break; } } @@ -457,8 +455,8 @@ static int fetch_messages(int mailserver_socket, struct query *ctl, err = (ctl->server.base_protocol->fetch_headers)(mailserver_socket,ctl,num, &len); if (err == PS_TRANSIENT) /* server is probably Exchange */ { - report_build(stdout, - GT_("couldn't fetch headers, message %s@%s:%d (%d octets)"), + report(stdout, + GT_("couldn't fetch headers, message %s@%s:%d (%d octets)\n"), ctl->remotename, ctl->server.truename, num, msgsizes[num-1]); continue; @@ -747,19 +745,12 @@ const int maxfetch; /* maximum number of messages to fetch */ sigprocmask(SIG_UNBLOCK, &allsigs, NULL); #endif /* HAVE_SIGPROCMASK */ - /* If there was a connect timeout, the socket should be closed. - * mailserver_socket_temp contains the socket to close. - */ - mailserver_socket = mailserver_socket_temp; - if (js == THROW_SIGPIPE) { signal(SIGPIPE, SIG_IGN); report(stdout, GT_("SIGPIPE thrown from an MDA or a stream socket error\n")); wait(0); - err = PS_SOCKET; - goto cleanUp; } else if (js == THROW_TIMEOUT) { @@ -808,17 +799,10 @@ const int maxfetch; /* maximum number of messages to fetch */ close_warning_by_mail(ctl, (struct msgblk *)NULL); ctl->wedged = TRUE; } - - err = PS_ERROR; } - /* try to clean up all streams */ - release_sink(ctl); - smtp_close(ctl, 0); - if (mailserver_socket != -1) { - cleanupSockClose(mailserver_socket); - mailserver_socket = -1; - } + err = PS_SOCKET; + goto cleanUp; } else { @@ -1344,8 +1328,10 @@ is restored.")); /* OK, we're going to gather size info next */ xalloca(msgsizes, int *, sizeof(int) * count); xalloca(msgcodes, int *, sizeof(int) * count); - for (i = 0; i < count; i++) + for (i = 0; i < count; i++) { + msgsizes[i] = 0; msgcodes[i] = MSGLEN_UNKNOWN; + } /* * We need the size of each message before it's @@ -1428,7 +1414,21 @@ is restored.")); stage = STAGE_LOGOUT; (ctl->server.base_protocol->logout_cmd)(mailserver_socket, ctl); } - cleanupSockClose(mailserver_socket); + + /* try to clean up all streams */ + release_sink(ctl); + smtp_close(ctl, 0); + if (mailserver_socket != -1) { + cleanupSockClose(mailserver_socket); + mailserver_socket = -1; + } + /* If there was a connect timeout, the socket should be closed. + * mailserver_socket_temp contains the socket to close. + */ + if (mailserver_socket_temp != -1) { + cleanupSockClose(mailserver_socket_temp); + mailserver_socket_temp = -1; + } } msg = (const char *)NULL; /* sacrifice to -Wall */ @@ -712,6 +712,9 @@ static int imap_getsizes(int sock, int count, int *sizes) if ((ok = gen_recv(sock, buf, sizeof(buf)))) return(ok); + /* an untagged NO means that a message was not readable */ + else if (strstr(buf, "* NO")) + ; else if (strstr(buf, "OK") || strstr(buf, "NO")) break; else if (sscanf(buf, "* %u FETCH (RFC822.SIZE %u)", &num, &size) == 2) { @@ -784,9 +787,19 @@ static int imap_fetch_headers(int sock, struct query *ctl,int number,int *lenp) break; /* try to recover from chronically fucked-up M$ Exchange servers */ else if (!strncmp(ptr, "NO", 2)) + { + /* wait for a tagged response */ + if (strstr (buf, "* NO")) + imap_ok (sock, 0); return(PS_TRANSIENT); + } else if (!strncmp(ptr, "BAD", 3)) + { + /* wait for a tagged response */ + if (strstr (buf, "* BAD")) + imap_ok (sock, 0); return(PS_TRANSIENT); + } } if (num != number) @@ -594,7 +594,7 @@ struct query *ctl; /* option record to be initialized */ break; case LA_SSLCERTPATH: - ctl->sslcertpath = xstrdup(optarg); + ctl->sslcertpath = prependdir(optarg, currentwd); break; case LA_SSLFINGERPRINT: @@ -354,7 +354,7 @@ user_option : TO localnames HERE | SSLCERT STRING {current.sslcert = prependdir ($2, rcfiledir);} | SSLPROTO STRING {current.sslproto = xstrdup($2);} | SSLCERTCK {current.sslcertck = FLAG_TRUE;} - | SSLCERTPATH STRING {current.sslcertpath = xstrdup($2);} + | SSLCERTPATH STRING {current.sslcertpath = prependdir($2, rcfiledir);} | SSLFINGERPRINT STRING {current.sslfingerprint = xstrdup($2);} | NO KEEP {current.keep = FLAG_FALSE;} @@ -579,6 +579,7 @@ char *prependdir (const char *file, const char *dir) char *newfile; if (!file[0] || /* null path */ file[0] == '/' || /* absolute path */ + strcmp(file, "-") == 0 || /* stdin/stdout */ !dir[0]) /* we don't HAVE_GETCWD */ return xstrdup (file); newfile = xmalloc (strlen (dir) + 1 + strlen (file) + 1); @@ -694,6 +694,7 @@ static const char *is_quad(const char *q) return NULL; /* Make sure quad is < 255 */ if ( (r-q) == 3) + { if (*q > '2') return NULL; else if (*q == '2') @@ -706,6 +707,7 @@ static const char *is_quad(const char *q) return NULL; } } + } return r; } @@ -1206,7 +1208,13 @@ void release_sink(struct query *ctl) /* release the per-message output sink, whether it's a pipe or SMTP socket */ { if (ctl->bsmtp && sinkfp) - fclose(sinkfp); + { + if (strcmp(ctl->bsmtp, "-")) + { + fclose(sinkfp); + sinkfp = (FILE *)NULL; + } + } else if (ctl->mda) { if (sinkfp) @@ -1251,7 +1259,10 @@ int close_sink(struct query *ctl, struct msgblk *msg, flag forward) fputs(".\r\n", sinkfp); error = ferror(sinkfp); if (strcmp(ctl->bsmtp, "-")) + { if (fclose(sinkfp) == EOF) error = 1; + sinkfp = (FILE *)NULL; + } if (error) { report(stderr, |