From f6b7a3a3a1512c1a877f39b5bc606dcef2fcd922 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 17 Oct 1998 16:24:28 +0000 Subject: More verbosity fixes. svn path=/trunk/; revision=2103 --- checkalias.c | 6 +- driver.c | 26 +- fetchmail-FAQ.html | 26 +- fetchmail.h | 1 + imap.c | 34 +-- rpa.c | 708 ++++++++++++++++++++++++++--------------------------- sink.c | 4 +- smtp.c | 20 +- 8 files changed, 414 insertions(+), 411 deletions(-) diff --git a/checkalias.c b/checkalias.c index 5d515cfc..5d5320f6 100644 --- a/checkalias.c +++ b/checkalias.c @@ -140,15 +140,15 @@ int is_host_alias(const char *name, struct query *ctl) goto match; else if (((he_st = gethostbyname(ctl->server.truename)) != (struct hostent *)NULL) && ctl->server.checkalias) { - if (outlevel >= O_VERBOSE) + if (outlevel >= O_DEBUG) error(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_VERBOSE) + if (outlevel >= O_DEBUG) error(0, 0, "Yes, their IP addresses match"); goto match; } - if (outlevel >= O_VERBOSE) + if (outlevel >= O_DEBUG) error(0, 0, "No, their IP addresses don't match"); } else diff --git a/driver.c b/driver.c index 4cb24bc9..fe709197 100644 --- a/driver.c +++ b/driver.c @@ -137,7 +137,7 @@ struct idlist **xmit_names; /* list of recipient names parsed out */ if (lname != (char *)NULL) { - if (outlevel >= O_VERBOSE) + if (outlevel >= O_DEBUG) error(0, 0, "mapped %s to local %s", name, lname); save_str(xmit_names, lname, XMIT_ACCEPT); accept_count++; @@ -192,7 +192,7 @@ struct idlist **xmit_names; /* list of recipient names parsed out */ (rhs[-1] == '.' || rhs[-1] == '@') && strcasecmp(rhs, idp->id) == 0) { - if (outlevel >= O_VERBOSE) + if (outlevel >= O_DEBUG) error(0, 0, "passed through %s matching %s", cp, idp->id); save_str(xmit_names, cp, XMIT_ACCEPT); @@ -317,16 +317,16 @@ static char *parse_received(struct query *ctl, char *bufp) if (!ok) { - if (outlevel >= O_VERBOSE) + if (outlevel >= O_DEBUG) error(0, 0, "no Received address found"); return(NULL); } else { - if (outlevel >= O_VERBOSE) { + if (outlevel >= O_DEBUG) { char *lf = rbuf + strlen(rbuf)-1; *lf = '\0'; - if (outlevel >= O_VERBOSE) + if (outlevel >= O_DEBUG) error(0, 0, "found Received address `%s'", rbuf+2); *lf = '\n'; } @@ -808,7 +808,7 @@ int num; /* index of message */ { no_local_matches = TRUE; save_str(&xmit_names, run.postmaster, XMIT_ACCEPT); - if (outlevel >= O_VERBOSE) + if (outlevel >= O_DEBUG) error(0, 0, "no local matches, forwarding to %s", run.postmaster); @@ -823,7 +823,7 @@ int num; /* index of message */ */ if (ctl->errcount > olderrs) /* there were DNS errors above */ { - if (outlevel >= O_VERBOSE) + if (outlevel >= O_DEBUG) error(0,0, "forwarding and deletion suppressed due to DNS errors"); free(headers); free_str_list(&xmit_names); @@ -1438,7 +1438,7 @@ const struct method *proto; /* protocol method table */ #ifndef EHOSTUNREACH #define EHOSTUNREACH (-1) #endif - if (outlevel >= O_VERBOSE || errno != EHOSTUNREACH) + if (outlevel >= O_DEBUG || errno != EHOSTUNREACH) { error_build("fetchmail: %s connection to %s failed: ", protocol->name, ctl->server.pollname); @@ -1530,7 +1530,7 @@ const struct method *proto; /* protocol method table */ dispatches = 0; ++pass; - if (outlevel >= O_VERBOSE) + if (outlevel >= O_DEBUG) if (idp->id) error(0, 0, "selecting or re-polling folder %s", idp->id); else @@ -1865,7 +1865,7 @@ const struct method *proto; /* protocol method table */ */ if (msgsizes && msglen != msgsizes[num-1]) { - if (outlevel >= O_VERBOSE) + if (outlevel >= O_DEBUG) error(0, 0, "message %d was not the expected length (%d actual != %d expected)", num, msglen, msgsizes[num-1]); @@ -2050,7 +2050,7 @@ va_dcl strcat(buf, "\r\n"); SockWrite(sock, buf, strlen(buf)); - if (outlevel >= O_VERBOSE) + if (outlevel >= O_MONITOR) { char *cp; @@ -2092,7 +2092,7 @@ int size; /* length of buffer */ buf[strlen(buf)-1] = '\0'; if (buf[strlen(buf)-1] == '\r') buf[strlen(buf)-1] = '\0'; - if (outlevel >= O_VERBOSE) + if (outlevel >= O_MONITOR) error(0, 0, "%s< %s", protocol->name, buf); phase = oldphase; return(PS_SUCCESS); @@ -2137,7 +2137,7 @@ va_dcl strcat(buf, "\r\n"); SockWrite(sock, buf, strlen(buf)); - if (outlevel >= O_VERBOSE) + if (outlevel >= O_MONITOR) { char *cp; diff --git a/fetchmail-FAQ.html b/fetchmail-FAQ.html index e0c4a691..9f637124 100644 --- a/fetchmail-FAQ.html +++ b/fetchmail-FAQ.html @@ -10,7 +10,7 @@
Back to Fetchmail Home Page To Site Map -$Date: 1998/10/17 15:10:42 $ +$Date: 1998/10/17 16:24:27 $

Frequently Asked Questions About Fetchmail

@@ -388,14 +388,16 @@ to see these, or telnet direct to the server port (110 for POP3, 143 for IMAP).

The facility you are most likely to have available is APOP. This is a -POP3 feature supported by many servers. If you see something in the -greeting line that looks like an angle-bracket-enclosed Internet -address with a numeric left-hand part, that's an APOP challenge (it -will vary each time you log in). You can register a secret on the -host (using popauth(8) or some program like it). Specify -the secret as your password in your .fetchmailrc; it will be used to -encrypt the current challenge, and the encrypted form will be sent -back the the server for verification.

+POP3 feature supported by many servers (fetchmailconf's autoprobe +facility will detect it and tell you if you have it). If you see +something in the greeting line that looks like an +angle-bracket-enclosed Internet address with a numeric left-hand part, +that's an APOP challenge (it will vary each time you log in). You can +register a secret on the host (using popauth(8) or some +program like it). Specify the secret as your password in your +.fetchmailrc; it will be used to encrypt the current challenge, and +the encrypted form will be sent back the the server for +verification.

Alternatively, you may have Kerberos available. This may require you to set up some magic files in your home directory on your client @@ -423,7 +425,7 @@ OTP, you will specify a password but it will not be sent en clair.

Sadly, there is at present (July 1998) no OTP or APOP-like facility generally available on IMAP servers. However, there do exist patches which will OTP-enable the University of Washington IMAP -daemon, version 4.1-BETA. And we have a report that the GSSAPI +daemon, version 4.2-FINAL. And we have a report that the GSSAPI support in fetchmail works with the GSSAPI support in the most recent version of UW IMAP.

@@ -439,7 +441,7 @@ not currently a standard way to do this; fetchmail also uses this method, so the two will interoperate happily. They better, because this is how Craig gets his mail ;-)

-(One important win of OTP is that it's not subject to ITAR restrictions.)

+(One important win of OTP is that it's not subject to EAR restrictions.)


G9. Is any special configuration needed to use a dynamic IP address?

@@ -2182,7 +2184,7 @@ Re-ordering messages is a user-agent function, anyway.

Back to Fetchmail Home Page To Site Map -$Date: 1998/10/17 15:10:42 $ +$Date: 1998/10/17 16:24:27 $

Eric S. Raymond <esr@snark.thyrsus.com>
diff --git a/fetchmail.h b/fetchmail.h index 2143a89a..41d9da07 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -73,6 +73,7 @@ #define O_NORMAL 1 /* user-friendly */ #define O_VERBOSE 2 /* chatty */ #define O_DEBUG 3 /* prolix */ +#define O_MONITOR O_VERBOSE #define SIZETICKER 1024 /* print 1 dot per this many bytes */ diff --git a/imap.c b/imap.c index 29747e01..9441854f 100644 --- a/imap.c +++ b/imap.c @@ -141,7 +141,7 @@ static int do_otp(int sock, struct query *ctl) to64frombits(buffer, ctl->remotename, strlen(ctl->remotename)); - if (outlevel >= O_VERBOSE) + if (outlevel >= O_MONITOR) error(0, 0, "IMAP> %s", buffer); SockWrite(sock, buffer, strlen(buffer)); SockWrite(sock, "\r\n", 2); @@ -168,7 +168,7 @@ static int do_otp(int sock, struct query *ctl) to64frombits(buffer, response, strlen(response)); - if (outlevel >= O_VERBOSE) + if (outlevel >= O_MONITOR) error(0, 0, "IMAP> %s", buffer); SockWrite(sock, buffer, strlen(buffer)); SockWrite(sock, "\r\n", 2); @@ -308,7 +308,7 @@ static int do_rfc1731(int sock, char *truename) } to64frombits(buf1, authenticator.dat, authenticator.length); - if (outlevel >= O_VERBOSE) { + if (outlevel >= O_MONITOR) { error(0, 0, "IMAP> %s", buf1); } SockWrite(sock, buf1, strlen(buf1)); @@ -391,7 +391,7 @@ static int do_rfc1731(int sock, char *truename) &session, 1); to64frombits(buf1, authenticator.dat, authenticator.length); - if (outlevel >= O_VERBOSE) { + if (outlevel >= O_MONITOR) { error(0, 0, "IMAP> %s", buf1); } SockWrite(sock, buf1, strlen(buf1)); @@ -438,7 +438,7 @@ static int do_gssauth(int sock, char *hostname, char *username) error(0, -1, "Couldn't get service name for [%s]", buf1); return PS_AUTHFAIL; } - else if (outlevel >= O_VERBOSE) { + else if (outlevel >= O_DEBUG) { maj_stat = gss_display_name(&min_stat, target_name, &request_buf, &mech_name); error(0, 0, "Using service name [%s]",request_buf.value); @@ -475,7 +475,7 @@ static int do_gssauth(int sock, char *hostname, char *username) gss_release_buffer(&min_stat, &send_token); SockWrite(sock, buf1, strlen(buf1)); SockWrite(sock, "\r\n", 2); - if (outlevel >= O_VERBOSE) + if (outlevel >= O_MONITOR) error(0,0,"IMAP> %s", buf1); if (maj_stat == GSS_S_CONTINUE_NEEDED) { if (result = gen_recv(sock, buf1, sizeof buf1)) { @@ -503,7 +503,7 @@ static int do_gssauth(int sock, char *hostname, char *username) gss_release_buffer(&min_stat, &send_token); return PS_AUTHFAIL; } - if (outlevel >= O_VERBOSE) + if (outlevel >= O_DEBUG) error(0,0,"Credential exchange complete"); /* first octet is security levels supported. We want none, for now */ server_conf_flags = ((char *)send_token.value)[0]; @@ -516,7 +516,7 @@ static int do_gssauth(int sock, char *hostname, char *username) buf_size = ntohl(*((long *)send_token.value)); /* we don't care about buffer size if we don't wrap data */ gss_release_buffer(&min_stat, &send_token); - if (outlevel >= O_VERBOSE) { + if (outlevel >= O_DEBUG) { error(0,0,"Unwrapped security level flags: %s%s%s", server_conf_flags & GSSAUTH_P_NONE ? "N" : "-", server_conf_flags & GSSAUTH_P_INTEGRITY ? "I" : "-", @@ -538,7 +538,7 @@ static int do_gssauth(int sock, char *hostname, char *username) return PS_AUTHFAIL; } to64frombits(buf1, send_token.value, send_token.length); - if (outlevel >= O_VERBOSE) { + if (outlevel >= O_DEBUG) { error(0,0,"Requesting authorisation as %s", username); error(0,0,"IMAP> %s",buf1); } @@ -550,7 +550,7 @@ static int do_gssauth(int sock, char *hostname, char *username) return result; if (strstr(buf1, "OK")) { /* flush security context */ - if (outlevel >= O_VERBOSE) + if (outlevel >= O_DEBUG) error(0, 0, "Releasing GSS credentials"); maj_stat = gss_delete_sec_context(&min_stat, &context, &send_token); if (maj_stat != GSS_S_COMPLETE) { @@ -600,20 +600,20 @@ int imap_getauth(int sock, struct query *ctl, char *greeting) if (strstr(capabilities, "IMAP4REV1")) { imap_version = IMAP4rev1; - if (outlevel >= O_VERBOSE) + if (outlevel >= O_DEBUG) error(0, 0, "Protocol identified as IMAP4 rev 1"); } else { imap_version = IMAP4; - if (outlevel >= O_VERBOSE) + if (outlevel >= O_DEBUG) error(0, 0, "Protocol identified as IMAP4 rev 0"); } } else if (ok == PS_ERROR) { imap_version = IMAP2; - if (outlevel >= O_VERBOSE) + if (outlevel >= O_DEBUG) error(0, 0, "Protocol identified as IMAP2 or IMAP2BIS"); } else @@ -624,7 +624,7 @@ int imap_getauth(int sock, struct query *ctl, char *greeting) #if OPIE if ((ctl->server.protocol == P_IMAP) && strstr(capabilities, "AUTH=X-OTP")) { - if (outlevel >= O_VERBOSE) + if (outlevel >= O_DEBUG) error(0, 0, "OTP authentication is supported"); if (do_otp(sock, ctl) == PS_SUCCESS) return(PS_SUCCESS); @@ -636,7 +636,7 @@ int imap_getauth(int sock, struct query *ctl, char *greeting) { if (ctl->server.protocol == P_IMAP_GSS) { - if (outlevel >= O_VERBOSE) + if (outlevel >= O_DEBUG) error(0, 0, "GSS authentication is supported"); return do_gssauth(sock, ctl->server.truename, ctl->remotename); } @@ -651,14 +651,14 @@ int imap_getauth(int sock, struct query *ctl, char *greeting) #ifdef KERBEROS_V4 if (strstr(capabilities, "AUTH=KERBEROS_V4")) { - if (outlevel >= O_VERBOSE) + if (outlevel >= O_DEBUG) error(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_VERBOSE) + if (outlevel >= O_MONITOR) error(0, 0, "IMAP> *"); SockWrite(sock, "*\r\n", 3); } diff --git a/rpa.c b/rpa.c index 694a0123..e404e6aa 100644 --- a/rpa.c +++ b/rpa.c @@ -111,15 +111,15 @@ int POP3_auth_rpa (unsigned char *userid, unsigned char *passphrase, int socket) unsigned char *bufp; int status,aulin,kuslin; char* stdec[4] = { "Success" , - "Restricted user (something wrong with account)" , - "Invalid userid or passphrase" , - "Deity error" }; + "Restricted user (something wrong with account)" , + "Invalid userid or passphrase" , + "Deity error" }; /* Initiate RPA authorisation */ SockPrintf(socket,"AUTH RPA\r\n"); - if (outlevel >= O_VERBOSE) + if (outlevel >= O_MONITOR) error(0, 0, "> AUTH RPA\n"); /* Create unicode user name in Nu. */ @@ -133,7 +133,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_VERBOSE) + if (outlevel > O_SILENT && outlevel < O_MONITOR) error(0, 0, "%s\n",buf); return(ok); @@ -155,11 +155,11 @@ int POP3_auth_rpa (unsigned char *userid, unsigned char *passphrase, int socket) #ifndef TESTMODE SockPrintf(socket,"%s\r\n",buf); #endif - if (outlevel >= O_VERBOSE) + if (outlevel >= O_MONITOR) error(0, 0, "> %s\n",buf); if ((ok = POP3_rpa_resp(buf,socket)) != 0) { - if (outlevel > O_SILENT && outlevel < O_VERBOSE) + if (outlevel > O_SILENT && outlevel < O_MONITOR) error(0, 0, "%s\n",buf); return(ok); } @@ -176,12 +176,12 @@ int POP3_auth_rpa (unsigned char *userid, unsigned char *passphrase, int socket) /* Interpret Token 2 */ verh = *(bufp++); verl = *(bufp++); - if (outlevel >= O_VERBOSE) + if (outlevel >= O_DEBUG) error(0, 0, "Service chose RPA version %d.%d\n",verh,verl); Csl = *(bufp++); memcpy(Cs, bufp, Csl); bufp += Csl; - if (outlevel >= O_VERBOSE) + if (outlevel >= O_DEBUG) { error(0, 0, "Service challenge (l=%d):",Csl); for (i=0; i= O_VERBOSE) + if (outlevel >= O_DEBUG) error(0, 0, "Service timestamp %s\n",Ts); rll = *(bufp++) << 8; rll = rll | *(bufp++); if ((bufp-buf+rll) != rxlen) @@ -200,7 +200,7 @@ int POP3_auth_rpa (unsigned char *userid, unsigned char *passphrase, int socket) error(0, 0, "RPA token 2 length error\n"); return(PS_RPA); } - if (outlevel >= O_VERBOSE) + if (outlevel >= O_DEBUG) error(0, 0, "Realm list: %s\n",bufp); if (SetRealmService(bufp) != 0) { @@ -215,128 +215,128 @@ int POP3_auth_rpa (unsigned char *userid, unsigned char *passphrase, int socket) *(bufp++) = HDR; LenAppend(&bufp, 11+2+strlen(userid)+1+Cul+1+Rul ); memcpy(bufp, MECH, 11); bufp += 11; - *(bufp++) = 0; - *(bufp++) = strlen(userid); - memcpy(bufp,userid,strlen(userid)); bufp += strlen(userid); - GenChallenge(Cu,Cul); - *(bufp++) = Cul; - memcpy(bufp, Cu, Cul); bufp += Cul; - CompUserResp(); - *(bufp++) = Rul; - memcpy(bufp, Ru, Rul); bufp += Rul; - - /* Send Token 3, receive Token 4 */ - - EncBase64(buf,bufp-buf); + *(bufp++) = 0; + *(bufp++) = strlen(userid); + memcpy(bufp,userid,strlen(userid)); bufp += strlen(userid); + GenChallenge(Cu,Cul); + *(bufp++) = Cul; + memcpy(bufp, Cu, Cul); bufp += Cul; + CompUserResp(); + *(bufp++) = Rul; + memcpy(bufp, Ru, Rul); bufp += Rul; + + /* Send Token 3, receive Token 4 */ + + EncBase64(buf,bufp-buf); #ifndef TESTMODE - SockPrintf(socket,"%s\r\n",buf); + SockPrintf(socket,"%s\r\n",buf); #endif - if (outlevel >= O_VERBOSE) - error(0, 0, "> %s\n",buf); - if ((ok = POP3_rpa_resp(buf,socket)) != 0) + if (outlevel >= O_MONITOR) + error(0, 0, "> %s\n",buf); + if ((ok = POP3_rpa_resp(buf,socket)) != 0) { - if (outlevel > O_SILENT && outlevel < O_VERBOSE) - error(0, 0, "%s\n",buf); - return(ok); + if (outlevel > O_SILENT && outlevel < O_MONITOR) + error(0, 0, "%s\n",buf); + return(ok); } - if ((rxlen = DecBase64(buf)) == 0) + if ((rxlen = DecBase64(buf)) == 0) { - if (outlevel > O_SILENT) - error(0, 0, "RPA token 4: Base64 decode error\n"); - return(PS_RPA); + if (outlevel > O_SILENT) + error(0, 0, "RPA token 4: Base64 decode error\n"); + return(PS_RPA); } - bufp = buf; - if (LenSkip(&bufp,rxlen) == 0) return(PS_RPA); + bufp = buf; + if (LenSkip(&bufp,rxlen) == 0) return(PS_RPA); - /* Interpret Token 4 */ + /* Interpret Token 4 */ - aulin = *(bufp++); - if (outlevel >= O_VERBOSE) + aulin = *(bufp++); + if (outlevel >= O_DEBUG) { - error(0, 0, "User authentication (l=%d):",aulin); - for (i=0; i= O_VERBOSE) - error(0, 0, "RPA status: %02X\n",status); + status = *(bufp++); + if (outlevel >= O_DEBUG) + error(0, 0, "RPA status: %02X\n",status); } - else status = 0; - if ((bufp - buf) != rxlen) + else status = 0; + if ((bufp - buf) != rxlen) { - if (outlevel > O_SILENT) - error(0, 0, "RPA token 4 length error\n"); - return(PS_RPA); + if (outlevel > O_SILENT) + error(0, 0, "RPA token 4 length error\n"); + return(PS_RPA); } - if (status != 0) + if (status != 0) { - if (outlevel > O_SILENT) - if (status < 4) - error(0, 0, "RPA rejects you: %s\n",stdec[status]); - else - error(0, 0, "RPA rejects you, reason unknown\n"); - return(PS_AUTHFAIL); + if (outlevel > O_SILENT) + if (status < 4) + error(0, 0, "RPA rejects you: %s\n",stdec[status]); + else + error(0, 0, "RPA rejects you, reason unknown\n"); + return(PS_AUTHFAIL); } - if (Aul != aulin) + if (Aul != aulin) { - error(0, 0, "RPA User Authentication length error: %d\n",aulin); - return(PS_RPA); + error(0, 0, "RPA User Authentication length error: %d\n",aulin); + return(PS_RPA); } - if (Kusl != kuslin) + if (Kusl != kuslin) { - error(0, 0, "RPA Session key length error: %d\n",kuslin); - return(PS_RPA); + error(0, 0, "RPA Session key length error: %d\n",kuslin); + return(PS_RPA); } - if (CheckUserAuth() != 0) + if (CheckUserAuth() != 0) { - if (outlevel > O_SILENT) - error(0, 0, "RPA _service_ auth fail. Spoof server?\n"); - return(PS_AUTHFAIL); + if (outlevel > O_SILENT) + error(0, 0, "RPA _service_ auth fail. Spoof server?\n"); + return(PS_AUTHFAIL); } - if (outlevel >= O_VERBOSE) + if (outlevel >= O_DEBUG) { - error(0, 0, "Session key established:"); - for (i=0; i= O_VERBOSE) - error(0, 0, "> %s\n",buf); - if ((ok = POP3_rpa_resp(buf,socket)) != 0) - { - if (outlevel > O_SILENT && outlevel < O_VERBOSE) - error(0, 0, "%s\n",buf); - return(ok); - } + if (outlevel >= O_MONITOR) + error(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); + return(ok); + } } - if (outlevel > O_SILENT) - error(0, 0, "RPA authorisation complete\n"); + if (outlevel > O_SILENT) + error(0, 0, "RPA authorisation complete\n"); - return(PS_SUCCESS); + return(PS_SUCCESS); } @@ -357,45 +357,45 @@ static int POP3_rpa_resp (argbuf,socket) unsigned char *argbuf; int socket; { - int ok; - char buf [POPBUFSIZE]; - char *bufp; - int sockrc; + int ok; + char buf [POPBUFSIZE]; + char *bufp; + int sockrc; - if (outlevel >= O_VERBOSE) - error(0, 0, "Get response\n"); + if (outlevel >= O_DEBUG) + error(0, 0, "Get response\n"); #ifndef TESTMODE - sockrc = gen_recv(socket, buf, sizeof(buf)); + sockrc = gen_recv(socket, buf, sizeof(buf)); #else - linecount++; - if (linecount == 1) strcpy(buf,line1); - if (linecount == 2) strcpy(buf,line2); - if (linecount == 3) strcpy(buf,line3); + linecount++; + if (linecount == 1) strcpy(buf,line1); + if (linecount == 2) strcpy(buf,line2); + if (linecount == 3) strcpy(buf,line3); /* error(0, 0, "--> "); fflush(stderr); */ /* scanf("%s",&buf) */ - sockrc = PS_SUCCESS; + sockrc = PS_SUCCESS; #endif - if (sockrc == PS_SUCCESS) { - bufp = buf; - if ((*buf) == '+') - { - bufp++; + if (sockrc == PS_SUCCESS) { + bufp = buf; + if ((*buf) == '+') + { + bufp++; /* if (*bufp == ' ') bufp++; */ - if (argbuf != NULL) - strcpy(argbuf,bufp); - ok=0; - } - else if (strcmp(buf,"-ERR") == 0) - ok = PS_ERROR; - else ok = PS_PROTOCOL; - - } - else - ok = PS_SOCKET; - if (outlevel >= O_VERBOSE) - error(0, 0, "Get response return %d [%s]\n", ok, buf); - buf[sockrc] = 0; - return(ok); + if (argbuf != NULL) + strcpy(argbuf,bufp); + ok=0; + } + else if (strcmp(buf,"-ERR") == 0) + ok = PS_ERROR; + else ok = PS_PROTOCOL; + + } + else + ok = PS_SOCKET; + if (outlevel >= O_DEBUG) + error(0, 0, "Get response return %d [%s]\n", ok, buf); + buf[sockrc] = 0; + return(ok); } /********************************************************************* @@ -416,20 +416,20 @@ static void LenAppend(pptr,len) unsigned char **pptr; int len; { - if (len < 0x80) + if (len < 0x80) { - **pptr = len; (*pptr)++; + **pptr = len; (*pptr)++; } - else if (len < 0x100) + else if (len < 0x100) { - **pptr = 0x81; (*pptr)++; - **pptr = len; (*pptr)++; + **pptr = 0x81; (*pptr)++; + **pptr = len; (*pptr)++; } - else + else { - **pptr = 0x82; (*pptr)++; - **pptr = len >> 8; (*pptr)++; - **pptr = len & 0xFF; (*pptr)++; + **pptr = 0x82; (*pptr)++; + **pptr = len >> 8; (*pptr)++; + **pptr = len & 0xFF; (*pptr)++; } } @@ -450,48 +450,48 @@ int LenSkip(pptr,rxlen) unsigned char **pptr; int rxlen; { - int len; - unsigned char *save; - save = *pptr; - if (**pptr != HDR) + int len; + unsigned char *save; + save = *pptr; + if (**pptr != HDR) { - if (outlevel > O_SILENT) error(0, 0, "Hdr not 60\n"); - return(0); + if (outlevel > O_SILENT) error(0, 0, "Hdr not 60\n"); + return(0); } - (*pptr)++; - if (((**pptr) & 0x80) == 0 ) + (*pptr)++; + if (((**pptr) & 0x80) == 0 ) { - len = **pptr; (*pptr)++; + len = **pptr; (*pptr)++; } - else if ((**pptr) == 0x81) + else if ((**pptr) == 0x81) { - len = *(*pptr+1); (*pptr) += 2; + len = *(*pptr+1); (*pptr) += 2; } - else if ((**pptr) == 0x82) + else if ((**pptr) == 0x82) { - len = ((*(*pptr+1)) << 8) | *(*pptr+2); - (*pptr) += 3; + len = ((*(*pptr+1)) << 8) | *(*pptr+2); + (*pptr) += 3; } - else len = 0; - if (len==0) + else len = 0; + if (len==0) { - if (outlevel>O_SILENT) - error(0, 0, "Token length error\n"); + if (outlevel>O_SILENT) + error(0, 0, "Token length error\n"); } - else if (((*pptr-save)+len) != rxlen) + else if (((*pptr-save)+len) != rxlen) { - if (outlevel>O_SILENT) - error(0, 0, "Token Length %d disagrees with rxlen %d\n",len,rxlen); - len = 0; + if (outlevel>O_SILENT) + error(0, 0, "Token Length %d disagrees with rxlen %d\n",len,rxlen); + len = 0; } - else if (memcmp(*pptr,MECH,11)) + else if (memcmp(*pptr,MECH,11)) { - if (outlevel > O_SILENT) - error(0, 0, "Mechanism field incorrect\n"); - len = 0; + if (outlevel > O_SILENT) + error(0, 0, "Mechanism field incorrect\n"); + len = 0; } - else (*pptr) += 11; /* Skip mechanism field */ - return(len); + else (*pptr) += 11; /* Skip mechanism field */ + return(len); } /********************************************************************* @@ -510,44 +510,44 @@ int rxlen; static int DecBase64(bufp) unsigned char *bufp; { - unsigned int new, bits=0, cnt=0, i, part=0; - unsigned char ch; - unsigned char* outp=bufp; - unsigned char* inp=bufp; - while((ch=*(inp++)) != 0) - { - if ((ch != '=') && (ch != ' ') && (ch != '\n') && (ch != '\r')) - { - if ((ch>='A') && (ch <= 'Z')) new = ch - 'A'; - else if ((ch>='a') && (ch <= 'z')) new = ch - 'a' + 26; - else if ((ch>='0') && (ch <= '9')) new = ch - '0' + 52; - else if ( ch=='+' ) new = 62; - else if ( ch=='/' ) new = 63; - else { - error(0, 0, "dec64 error at char %d: %x\n", inp - bufp, ch); - return(0); - } - part=((part & 0x3F)*64) + new; - bits += 6; - if (bits >= 8) - { - bits -= 8; - *outp = (part >> bits); - cnt++; outp++; - } - } - } - if (outlevel >= O_VERBOSE) - { - error(0, 0, "Inbound binary data:\n"); - for (i=0; i='A') && (ch <= 'Z')) new = ch - 'A'; + else if ((ch>='a') && (ch <= 'z')) new = ch - 'a' + 26; + else if ((ch>='0') && (ch <= '9')) new = ch - '0' + 52; + else if ( ch=='+' ) new = 62; + else if ( ch=='/' ) new = 63; + else { + error(0, 0, "dec64 error at char %d: %x\n", inp - bufp, ch); + return(0); + } + part=((part & 0x3F)*64) + new; + bits += 6; + if (bits >= 8) + { + bits -= 8; + *outp = (part >> bits); + cnt++; outp++; + } + } + } + if (outlevel >= O_MONITOR) + { + error(0, 0, "Inbound binary data:\n"); + for (i=0; i= O_VERBOSE) - { - error(0, 0, "Outbound data:\n"); - for (i=0; i=0; i-=3) - { - c1 = bufp[i]; - if ((i+1) < len) c2 = bufp[i+1]; else c2=0; - if ((i+2) < len) c3 = bufp[i+2]; else c3=0; - *(outp) = x[c1/4]; - *(outp+1) = x[((c1 & 3)*16) + (c2/16)]; - if ((i+1) < len) *(outp+2) = x[((c2 & 0x0F)*4) + (c3/64)]; - else *(outp+2) = '='; - if ((i+2) < len) *(outp+3) = x[c3 & 0x3F]; - else *(outp+3) = '='; - outp -= 4; + unsigned char* outp; + unsigned char c1,c2,c3; + char x[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + int i; + + if (outlevel >= O_MONITOR) + { + error(0, 0, "Outbound data:\n"); + for (i=0; i=0; i-=3) + { + c1 = bufp[i]; + if ((i+1) < len) c2 = bufp[i+1]; else c2=0; + if ((i+2) < len) c3 = bufp[i+2]; else c3=0; + *(outp) = x[c1/4]; + *(outp+1) = x[((c1 & 3)*16) + (c2/16)]; + if ((i+1) < len) *(outp+2) = x[((c2 & 0x0F)*4) + (c3/64)]; + else *(outp+2) = '='; + if ((i+2) < len) *(outp+3) = x[c3 & 0x3F]; + else *(outp+3) = '='; + outp -= 4; } } @@ -627,34 +627,34 @@ unsigned char *buf; /* output buffer */ int *plen; int conv; { - unsigned char *p; - int i; - *plen = 0; p=buf; - while ( ((**pptr)!=delim) && ((**pptr)!=0) && ((*plen) O_SILENT) - error(0, 0, "RPA String too long\n"); - *plen = 0; + if (outlevel > O_SILENT) + error(0, 0, "RPA String too long\n"); + *plen = 0; } - if (outlevel >= O_VERBOSE) + if (outlevel >= O_DEBUG) { - error(0, 0, "Unicode:"); - for (i=0; i<(*plen); i++) - { - error_build("%02X ",buf[i]); - if (((i % 16)==15) || (i==((*plen)-1))) - error_complete(0, 0, ""); - } + error(0, 0, "Unicode:"); + for (i=0; i<(*plen); i++) + { + error_build("%02X ",buf[i]); + if (((i % 16)==15) || (i==((*plen)-1))) + error_complete(0, 0, ""); + } } } @@ -674,16 +674,16 @@ int conv; static int SetRealmService(bufp) unsigned char* bufp; { - /* For the moment we pick the first available realm. It would */ - /* make more sense to verify that the realm which the user */ - /* has given (as part of id) is in the list, and select it's */ - /* corresponding service name. */ - ToUnicode(&bufp, '@', Ns, &Nsl, 1); /* Service */ - bufp++; /* Skip the @ */ - ToUnicode(&bufp, ' ', Nr, &Nrl, 1); /* Realm name */ - if ((Nrl == 0) || (Nsl == 0)) - return(PS_RPA); - return(0); + /* For the moment we pick the first available realm. It would */ + /* make more sense to verify that the realm which the user */ + /* has given (as part of id) is in the list, and select it's */ + /* corresponding service name. */ + ToUnicode(&bufp, '@', Ns, &Nsl, 1); /* Service */ + bufp++; /* Skip the @ */ + ToUnicode(&bufp, ' ', Nr, &Nrl, 1); /* Realm name */ + if ((Nrl == 0) || (Nsl == 0)) + return(PS_RPA); + return(0); } /********************************************************************* @@ -723,7 +723,7 @@ int len; if (devrandom) fclose(devrandom); - if (outlevel >= O_VERBOSE) + if (outlevel >= O_DEBUG) { error(0, 0, "User challenge:"); for (i=0; i= O_VERBOSE) - { - error(0, 0, "MD5 being applied to data block:\n"); - for (i=0; i= O_VERBOSE) + if (outlevel >= O_DEBUG) { - error(0, 0, "MD5 result is: "); - for (i=0; i<16; i++) - { - error_build("%02X ",out[i]); - } - error_complete(0, 0, ""); + error(0, 0, "MD5 being applied to data block:\n"); + for (i=0; i= O_DEBUG) + { + error(0, 0, "MD5 result is: "); + for (i=0; i<16; i++) + { + error_build("%02X ",out[i]); + } + error_complete(0, 0, ""); } } #endif /* POP3_ENABLE && RPA_ENABLE */ diff --git a/sink.c b/sink.c index 0f2afc87..e9d445ce 100644 --- a/sink.c +++ b/sink.c @@ -156,7 +156,7 @@ static int smtp_open(struct query *ctl) */ ctl->destaddr = ctl->smtpaddress ? ctl->smtpaddress : ( ctl->smtphost ? ctl->smtphost : "localhost"); - if (outlevel >= O_VERBOSE && ctl->smtp_socket != -1) + if (outlevel >= O_DEBUG && ctl->smtp_socket != -1) error(0, 0, "forwarding to %s", ctl->smtphost); return(ctl->smtp_socket); @@ -374,7 +374,7 @@ int open_sink(struct query *ctl, } - if (outlevel >= O_VERBOSE) + if (outlevel >= O_DEBUG) error(0, 0, "about to deliver with: %s", before); #ifdef HAVE_SETEUID diff --git a/smtp.c b/smtp.c index 0328f86c..b578fc15 100644 --- a/smtp.c +++ b/smtp.c @@ -38,7 +38,7 @@ int SMTP_helo(int sock,char *host) int ok; SockPrintf(sock,"HELO %s\r\n", host); - if (outlevel >= O_VERBOSE) + if (outlevel >= O_MONITOR) error(0, 0, "SMTP> HELO %s", host); ok = SMTP_ok(sock); return ok; @@ -50,7 +50,7 @@ int SMTP_ehlo(int sock, char *host, int *opt) struct opt *hp; SockPrintf(sock,"EHLO %s\r\n", host); - if (outlevel >= O_VERBOSE) + if (outlevel >= O_MONITOR) error(0, 0, "SMTP> EHLO %s", host); *opt = 0; @@ -65,7 +65,7 @@ int SMTP_ehlo(int sock, char *host, int *opt) if (n < 4) return SM_ERROR; smtp_response[n] = '\0'; - if (outlevel >= O_VERBOSE) + if (outlevel >= O_MONITOR) error(0, 0, "SMTP< %s", smtp_response); for (hp = extensions; hp->name; hp++) if (!strncasecmp(hp->name, smtp_response+4, strlen(hp->name))) @@ -91,7 +91,7 @@ int SMTP_from(int sock, char *from, char *opts) if (opts) strcat(buf, opts); SockPrintf(sock,"%s\r\n", buf); - if (outlevel >= O_VERBOSE) + if (outlevel >= O_MONITOR) error(0, 0, "SMTP> %s", buf); ok = SMTP_ok(sock); return ok; @@ -103,7 +103,7 @@ int SMTP_rcpt(int sock, char *to) int ok; SockPrintf(sock,"RCPT TO:<%s>\r\n", to); - if (outlevel >= O_VERBOSE) + if (outlevel >= O_MONITOR) error(0, 0, "SMTP> RCPT TO:<%s>", to); ok = SMTP_ok(sock); return ok; @@ -115,7 +115,7 @@ int SMTP_data(int sock) int ok; SockPrintf(sock,"DATA\r\n"); - if (outlevel >= O_VERBOSE) + if (outlevel >= O_MONITOR) error(0, 0, "SMTP> DATA"); ok = SMTP_ok(sock); return ok; @@ -127,7 +127,7 @@ int SMTP_rset(int sock) int ok; SockPrintf(sock,"RSET\r\n"); - if (outlevel >= O_VERBOSE) + if (outlevel >= O_MONITOR) error(0, 0, "SMTP> RSET"); ok = SMTP_ok(sock); return ok; @@ -139,7 +139,7 @@ int SMTP_quit(int sock) int ok; SockPrintf(sock,"QUIT\r\n"); - if (outlevel >= O_VERBOSE) + if (outlevel >= O_MONITOR) error(0, 0, "SMTP> QUIT"); ok = SMTP_ok(sock); return ok; @@ -151,7 +151,7 @@ int SMTP_eom(int sock) int ok; SockPrintf(sock,".\r\n"); - if (outlevel >= O_VERBOSE) + if (outlevel >= O_MONITOR) error(0, 0, "SMTP>. (EOM)"); ok = SMTP_ok(sock); return ok; @@ -171,7 +171,7 @@ int SMTP_ok(int sock) if (n < 4) return SM_ERROR; smtp_response[n] = '\0'; - if (outlevel >= O_VERBOSE) + if (outlevel >= O_MONITOR) error(0, 0, "SMTP< %s", smtp_response); if ((smtp_response[0] == '1' || smtp_response[0] == '2' || smtp_response[0] == '3') && smtp_response[3] == ' ') return SM_OK; -- cgit v1.2.3