int pass; /* how many times have we re-polled? */
int stage; /* where are we? */
int phase; /* where are we, for error-logging purposes? */
+int mytimeout; /* value of nonreponse timeout */
static const struct method *protocol;
static jmp_buf restart;
#define GENSYM (sprintf(tag, "A%04d", ++tagnum % TAGMOD), tag)
static char shroud[PASSWORDLEN]; /* string to shroud in debug output */
-static int mytimeout; /* value of nonreponse timeout */
static int timeoutcount; /* count consecutive timeouts */
static int msglen; /* actual message length */
sizeticker += linelen;
while (sizeticker >= SIZETICKER)
{
- if (!run.use_syslog)
+ if (!run.use_syslog && isatty(1))
{
fputc('.', stdout);
fflush(stdout);
else if (!strncasecmp("Resent-Sender:", line, 14))
resent_sender_offs = (line - msgblk.headers);
- else if (!strncasecmp("Message-Id:", buf, 11))
+#ifdef __UNUSED__
+ else if (!strncasecmp("Message-Id:", line, 11))
{
if (ctl->server.uidl)
{
char id[IDLEN+1];
- buf[IDLEN+12] = 0; /* prevent stack overflow */
- sscanf(buf+12, "%s", id);
+ line[IDLEN+12] = 0; /* prevent stack overflow */
+ sscanf(line+12, "%s", id);
if (!str_find( &ctl->newsaved, num))
{
struct idlist *new = save_str(&ctl->newsaved,id,UID_SEEN);
}
}
}
+#endif /* __UNUSED__ */
else if (!MULTIDROP(ctl))
continue;
free_str_list(&msgblk.recipients);
return(PS_IOERR);
}
- else if ((run.poll_interval == 0 || nodetach) && outlevel >= O_VERBOSE)
+ else if ((run.poll_interval == 0 || nodetach) && outlevel >= O_VERBOSE && isatty(2))
fputs("#", stderr);
/* write error notifications */
sizeticker += linelen;
while (sizeticker >= SIZETICKER)
{
- if ((run.poll_interval == 0 || nodetach) && outlevel > O_SILENT)
+ if ((run.poll_interval == 0 || nodetach) && outlevel > O_SILENT && isatty(1))
{
fputc('.', stdout);
fflush(stdout);
release_sink(ctl);
return(PS_IOERR);
}
- else if (outlevel >= O_VERBOSE)
+ else if (outlevel >= O_VERBOSE && isatty(1))
{
fputc('*', stdout);
fflush(stdout);
nbr = current->val.status.mark;
size = atoi(current->id);
stuff_warning(ctl,
- _("\t%d msg %d octets long skipped by fetchmail.\n"),
+ _("\t%d msg %d octets long skipped by fetchmail.\r\n"),
nbr, size);
}
current->val.status.num++;
if (js == THROW_SIGPIPE)
{
report(stdout,
- _("SIGPIPE thrown from an MDA or a stream socket error"));
+ _("SIGPIPE thrown from an MDA or a stream socket error\n"));
ok = PS_SOCKET;
+ goto cleanUp;
}
else if (js == THROW_TIMEOUT)
{
ctl->mda ? "MDA" : "SMTP");
else if (phase == LISTENER_WAIT)
report(stdout,
- _("timeout after %d seconds waiting for listener to respond.\n"));
+ _("timeout after %d seconds waiting for listener to respond.\n"), ctl->server.timeout);
else
report(stdout,
_("timeout after %d seconds.\n"), ctl->server.timeout);
/*
* If we've exceeded our threshold for consecutive timeouts,
* try to notify the user, then mark the connection wedged.
+ * Don't do this if the connection can idle, though; idle
+ * timeouts just mean the frequency of mail is low.
*/
if (timeoutcount > MAX_TIMEOUTS
&& !open_warning_by_mail(ctl, (struct msgblk *)NULL))
}
else
{
- char buf[POPBUFSIZE+1], *realhost;
+ char buf[MSGBUFSIZE+1], *realhost;
int len, num, count, new, bytes, deletions = 0, *msgsizes = NULL;
#if INET6_ENABLE
int fetches, dispatches, oldphase;
if ((mailserver_socket = SockOpen(realhost, port, NULL, ctl->server.plugin)) == -1)
#endif /* INET6_ENABLE */
{
+ char errbuf[BUFSIZ];
#if !INET6_ENABLE
int err_no = errno;
#ifdef HAVE_RES_SEARCH
* in daemon mode but the connection to the outside world
* is down.
*/
- if (!(err_no == EHOSTUNREACH && run.poll_interval))
+ if (!((err_no == EHOSTUNREACH || err_no == ENETUNREACH)
+ && run.poll_interval))
{
report_build(stderr, _("fetchmail: %s connection to %s failed"),
protocol->name, ctl->server.pollname);
if (h_errno != 0)
{
if (h_errno == HOST_NOT_FOUND)
- report_complete(stderr,
- _(": host is unknown\n"));
+ strcpy(errbuf, _("host is unknown."));
else if (h_errno == NO_ADDRESS)
- report_complete(stderr,
- _(": name is valid but has no IP address\n"));
+ strcpy(errbuf, _("name is valid but has no IP address."));
else if (h_errno == NO_RECOVERY)
- report_complete(stderr,
- _(": unrecoverable name server error\n"));
+ strcpy(errbuf, _("unrecoverable name server error."));
else if (h_errno == TRY_AGAIN)
- report_complete(stderr,
- _(": temporary name server error\n"));
+ strcpy(errbuf, _("temporary name server error."));
else
- report_complete(stderr,
- _(": unknown DNS error %d\n"), h_errno);
+ sprintf(errbuf, _("unknown DNS error %d."), h_errno);
}
else
#endif /* HAVE_RES_SEARCH */
- report_complete(stderr, ": %s\n", strerror(err_no));
-
+ strcpy(errbuf, strerror(err_no));
+ report_complete(stderr, ": %s\n", errbuf);
+
+#ifdef __UNUSED
+ /*
+ * Don't use this. It was an attempt to address Debian bug
+ * #47143 (Notify user by mail when pop server nonexistent).
+ * Trouble is, that doesn't work; you trip over the case
+ * where your SLIP or PPP link is down...
+ */
+ /* warn the system administrator */
+ if (open_warning_by_mail(ctl, (struct msgblk *)NULL) == 0)
+ {
+#define OPENFAIL "Subject: Fetchmail unreachable-server warning.\r\n\r\nFetchmail could not reach the mail server %s:"
+ stuff_warning(ctl, OPENFAIL, ctl->server.pollname);
+ stuff_warning(ctl, errbuf, ctl->server.pollname);
+ close_warning_by_mail(ctl, (struct msgblk *)NULL);
+#undef OPENFAIL
+ }
+#endif
}
#endif /* INET6_ENABLE */
ok = PS_SOCKET;
dispatches = 0;
++pass;
+ /* reset timeout, in case we did an IDLE */
+ mytimeout = ctl->server.timeout;
+
if (outlevel >= O_DEBUG)
{
if (idp->id)
if (new == -1 || ctl->fetchall)
new = count;
fetches = new; /* set error status ccorrectly */
- goto no_error;
+ /*
+ * There used to be a `got noerror' here, but this
+ * prevneted checking of multiple folders. This
+ * comment is a reminder in case I introduced some
+ * subtle bug by removing it...
+ */
}
else if (count > 0)
{
*/
if (protocol->fetch_body && !suppress_readbody)
{
- if (outlevel >= O_VERBOSE)
+ if (outlevel >= O_VERBOSE && isatty(1))
{
fputc('\n', stdout);
fflush(stdout);
/* tell server we got it OK and resynchronize */
if (protocol->trail)
{
- if (outlevel >= O_VERBOSE)
+ if (outlevel >= O_VERBOSE && isatty(1))
{
fputc('\n', stdout);
fflush(stdout);
}
} while
/*
- * Only re-poll if we had some actual forwards, allowed
- * deletions and had no errors.
+ * Only re-poll if we either had some actual forwards and
+ * either allowed deletions and had no errors.
* Otherwise it is far too easy to get into infinite loops.
*/
(dispatches && protocol->retry && !ctl->keep && !ctl->errcount);