diff options
-rw-r--r-- | checkalias.c | 6 | ||||
-rw-r--r-- | driver.c | 94 | ||||
-rw-r--r-- | etrn.c | 6 | ||||
-rw-r--r-- | fetchmail.c | 22 | ||||
-rw-r--r-- | fetchmail.h | 6 | ||||
-rw-r--r-- | imap.c | 38 | ||||
-rw-r--r-- | interface.c | 10 | ||||
-rw-r--r-- | report.c | 60 | ||||
-rw-r--r-- | rpa.c | 96 | ||||
-rw-r--r-- | sink.c | 6 | ||||
-rw-r--r-- | smtp.c | 20 |
11 files changed, 184 insertions, 180 deletions
diff --git a/checkalias.c b/checkalias.c index cf151d76..3c8a6e6b 100644 --- a/checkalias.c +++ b/checkalias.c @@ -137,15 +137,15 @@ int is_host_alias(const char *name, struct query *ctl) else if (((he_st = gethostbyname(ctl->server.truename)) != (struct hostent *)NULL) && ctl->server.checkalias) { if (outlevel >= O_DEBUG) - error(0, 0, _("Checking if %s is really the same node as %s"),ctl->server.truename,name); + progress(0, 0, _("Checking if %s is really the same node as %s"),ctl->server.truename,name); if (is_ip_alias(ctl->server.truename,name) == TRUE) { if (outlevel >= O_DEBUG) - error(0, 0, _("Yes, their IP addresses match")); + progress(0, 0, _("Yes, their IP addresses match")); goto match; } if (outlevel >= O_DEBUG) - error(0, 0, _("No, their IP addresses don't match")); + progress(0, 0, _("No, their IP addresses don't match")); } else return(FALSE); @@ -132,7 +132,7 @@ static void map_name(const char *name, struct query *ctl, struct idlist **xmit_n if (lname != (char *)NULL) { if (outlevel >= O_DEBUG) - error(0, 0, _("mapped %s to local %s"), name, lname); + progress(0, 0, _("mapped %s to local %s"), name, lname); save_str(xmit_names, lname, XMIT_ACCEPT); accept_count++; } @@ -189,7 +189,7 @@ static void find_server_names(const char *hdr, strcasecmp(rhs, idp->id) == 0) { if (outlevel >= O_DEBUG) - error(0, 0, _("passed through %s matching %s"), + progress(0, 0, _("passed through %s matching %s"), cp, idp->id); save_str(xmit_names, cp, XMIT_ACCEPT); accept_count++; @@ -243,7 +243,7 @@ static char *parse_received(struct query *ctl, char *bufp) * does this when the mail has a single recipient. */ if (outlevel >= O_DEBUG) - error(0, 0, _("analyzing Received line:\n%s"), bufp); + progress(0, 0, _("analyzing Received line:\n%s"), bufp); /* search for whitepace-surrounded "by" followed by xxxx.yyyy */ for (base = bufp; ; base = ok + 2) @@ -281,13 +281,13 @@ static char *parse_received(struct query *ctl, char *bufp) if (is_host_alias(rbuf, ctl)) { if (outlevel >= O_DEBUG) - error(0, 0, + progress(0, 0, _("line accepted, %s is an alias of the mailserver"), rbuf); } else { if (outlevel >= O_DEBUG) - error(0, 0, + progress(0, 0, _("line rejected, %s is not an alias of the mailserver"), rbuf); return(NULL); @@ -359,7 +359,7 @@ static char *parse_received(struct query *ctl, char *bufp) if (!ok) { if (outlevel >= O_DEBUG) - error(0, 0, _("no Received address found")); + progress(0, 0, _("no Received address found")); return(NULL); } else @@ -368,7 +368,7 @@ static char *parse_received(struct query *ctl, char *bufp) char *lf = rbuf + strlen(rbuf)-1; *lf = '\0'; if (outlevel >= O_DEBUG) - error(0, 0, _("found Received address `%s'"), rbuf+2); + progress(0, 0, _("found Received address `%s'"), rbuf+2); *lf = '\n'; } return(rbuf); @@ -499,7 +499,7 @@ static int readheaders(int sock, sizeticker += linelen; while (sizeticker >= SIZETICKER) { - error_build("."); + progress_build("."); sizeticker -= SIZETICKER; } } @@ -731,7 +731,7 @@ static int readheaders(int sock, if (!headers_ok) { if (outlevel > O_SILENT) - error(0,0,_("message delimiter found while scanning headers")); + progress(0,0,_("message delimiter found while scanning headers")); } /* @@ -854,7 +854,7 @@ static int readheaders(int sock, no_local_matches = TRUE; save_str(&msgblk.recipients, run.postmaster, XMIT_ACCEPT); if (outlevel >= O_DEBUG) - error(0, 0, + progress(0, 0, _("no local matches, forwarding to %s"), run.postmaster); } @@ -869,7 +869,7 @@ static int readheaders(int sock, if (ctl->errcount > olderrs) /* there were DNS errors above */ { if (outlevel >= O_DEBUG) - error(0,0, _("forwarding and deletion suppressed due to DNS errors")); + progress(0,0, _("forwarding and deletion suppressed due to DNS errors")); free(msgblk.headers); free_str_list(&msgblk.recipients); return(PS_TRANSIENT); @@ -966,7 +966,7 @@ static int readheaders(int sock, if (n == -1) { - error(0, errno, _("writing RFC822 msgblk.headers")); + progress(0, errno, _("writing RFC822 msgblk.headers")); release_sink(ctl); free(msgblk.headers); free_str_list(&msgblk.recipients); @@ -1074,7 +1074,7 @@ static int readbody(int sock, struct query *ctl, flag forward, int len) while (sizeticker >= SIZETICKER) { if (!run.use_syslog && outlevel > O_SILENT) - error_build("."); + progress_build("."); sizeticker -= SIZETICKER; } } @@ -1122,7 +1122,7 @@ static int readbody(int sock, struct query *ctl, flag forward, int len) if (n < 0) { - error(0, errno, _("writing message text")); + progress(0, errno, _("writing message text")); release_sink(ctl); return(PS_IOERR); } @@ -1419,23 +1419,23 @@ const struct method *proto; /* protocol method table */ #endif /* HAVE_SIGPROCMASK */ if (phase == OPEN_WAIT) - error(0, 0, + progress(0, 0, _("timeout after %d seconds waiting to connect to server %s."), ctl->server.timeout, ctl->server.pollname); else if (phase == SERVER_WAIT) - error(0, 0, + progress(0, 0, _("timeout after %d seconds waiting for server %s."), ctl->server.timeout, ctl->server.pollname); else if (phase == FORWARDING_WAIT) - error(0, 0, + progress(0, 0, _("timeout after %d seconds waiting for %s."), ctl->server.timeout, ctl->mda ? "MDA" : "SMTP"); else if (phase == LISTENER_WAIT) - error(0, 0, + progress(0, 0, _("timeout after %d seconds waiting for listener to respond.")); else - error(0, 0, _("timeout after %d seconds."), ctl->server.timeout); + progress(0, 0, _("timeout after %d seconds."), ctl->server.timeout); release_sink(ctl); if (ctl->smtp_socket != -1) @@ -1485,8 +1485,7 @@ const struct method *proto; /* protocol method table */ /* execute pre-initialization command, if any */ if (ctl->preconnect && (ok = system(ctl->preconnect))) { - sprintf(buf, _("pre-connection command failed with status %d"), ok); - error(0, 0, buf); + error(0, 0, _("pre-connection command failed with status %d"), ok); ok = PS_SYNTAX; goto closeUp; } @@ -1641,9 +1640,9 @@ const struct method *proto; /* protocol method table */ if (outlevel >= O_DEBUG) if (idp->id) - error(0, 0, _("selecting or re-polling folder %s"), idp->id); + progress(0, 0, _("selecting or re-polling folder %s"), idp->id); else - error(0, 0, _("selecting or re-polling default folder")); + progress(0, 0, _("selecting or re-polling default folder")); /* compute # of messages and number of new messages waiting */ ok = (protocol->getrange)(sock, ctl, idp->id, &count, &new, &bytes); @@ -1659,28 +1658,28 @@ const struct method *proto; /* protocol method table */ ctl->remotename, ctl->server.truename); if (outlevel > O_SILENT) if (count == -1) /* only used for ETRN */ - error(0, 0, _("Polling %s"), ctl->server.truename); + progress(0, 0, _("Polling %s"), ctl->server.truename); else if (count != 0) { if (new != -1 && (count - new) > 0) - error_build(_("%d %s (%d seen) for %s"), + progress_build(_("%d %s (%d seen) for %s"), count, count > 1 ? _("messages") : _("message"), count-new, buf); else - error_build(_("%d %s for %s"), + progress_build(_("%d %s for %s"), count, count > 1 ? _("messages") : _("message"), buf); if (bytes == -1) - error_complete(0, 0, "."); + progress_complete(0, 0, "."); else - error_complete(0, 0, _(" (%d octets)."), bytes); + progress_complete(0, 0, _(" (%d octets)."), bytes); } else { /* these are pointless in normal daemon mode */ if (pass == 1 && (run.poll_interval == 0 || outlevel >= O_VERBOSE)) - error(0, 0, _("No mail for %s"), buf); + progress(0, 0, _("No mail for %s"), buf); } /* very important, this is where we leave the do loop */ @@ -1780,7 +1779,7 @@ const struct method *proto; /* protocol method table */ if (msgsizes && msgsizes[num-1] == -1) { if (outlevel >= O_VERBOSE) - error(0, 0, + progress(0, 0, _("Skipping message %d, length -1"), num - 1); continue; @@ -1791,7 +1790,7 @@ const struct method *proto; /* protocol method table */ { if (outlevel > O_SILENT) { - error_build(_("skipping message %d"), num); + progress_build(_("skipping message %d"), num); if (toolarge && !check_only) { char size[32]; @@ -1836,7 +1835,7 @@ const struct method *proto; /* protocol method table */ tmp->val.status.num = cnt; } - error_build(_(" (oversized, %d octets)"), + progress_build(_(" (oversized, %d octets)"), msgsizes[num-1]); } } @@ -1859,16 +1858,16 @@ const struct method *proto; /* protocol method table */ if (outlevel > O_SILENT) { - error_build(_("reading message %d of %d"), + progress_build(_("reading message %d of %d"), num,count); if (len > 0) - error_build(_(" (%d %soctets)"), + progress_build(_(" (%d %soctets)"), len, wholesize ? "" : _("header ")); if (outlevel >= O_VERBOSE) - error_complete(0, 0, ""); + progress_complete(0, 0, ""); else - error_build(" "); + progress_build(" "); } /* @@ -1909,7 +1908,7 @@ const struct method *proto; /* protocol method table */ if ((ok=(protocol->fetch_body)(sock,ctl,num,&len))) goto cleanUp; if (outlevel > O_SILENT && !wholesize) - error_build(_(" (%d body octets) "), len); + progress_build(_(" (%d body octets) "), len); } } @@ -1977,7 +1976,7 @@ const struct method *proto; /* protocol method table */ if (msgsizes && msglen != msgsizes[num-1]) { if (outlevel >= O_DEBUG) - error(0, 0, + progress(0, 0, _("message %d was not the expected length (%d actual != %d expected)"), num, msglen, msgsizes[num-1]); } @@ -2016,7 +2015,7 @@ const struct method *proto; /* protocol method table */ if (retained) { if (outlevel > O_SILENT) - error_complete(0, 0, _(" retained")); + progress_complete(0, 0, _(" retained")); } else if (protocol->delete && !suppress_delete @@ -2024,7 +2023,7 @@ const struct method *proto; /* protocol method table */ { deletions++; if (outlevel > O_SILENT) - error_complete(0, 0, _(" flushed")); + progress_complete(0, 0, _(" flushed")); ok = (protocol->delete)(sock, ctl, num); if (ok != 0) goto cleanUp; @@ -2033,13 +2032,13 @@ const struct method *proto; /* protocol method table */ #endif /* POP3_ENABLE */ } else if (outlevel > O_SILENT) - error_complete(0, 0, _(" not flushed")); + progress_complete(0, 0, _(" not flushed")); /* perhaps this as many as we're ready to handle */ if (NUM_NONZERO(ctl->fetchlimit) && ctl->fetchlimit <= fetches) { - error(0, 0, _("fetchlimit reached; %d messages left on server"), + progress(0, 0, _("fetchlimit reached; %d messages left on server"), count - fetches); goto no_error; } @@ -2122,10 +2121,7 @@ closeUp: /* execute post-initialization command, if any */ if (ctl->postconnect && (ok = system(ctl->postconnect))) { - char buf[80]; - - sprintf(buf, _("post-connection command failed with status %d"), ok); - error(0, 0, buf); + error(0, 0, _("post-connection command failed with status %d"), ok); if (ok == PS_SUCCESS) ok = PS_SYNTAX; } @@ -2182,7 +2178,7 @@ va_dcl *cp = '\0'; } buf[strlen(buf)-2] = '\0'; - error(0, 0, "%s> %s", protocol->name, buf); + progress(0, 0, "%s> %s", protocol->name, buf); } } @@ -2210,7 +2206,7 @@ int size; /* length of buffer */ if (buf[strlen(buf)-1] == '\r') buf[strlen(buf)-1] = '\0'; if (outlevel >= O_MONITOR) - error(0, 0, "%s< %s", protocol->name, buf); + progress(0, 0, "%s< %s", protocol->name, buf); phase = oldphase; return(PS_SUCCESS); } @@ -2268,7 +2264,7 @@ va_dcl *cp = '\0'; } buf[strlen(buf)-1] = '\0'; - error(0, 0, "%s> %s", protocol->name, buf); + progress(0, 0, "%s> %s", protocol->name, buf); } /* we presume this does its own response echoing */ @@ -69,18 +69,18 @@ static int etrn_getrange(int sock, struct query *ctl, const char *id, { case 250: /* OK, queuing for node <x> started */ if (outlevel >= O_SILENT) - error(0, 0, _("Queuing for %s started"), qnp->id); + progress(0, 0, _("Queuing for %s started"), qnp->id); break; case 251: /* OK, no messages waiting for node <x> */ if (outlevel >= O_SILENT) - error(0, 0, _("No messages waiting for %s"), qnp->id); + progress(0, 0, _("No messages waiting for %s"), qnp->id); return(PS_NOMAIL); case 252: /* OK, pending messages for node <x> started */ case 253: /* OK, <n> pending messages for node <x> started */ if (outlevel >= O_SILENT) - error(0, 0, _("Pending messages for %s started"), qnp->id); + progress(0, 0, _("Pending messages for %s started"), qnp->id); break; case 458: /* Unable to queue messages for node <x> */ diff --git a/fetchmail.c b/fetchmail.c index 9edc1600..5636e803 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -464,7 +464,7 @@ int main (int argc, char **argv) { if (!nodetach) daemonize(run.logfile, termhook); - error( 0, 0, _("starting fetchmail %s daemon "), VERSION); + progress( 0, 0, _("starting fetchmail %s daemon "), VERSION); /* * We'll set up a handler for these when we're sleeping, @@ -537,7 +537,7 @@ int main (int argc, char **argv) if (ctl->server.poll_count++ % ctl->server.interval) { if (outlevel >= O_VERBOSE) - error(0, -1, + progress(0, -1, _("interval not reached, not querying %s"), ctl->server.pollname); continue; @@ -565,13 +565,13 @@ int main (int argc, char **argv) { write_saved_lists(querylist, run.idfile); if (outlevel >= O_DEBUG) - error(0, 0, _("saved UID List")); + progress(0, 0, _("saved UID List")); } #endif /* POP3_ENABLE */ } else if (!check_only && ((querystatus!=PS_NOMAIL) || (outlevel==O_DEBUG))) - error(0, 0, _("Query status=%d"), querystatus); + progress(0, 0, _("Query status=%d"), querystatus); #if defined(linux) && !INET6 if (ctl->server.monitor) @@ -633,7 +633,7 @@ int main (int argc, char **argv) } if (outlevel >= O_VERBOSE) - error(0, -1, _("fetchmail: sleeping at %s"), rfc822timestamp()); + progress(0, -1, _("fetchmail: sleeping at %s"), rfc822timestamp()); /* * With this simple hack, we make it possible for a foreground @@ -728,9 +728,9 @@ int main (int argc, char **argv) || ((run.poll_interval && !getuid()) && lastsig == SIGHUP)) { #ifdef SYS_SIGLIST_DECLARED - error(0, 0, _("awakened by %s"), sys_siglist[lastsig]); + progress(0, 0, _("awakened by %s"), sys_siglist[lastsig]); #else - error(0, 0, _("awakened by signal %d"), lastsig); + progress(0, 0, _("awakened by signal %d"), lastsig); #endif /* received a wakeup - unwedge all servers in case */ /* the problem has been manually repaired */ @@ -745,13 +745,13 @@ int main (int argc, char **argv) signal(SIGHUP, SIG_IGN); if (outlevel >= O_VERBOSE) - error(0, -1, _("awakened at %s"), rfc822timestamp()); + progress(0, -1, _("awakened at %s"), rfc822timestamp()); } } while (run.poll_interval); if (outlevel >= O_VERBOSE) - error(0, -1, _("normal termination, status %d"), + progress(0, -1, _("normal termination, status %d"), successes ? PS_SUCCESS : querystatus); termhook(0); @@ -1167,7 +1167,7 @@ static void termhook(int sig) */ if (sig != 0) - error(0, 0, _("terminated with signal %d"), sig); + progress(0, 0, _("terminated with signal %d"), sig); else /* terminate all SMTP connections cleanly */ for (ctl = querylist; ctl; ctl = ctl->next) @@ -1227,7 +1227,7 @@ static int query_host(struct query *ctl) time_t now; time(&now); - error(0, -1, _("%s querying %s (protocol %s) at %s"), + progress(0, -1, _("%s querying %s (protocol %s) at %s"), VERSION, ctl->server.pollname, showproto(ctl->server.protocol), ctime(&now)); } diff --git a/fetchmail.h b/fetchmail.h index 5e5884a1..e1e04787 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -349,6 +349,12 @@ void error_complete (); void error_at_line (); #endif +/* for now, send progress messages to stderr */ +#define progress error +#define progress_build error_build +#define progress_complete error_complete +#define progress_at_line error_at_line + /* driver.c: transaction support */ void set_timeout(int); #if defined(HAVE_STDARG_H) @@ -150,7 +150,7 @@ static int do_otp(int sock, struct query *ctl) to64frombits(buffer, ctl->remotename, strlen(ctl->remotename)); if (outlevel >= O_MONITOR) - error(0, 0, "IMAP> %s", buffer); + progress(0, 0, "IMAP> %s", buffer); SockWrite(sock, buffer, strlen(buffer)); SockWrite(sock, "\r\n", 2); @@ -177,7 +177,7 @@ static int do_otp(int sock, struct query *ctl) to64frombits(buffer, response, strlen(response)); if (outlevel >= O_MONITOR) - error(0, 0, "IMAP> %s", buffer); + progress(0, 0, "IMAP> %s", buffer); SockWrite(sock, buffer, strlen(buffer)); SockWrite(sock, "\r\n", 2); @@ -317,7 +317,7 @@ static int do_rfc1731(int sock, char *truename) to64frombits(buf1, authenticator.dat, authenticator.length); if (outlevel >= O_MONITOR) { - error(0, 0, "IMAP> %s", buf1); + progress(0, 0, "IMAP> %s", buf1); } SockWrite(sock, buf1, strlen(buf1)); SockWrite(sock, "\r\n", 2); @@ -400,7 +400,7 @@ static int do_rfc1731(int sock, char *truename) to64frombits(buf1, authenticator.dat, authenticator.length); if (outlevel >= O_MONITOR) { - error(0, 0, "IMAP> %s", buf1); + progress(0, 0, "IMAP> %s", buf1); } SockWrite(sock, buf1, strlen(buf1)); SockWrite(sock, "\r\n", 2); @@ -465,7 +465,7 @@ static int do_gssauth(int sock, char *hostname, char *username) sec_token = GSS_C_NO_BUFFER; context = GSS_C_NO_CONTEXT; if (outlevel >= O_VERBOSE) - error(0,0,_("Sending credentials")); + progress(0,0,_("Sending credentials")); do { maj_stat = gss_init_sec_context(&min_stat, GSS_C_NO_CREDENTIAL, &context, target_name, NULL, 0, 0, NULL, sec_token, NULL, @@ -484,7 +484,7 @@ static int do_gssauth(int sock, char *hostname, char *username) SockWrite(sock, buf1, strlen(buf1)); SockWrite(sock, "\r\n", 2); if (outlevel >= O_MONITOR) - error(0,0,"IMAP> %s", buf1); + progress(0,0,"IMAP> %s", buf1); if (maj_stat == GSS_S_CONTINUE_NEEDED) { if (result = gen_recv(sock, buf1, sizeof buf1)) { gss_release_name(&min_stat, &target_name); @@ -512,7 +512,7 @@ static int do_gssauth(int sock, char *hostname, char *username) return PS_AUTHFAIL; } if (outlevel >= O_DEBUG) - error(0,0,_("Credential exchange complete")); + progress(0,0,_("Credential exchange complete")); /* first octet is security levels supported. We want none, for now */ server_conf_flags = ((char *)send_token.value)[0]; if ( !(((char *)send_token.value)[0] & GSSAUTH_P_NONE) ) { @@ -525,11 +525,11 @@ static int do_gssauth(int sock, char *hostname, char *username) /* we don't care about buffer size if we don't wrap data */ gss_release_buffer(&min_stat, &send_token); if (outlevel >= O_DEBUG) { - error(0,0,_("Unwrapped security level flags: %s%s%s"), + progress(0,0,_("Unwrapped security level flags: %s%s%s"), server_conf_flags & GSSAUTH_P_NONE ? "N" : "-", server_conf_flags & GSSAUTH_P_INTEGRITY ? "I" : "-", server_conf_flags & GSSAUTH_P_PRIVACY ? "C" : "-"); - error(0,0,_("Maximum GSS token size is %ld"),buf_size); + progress(0,0,_("Maximum GSS token size is %ld"),buf_size); } /* now respond in kind (hack!!!) */ @@ -547,8 +547,8 @@ static int do_gssauth(int sock, char *hostname, char *username) } to64frombits(buf1, send_token.value, send_token.length); if (outlevel >= O_DEBUG) { - error(0,0,_("Requesting authorisation as %s"), username); - error(0,0,"IMAP> %s",buf1); + progress(0,0,_("Requesting authorisation as %s"), username); + progress(0,0,"IMAP> %s",buf1); } SockWrite(sock, buf1, strlen(buf1)); SockWrite(sock, "\r\n", 2); @@ -559,7 +559,7 @@ static int do_gssauth(int sock, char *hostname, char *username) if (strstr(buf1, "OK")) { /* flush security context */ if (outlevel >= O_DEBUG) - error(0, 0, _("Releasing GSS credentials")); + progress(0, 0, _("Releasing GSS credentials")); maj_stat = gss_delete_sec_context(&min_stat, &context, &send_token); if (maj_stat != GSS_S_COMPLETE) { error(0, -1, _("Error releasing credentials")); @@ -609,20 +609,20 @@ int imap_getauth(int sock, struct query *ctl, char *greeting) { imap_version = IMAP4rev1; if (outlevel >= O_DEBUG) - error(0, 0, _("Protocol identified as IMAP4 rev 1")); + progress(0, 0, _("Protocol identified as IMAP4 rev 1")); } else { imap_version = IMAP4; if (outlevel >= O_DEBUG) - error(0, 0, _("Protocol identified as IMAP4 rev 0")); + progress(0, 0, _("Protocol identified as IMAP4 rev 0")); } } else if (ok == PS_ERROR) { imap_version = IMAP2; if (outlevel >= O_DEBUG) - error(0, 0, _("Protocol identified as IMAP2 or IMAP2BIS")); + progress(0, 0, _("Protocol identified as IMAP2 or IMAP2BIS")); } else return(ok); @@ -633,7 +633,7 @@ int imap_getauth(int sock, struct query *ctl, char *greeting) if ((ctl->server.protocol == P_IMAP) && strstr(capabilities, "AUTH=X-OTP")) { if (outlevel >= O_DEBUG) - error(0, 0, _("OTP authentication is supported")); + progress(0, 0, _("OTP authentication is supported")); if (do_otp(sock, ctl) == PS_SUCCESS) return(PS_SUCCESS); }; @@ -645,7 +645,7 @@ int imap_getauth(int sock, struct query *ctl, char *greeting) if (ctl->server.protocol == P_IMAP_GSS) { if (outlevel >= O_DEBUG) - error(0, 0, _("GSS authentication is supported")); + progress(0, 0, _("GSS authentication is supported")); return do_gssauth(sock, ctl->server.truename, ctl->remotename); } } @@ -660,14 +660,14 @@ int imap_getauth(int sock, struct query *ctl, char *greeting) if (strstr(capabilities, "AUTH=KERBEROS_V4")) { if (outlevel >= O_DEBUG) - error(0, 0, _("KERBEROS_V4 authentication is supported")); + progress(0, 0, _("KERBEROS_V4 authentication is supported")); if (ctl->server.protocol == P_IMAP_K4) { if ((ok = do_rfc1731(sock, ctl->server.truename))) { if (outlevel >= O_MONITOR) - error(0, 0, "IMAP> *"); + progress(0, 0, "IMAP> *"); SockWrite(sock, "*\r\n", 3); } diff --git a/interface.c b/interface.c index 608ddc45..140822d0 100644 --- a/interface.c +++ b/interface.c @@ -218,7 +218,7 @@ void interface_note_activity(struct hostdata *hp) } #ifdef ACTIVITY_DEBUG - (void) error(0, 0, _("activity on %s -noted- as %d"), + (void) progress(0, 0, _("activity on %s -noted- as %d"), hp->monitor, hp->monitor_io); #endif } @@ -232,7 +232,7 @@ int interface_approve(struct hostdata *hp) if (hp->interface) { /* get interface info */ if (!get_ifinfo(hp->interface, &ifinfo)) { - (void) error(0, 0, _("skipping poll of %s, %s down"), + (void) progress(0, 0, _("skipping poll of %s, %s down"), hp->pollname, hp->interface); return(FALSE); } @@ -240,7 +240,7 @@ int interface_approve(struct hostdata *hp) if ((ifinfo.addr.s_addr & hp->interface_pair->interface_mask.s_addr) != hp->interface_pair->interface_address.s_addr) { - (void) error(0, 0, + (void) progress(0, 0, _("skipping poll of %s, %s IP address excluded"), hp->pollname, hp->interface); return(FALSE); @@ -252,14 +252,14 @@ int interface_approve(struct hostdata *hp) return(TRUE); #ifdef ACTIVITY_DEBUG - (void) error(0, 0, _("activity on %s checked as %d"), + (void) progress(0, 0, _("activity on %s checked as %d"), hp->monitor, hp->monitor_io); #endif /* if monitoring, check link for activity if it is up */ if (get_ifinfo(hp->monitor, &ifinfo) && hp->monitor_io == ifinfo.rx_packets + ifinfo.tx_packets) { - (void) error(0, 0, _("skipping poll of %s, %s inactive"), + (void) progress(0, 0, _("skipping poll of %s, %s inactive"), hp->pollname, hp->monitor); return(FALSE); } @@ -58,7 +58,7 @@ void exit (); #define MALLOC(n) xmalloc(n) #define REALLOC(n,s) xrealloc(n,s) -/* If NULL, error will flush stdout, then print on stderr the program +/* If NULL, error will flush stderr, then print on stderr the program name, a colon and a space. Otherwise, error will call this function without parameters instead. */ void (*error_print_progname) ( @@ -77,6 +77,8 @@ static unsigned int use_syslog; /* This variable is incremented each time `error' is called. */ unsigned int error_message_count; +/* for now, send all error messages to stderr */ +#define errfp stderr #ifdef _LIBC /* In the GNU C library, there is a predefined variable for this. */ @@ -198,38 +200,38 @@ error (status, errnum, message, va_alist) (*error_print_progname) (); else { - fflush (stdout); + fflush (errfp); if ( *message == '\n' ) { - fputc( '\n', stderr ); + fputc( '\n', errfp ); ++message; } - fprintf (stderr, "%s: ", program_name); + fprintf (errfp, "%s: ", program_name); } #ifdef VA_START VA_START (args, message); # if HAVE_VPRINTF || _LIBC - vfprintf (stderr, message, args); + vfprintf (errfp, message, args); # else - _doprnt (message, args, stderr); + _doprnt (message, args, errfp); # endif va_end (args); #else - fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8); + fprintf (errfp, message, a1, a2, a3, a4, a5, a6, a7, a8); #endif if (errnum && errnum != -1) { char *tmps = strerror(errnum); if (tmps) { - fprintf (stderr, ": %s", tmps); + fprintf (errfp, ": %s", tmps); } else { - fprintf (stderr, _(": Error %d"), errnum); + fprintf (errfp, _(": Error %d"), errnum); } } - putc ('\n', stderr); - fflush (stderr); + putc ('\n', errfp); + fflush (errfp); } ++error_message_count; if (status) @@ -238,20 +240,20 @@ error (status, errnum, message, va_alist) /* * Calling error_init(1) causes error_build and error_complete to write - * to stderr without buffering. This is needed for the ticker dots to + * to errfp without buffering. This is needed for the ticker dots to * work correctly. */ void error_init(int mode) { switch(mode) { - case 0: /* stderr, buffered */ + case 0: /* errfp, buffered */ default: use_stderr = FALSE; use_syslog = FALSE; break; - case 1: /* stderr, unbuffered */ + case 1: /* errfp, unbuffered */ use_stderr = TRUE; use_syslog = FALSE; break; @@ -365,7 +367,7 @@ error_build (message, va_alist) if (use_stderr && partial_message_size_used != 0) { partial_message_size_used = 0; - fputs(partial_message, stderr); + fputs(partial_message, errfp); } } @@ -469,13 +471,13 @@ error_complete (status, errnum, message, va_alist) if (use_stderr) { - fputs(partial_message, stderr); + fputs(partial_message, errfp); if (errnum) - fprintf (stderr, ": %s", strerror (errnum)); + fprintf (errfp, ": %s", strerror (errnum)); - putc ('\n', stderr); - fflush (stderr); + putc ('\n', errfp); + fflush (errfp); ++error_message_count; @@ -526,35 +528,35 @@ error_at_line (status, errnum, file_name, line_number, message, va_alist) (*error_print_progname) (); else { - fflush (stdout); + fflush (errfp); if ( *message == '\n' ) { - fputc( '\n', stderr ); + fputc( '\n', errfp ); ++message; } - fprintf (stderr, "%s:", program_name); + fprintf (errfp, "%s:", program_name); } if (file_name != NULL) - fprintf (stderr, "%s:%d: ", file_name, line_number); + fprintf (errfp, "%s:%d: ", file_name, line_number); #ifdef VA_START VA_START (args, message); # if HAVE_VPRINTF || _LIBC - vfprintf (stderr, message, args); + vfprintf (errfp, message, args); # else - _doprnt (message, args, stderr); + _doprnt (message, args, errfp); # endif va_end (args); #else - fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8); + fprintf (errfp, message, a1, a2, a3, a4, a5, a6, a7, a8); #endif ++error_message_count; if (errnum) - fprintf (stderr, ": %s", strerror (errnum)); - putc ('\n', stderr); - fflush (stderr); + fprintf (errfp, ": %s", strerror (errnum)); + putc ('\n', errfp); + fflush (errfp); if (status) exit (status); } @@ -120,7 +120,7 @@ int POP3_auth_rpa (unsigned char *userid, unsigned char *passphrase, int socket) SockPrintf(socket,"AUTH RPA\r\n"); if (outlevel >= O_MONITOR) - error(0, 0, "> AUTH RPA\n"); + progress(0, 0, "> AUTH RPA\n"); /* Create unicode user name in Nu. */ /* Create MD5 digest of user's passphrase in Pu */ @@ -134,7 +134,7 @@ int POP3_auth_rpa (unsigned char *userid, unsigned char *passphrase, int socket) if ((ok = POP3_rpa_resp(buf,socket)) != 0) { if (outlevel > O_SILENT && outlevel < O_MONITOR) - error(0, 0, "%s\n",buf); + progress(0, 0, "%s\n",buf); return(ok); } @@ -156,11 +156,11 @@ int POP3_auth_rpa (unsigned char *userid, unsigned char *passphrase, int socket) SockPrintf(socket,"%s\r\n",buf); #endif if (outlevel >= O_MONITOR) - error(0, 0, "> %s\n",buf); + progress(0, 0, "> %s\n",buf); if ((ok = POP3_rpa_resp(buf,socket)) != 0) { if (outlevel > O_SILENT && outlevel < O_MONITOR) - error(0, 0, "%s\n",buf); + progress(0, 0, "%s\n",buf); return(ok); } if ((rxlen = DecBase64(buf)) == 0) @@ -177,22 +177,22 @@ int POP3_auth_rpa (unsigned char *userid, unsigned char *passphrase, int socket) verh = *(bufp++); verl = *(bufp++); if (outlevel >= O_DEBUG) - error(0, 0, _("Service chose RPA version %d.%d\n"),verh,verl); + progress(0, 0, _("Service chose RPA version %d.%d\n"),verh,verl); Csl = *(bufp++); memcpy(Cs, bufp, Csl); bufp += Csl; if (outlevel >= O_DEBUG) { - error(0, 0, _("Service challenge (l=%d):"),Csl); + progress(0, 0, _("Service challenge (l=%d):"),Csl); for (i=0; i<Csl; i++) - error_build("%02X ",Cs[i]); - error_complete(0, 0, ""); + progress_build("%02X ",Cs[i]); + progress_complete(0, 0, ""); } memcpy(Ts, bufp, Tsl); Ts[Tsl] = 0; bufp += Tsl; if (outlevel >= O_DEBUG) - error(0, 0, _("Service timestamp %s\n"),Ts); + progress(0, 0, _("Service timestamp %s\n"),Ts); rll = *(bufp++) << 8; rll = rll | *(bufp++); if ((bufp-buf+rll) != rxlen) { @@ -201,7 +201,7 @@ int POP3_auth_rpa (unsigned char *userid, unsigned char *passphrase, int socket) return(PS_RPA); } if (outlevel >= O_DEBUG) - error(0, 0, _("Realm list: %s\n"),bufp); + progress(0, 0, _("Realm list: %s\n"),bufp); if (SetRealmService(bufp) != 0) { if (outlevel > O_SILENT) @@ -232,11 +232,11 @@ int POP3_auth_rpa (unsigned char *userid, unsigned char *passphrase, int socket) SockPrintf(socket,"%s\r\n",buf); #endif if (outlevel >= O_MONITOR) - error(0, 0, "> %s\n",buf); + progress(0, 0, "> %s\n",buf); if ((ok = POP3_rpa_resp(buf,socket)) != 0) { if (outlevel > O_SILENT && outlevel < O_MONITOR) - error(0, 0, "%s\n",buf); + progress(0, 0, "%s\n",buf); return(ok); } if ((rxlen = DecBase64(buf)) == 0) @@ -253,10 +253,10 @@ int POP3_auth_rpa (unsigned char *userid, unsigned char *passphrase, int socket) aulin = *(bufp++); if (outlevel >= O_DEBUG) { - error(0, 0, _("User authentication (l=%d):"),aulin); + progress(0, 0, _("User authentication (l=%d):"),aulin); for (i=0; i<aulin; i++) - error_build("%02X ",bufp[i]); - error_complete(0, 0, ""); + progress_build("%02X ",bufp[i]); + progress_complete(0, 0, ""); } if (aulin == Aul) memcpy(Au, bufp, Aul); bufp += aulin; @@ -267,7 +267,7 @@ int POP3_auth_rpa (unsigned char *userid, unsigned char *passphrase, int socket) { status = *(bufp++); if (outlevel >= O_DEBUG) - error(0, 0, _("RPA status: %02X\n"),status); + progress(0, 0, _("RPA status: %02X\n"),status); } else status = 0; if ((bufp - buf) != rxlen) @@ -303,10 +303,10 @@ int POP3_auth_rpa (unsigned char *userid, unsigned char *passphrase, int socket) } if (outlevel >= O_DEBUG) { - error(0, 0, _("Session key established:")); + progress(0, 0, _("Session key established:")); for (i=0; i<Kusl; i++) - error_build("%02X ",Kus[i]); - error_complete(0, 0, ""); + progress_build("%02X ",Kus[i]); + progress_complete(0, 0, ""); } /* Assemble Token 5 in buf and send (not in ver 2 though) */ @@ -324,17 +324,17 @@ int POP3_auth_rpa (unsigned char *userid, unsigned char *passphrase, int socket) SockPrintf(socket,"%s\r\n",buf); #endif if (outlevel >= O_MONITOR) - error(0, 0, "> %s\n",buf); + progress(0, 0, "> %s\n",buf); if ((ok = POP3_rpa_resp(buf,socket)) != 0) { if (outlevel > O_SILENT && outlevel < O_MONITOR) - error(0, 0, "%s\n",buf); + progress(0, 0, "%s\n",buf); return(ok); } } if (outlevel > O_SILENT) - error(0, 0, _("RPA authorisation complete\n")); + progress(0, 0, _("RPA authorisation complete\n")); return(PS_SUCCESS); } @@ -363,7 +363,7 @@ int socket; int sockrc; if (outlevel >= O_DEBUG) - error(0, 0, _("Get response\n")); + progress(0, 0, _("Get response\n")); #ifndef TESTMODE sockrc = gen_recv(socket, buf, sizeof(buf)); #else @@ -371,7 +371,7 @@ int socket; if (linecount == 1) strcpy(buf,line1); if (linecount == 2) strcpy(buf,line2); if (linecount == 3) strcpy(buf,line3); -/* error(0, 0, "--> "); fflush(stderr); */ +/* progress(0, 0, "--> "); fflush(stderr); */ /* scanf("%s",&buf) */ sockrc = PS_SUCCESS; #endif @@ -393,7 +393,7 @@ int socket; else ok = PS_SOCKET; if (outlevel >= O_DEBUG) - error(0, 0, _("Get response return %d [%s]\n"), ok, buf); + progress(0, 0, _("Get response return %d [%s]\n"), ok, buf); buf[sockrc] = 0; return(ok); } @@ -539,12 +539,12 @@ unsigned char *bufp; } if (outlevel >= O_MONITOR) { - error(0, 0, _("Inbound binary data:\n")); + progress(0, 0, _("Inbound binary data:\n")); for (i=0; i<cnt; i++) { - error_build("%02X ",bufp[i]); + progress_build("%02X ",bufp[i]); if (((i % 16)==15) || (i==(cnt-1))) - error_complete(0, 0, ""); + progress_complete(0, 0, ""); } } return(cnt); @@ -577,12 +577,12 @@ int len; if (outlevel >= O_MONITOR) { - error(0, 0, _("Outbound data:\n")); + progress(0, 0, _("Outbound data:\n")); for (i=0; i<len; i++) { - error_build("%02X ",bufp[i]); + progress_build("%02X ",bufp[i]); if (((i % 16)==15) || (i==(len-1))) - error_complete(0, 0, ""); + progress_complete(0, 0, ""); } } outp = bufp + (((len-1)/3)*4); @@ -648,12 +648,12 @@ int conv; } if (outlevel >= O_DEBUG) { - error(0, 0, _("Unicode:")); + progress(0, 0, _("Unicode:")); for (i=0; i<(*plen); i++) { - error_build("%02X ",buf[i]); + progress_build("%02X ",buf[i]); if (((i % 16)==15) || (i==((*plen)-1))) - error_complete(0, 0, ""); + progress_complete(0, 0, ""); } } } @@ -710,11 +710,11 @@ int len; devrandom = fopen("/dev/urandom","rb"); if (devrandom == NULL && outlevel > O_SILENT) { - error(0, 0, _("RPA Failed open of /dev/urandom. This shouldn't\n")); - error(0, 0, _(" prevent you logging in, but means you\n")); - error(0, 0, _(" cannot be sure you are talking to the\n")); - error(0, 0, _(" service that you think you are (replay\n")); - error(0, 0, _(" attacks by a dishonest service are possible.)\n")); + progress(0, 0, _("RPA Failed open of /dev/urandom. This shouldn't\n")); + progress(0, 0, _(" prevent you logging in, but means you\n")); + progress(0, 0, _(" cannot be sure you are talking to the\n")); + progress(0, 0, _(" service that you think you are (replay\n")); + progress(0, 0, _(" attacks by a dishonest service are possible.)\n")); } for(i=0; i<len; i++) @@ -725,12 +725,12 @@ int len; if (outlevel >= O_DEBUG) { - error(0, 0, _("User challenge:")); + progress(0, 0, _("User challenge:")); for (i=0; i<len; i++) { - error_build("%02X ",buf[i]); + progress_build("%02X ",buf[i]); if (((i % 16)==15) || (i==(len-1))) - error_complete(0, 0, ""); + progress_complete(0, 0, ""); } } } @@ -883,12 +883,12 @@ unsigned char* out; if (outlevel >= O_DEBUG) { - error(0, 0, _("MD5 being applied to data block:\n")); + progress(0, 0, _("MD5 being applied to data block:\n")); for (i=0; i<len; i++) { - error_build("%02X ",in[i]); + progress_build("%02X ",in[i]); if (((i % 16)==15) || (i==(len-1))) - error_complete(0, 0, ""); + progress_complete(0, 0, ""); } } MD5Init( &md5context ); @@ -896,12 +896,12 @@ unsigned char* out; MD5Final( out, &md5context ); if (outlevel >= O_DEBUG) { - error(0, 0, _("MD5 result is: ")); + progress(0, 0, _("MD5 result is: ")); for (i=0; i<16; i++) { - error_build("%02X ",out[i]); + progress_build("%02X ",out[i]); } - error_complete(0, 0, ""); + progress_complete(0, 0, ""); } } #endif /* POP3_ENABLE && RPA_ENABLE */ @@ -162,7 +162,7 @@ static int smtp_open(struct query *ctl) ctl->destaddr = ctl->smtpaddress ? ctl->smtpaddress : ( ctl->smtphost ? ctl->smtphost : "localhost"); if (outlevel >= O_DEBUG && ctl->smtp_socket != -1) - error(0, 0, _("forwarding to %s"), ctl->smtphost); + progress(0, 0, _("forwarding to %s"), ctl->smtphost); return(ctl->smtp_socket); } @@ -284,7 +284,7 @@ static int send_bouncemail(struct msgblk *msg, int userclass, ts = rfc822timestamp(); if (outlevel >= O_VERBOSE) - error(0, 0, "SMTP: (bounce-message body)"); + progress(0, 0, "SMTP: (bounce-message body)"); /* bouncemail headers */ SockPrintf(sock, "Return-Path: <>"); @@ -637,7 +637,7 @@ int open_sink(struct query *ctl, struct msgblk *msg, if (outlevel >= O_DEBUG) - error(0, 0, _("about to deliver with: %s"), before); + progress(0, 0, _("about to deliver with: %s"), before); #ifdef HAVE_SETEUID /* @@ -47,7 +47,7 @@ int SMTP_helo(int sock,const char *host) SockPrintf(sock,"HELO %s\r\n", host); if (outlevel >= O_MONITOR) - error(0, 0, "SMTP> HELO %s", host); + progress(0, 0, "SMTP> HELO %s", host); ok = SMTP_ok(sock); return ok; } @@ -59,7 +59,7 @@ int SMTP_ehlo(int sock, const char *host, int *opt) SockPrintf(sock,"%cHLO %s\r\n", (smtp_mode == 'S') ? 'E' : smtp_mode, host); if (outlevel >= O_MONITOR) - error(0, 0, "%cMTP> %cHLO %s", + progress(0, 0, "%cMTP> %cHLO %s", smtp_mode, (smtp_mode == 'S') ? 'E' : smtp_mode, host); *opt = 0; @@ -75,7 +75,7 @@ int SMTP_ehlo(int sock, const char *host, int *opt) return SM_ERROR; smtp_response[n] = '\0'; if (outlevel >= O_MONITOR) - error(0, 0, "SMTP< %s", smtp_response); + progress(0, 0, "SMTP< %s", smtp_response); for (hp = extensions; hp->name; hp++) if (!strncasecmp(hp->name, smtp_response+4, strlen(hp->name))) *opt |= hp->value; @@ -101,7 +101,7 @@ int SMTP_from(int sock, const char *from, const char *opts) strcat(buf, opts); SockPrintf(sock,"%s\r\n", buf); if (outlevel >= O_MONITOR) - error(0, 0, "%cMTP> %s", smtp_mode, buf); + progress(0, 0, "%cMTP> %s", smtp_mode, buf); ok = SMTP_ok(sock); return ok; } @@ -113,7 +113,7 @@ int SMTP_rcpt(int sock, const char *to) SockPrintf(sock,"RCPT TO:<%s>\r\n", to); if (outlevel >= O_MONITOR) - error(0, 0, "%cMTP> RCPT TO:<%s>", smtp_mode, to); + progress(0, 0, "%cMTP> RCPT TO:<%s>", smtp_mode, to); ok = SMTP_ok(sock); return ok; } @@ -125,7 +125,7 @@ int SMTP_data(int sock) SockPrintf(sock,"DATA\r\n"); if (outlevel >= O_MONITOR) - error(0, 0, "%cMTP> DATA", smtp_mode); + progress(0, 0, "%cMTP> DATA", smtp_mode); ok = SMTP_ok(sock); return ok; } @@ -137,7 +137,7 @@ int SMTP_rset(int sock) SockPrintf(sock,"RSET\r\n"); if (outlevel >= O_MONITOR) - error(0, 0, "%cMTP> RSET", smtp_mode); + progress(0, 0, "%cMTP> RSET", smtp_mode); ok = SMTP_ok(sock); return ok; } @@ -149,7 +149,7 @@ int SMTP_quit(int sock) SockPrintf(sock,"QUIT\r\n"); if (outlevel >= O_MONITOR) - error(0, 0, "%cMTP> QUIT", smtp_mode); + progress(0, 0, "%cMTP> QUIT", smtp_mode); ok = SMTP_ok(sock); return ok; } @@ -161,7 +161,7 @@ int SMTP_eom(int sock) SockPrintf(sock,".\r\n"); if (outlevel >= O_MONITOR) - error(0, 0, "%cMTP>. (EOM)", smtp_mode); + progress(0, 0, "%cMTP>. (EOM)", smtp_mode); /* * When doing LMTP, must process many of these at the outer level. @@ -189,7 +189,7 @@ int SMTP_ok(int sock) return SM_ERROR; smtp_response[n] = '\0'; if (outlevel >= O_MONITOR) - error(0, 0, "%cMTP< %s", smtp_mode, smtp_response); + progress(0, 0, "%cMTP< %s", smtp_mode, smtp_response); if ((smtp_response[0] == '1' || smtp_response[0] == '2' || smtp_response[0] == '3') && smtp_response[3] == ' ') return SM_OK; else if (smtp_response[3] != '-') |