masqmail

diff src/smtp_out.c @ 177:6530806d418f

better debug logging of outgoing SMTP dialogs the dialog is logged in the style of the RFC examples: ``C: foo'' is said by the client, ``S: bar'' is said by the server debug level 4 is used, but login data is logged on level 6
author meillo@marmaro.de
date Wed, 14 Jul 2010 16:35:17 +0200
parents a39c8ee61185
children 10da50168dab
line diff
     1.1 --- a/src/smtp_out.c	Wed Jul 14 16:26:12 2010 +0200
     1.2 +++ b/src/smtp_out.c	Wed Jul 14 16:35:17 2010 +0200
     1.3 @@ -174,6 +174,9 @@
     1.4  		buf_pos += len;
     1.5  
     1.6  	} while (code[3] == '-');
     1.7 +	if (psb->buffer) {
     1.8 +		DEBUG(4) debugf("S: %s\n", psb->buffer);
     1.9 +	}
    1.10  
    1.11  	return TRUE;
    1.12  }
    1.13 @@ -294,13 +297,13 @@
    1.14  			fprintf(psb->out, "EHLO %s\r\n", helo);
    1.15  			fflush(psb->out);
    1.16  
    1.17 -			DEBUG(4) debugf("EHLO %s\r\n", helo);
    1.18 +			DEBUG(4) debugf("C: EHLO %s\r\n", helo);
    1.19  
    1.20  		} else {
    1.21  			fprintf(psb->out, "HELO %s\r\n", helo);
    1.22  			fflush(psb->out);
    1.23  
    1.24 -			DEBUG(4) debugf("HELO %s\r\n", helo);
    1.25 +			DEBUG(4) debugf("C: HELO %s\r\n", helo);
    1.26  
    1.27  		}
    1.28  
    1.29 @@ -331,13 +334,13 @@
    1.30  		fprintf(psb->out, "MAIL FROM:%s SIZE=%d\r\n", addr_string(return_path), size);
    1.31  		fflush(psb->out);
    1.32  
    1.33 -		DEBUG(4) debugf("MAIL FROM:%s SIZE=%d\r\n", addr_string(return_path), size);
    1.34 +		DEBUG(4) debugf("C: MAIL FROM:%s SIZE=%d\r\n", addr_string(return_path), size);
    1.35  
    1.36  	} else {
    1.37  		fprintf(psb->out, "MAIL FROM:%s\r\n", addr_string(return_path));
    1.38  		fflush(psb->out);
    1.39  
    1.40 -		DEBUG(4) debugf("MAIL FROM:%s\r\n", addr_string(return_path));
    1.41 +		DEBUG(4) debugf("C: MAIL FROM:%s\r\n", addr_string(return_path));
    1.42  	}
    1.43  }
    1.44  
    1.45 @@ -346,7 +349,7 @@
    1.46  {
    1.47  	fprintf(psb->out, "RCPT TO:%s\r\n", addr_string(rcpt));
    1.48  	fflush(psb->out);
    1.49 -	DEBUG(4) debugf("RCPT TO:%s\n", addr_string(rcpt));
    1.50 +	DEBUG(4) debugf("C: RCPT TO:%s\n", addr_string(rcpt));
    1.51  }
    1.52  
    1.53  static void
    1.54 @@ -426,6 +429,7 @@
    1.55  
    1.56  	fprintf(psb->out, ".\r\n");
    1.57  	fflush(psb->out);
    1.58 +	DEBUG(4) debugf("C: .\n");
    1.59  }
    1.60  
    1.61  void
    1.62 @@ -525,7 +529,7 @@
    1.63  
    1.64  	fprintf(psb->out, "RSET\r\n");
    1.65  	fflush(psb->out);
    1.66 -	DEBUG(4) debugf("RSET\n");
    1.67 +	DEBUG(4) debugf("C: RSET\n");
    1.68  
    1.69  	if ((ok = read_response(psb, SMTP_CMD_TIMEOUT)))
    1.70  		if (check_response(psb, FALSE))
    1.71 @@ -543,7 +547,7 @@
    1.72  {
    1.73  	gboolean ok = FALSE;
    1.74  
    1.75 -	fprintf(psb->out, "AUTH CRAM-MD5\r\n");
    1.76 +	fprintf(psb->out, "C: AUTH CRAM-MD5\r\n");
    1.77  	fflush(psb->out);
    1.78  	DEBUG(4) debugf("AUTH CRAM-MD5\n");
    1.79  	if ((ok = read_response(psb, SMTP_CMD_TIMEOUT))) {
    1.80 @@ -583,7 +587,8 @@
    1.81  
    1.82  			fprintf(psb->out, "%s\r\n", reply64);
    1.83  			fflush(psb->out);
    1.84 -			DEBUG(4) debugf("  reply64 = %s\n", reply64);
    1.85 +			DEBUG(6) debugf("  reply64 = %s\n", reply64);
    1.86 +			DEBUG(6) debugf("C: %s\n", reply64);
    1.87  
    1.88  			if ((ok = read_response(psb, SMTP_CMD_TIMEOUT)))
    1.89  				ok = check_response(psb, FALSE);
    1.90 @@ -603,6 +608,7 @@
    1.91  	gboolean ok = FALSE;
    1.92  	fprintf(psb->out, "AUTH LOGIN\r\n");
    1.93  	fflush(psb->out);
    1.94 +	DEBUG(4) debugf("C: AUTH LOGIN\r\n");
    1.95  	if ((ok = read_response(psb, SMTP_CMD_TIMEOUT))) {
    1.96  		if ((ok = check_response(psb, TRUE))) {
    1.97  			gchar *resp64;
    1.98 @@ -620,6 +626,7 @@
    1.99  			reply64 = base64_encode(psb->auth_login, strlen(psb->auth_login));
   1.100  			fprintf(psb->out, "%s\r\n", reply64);
   1.101  			fflush(psb->out);
   1.102 +			DEBUG(6) debugf("C: %s\n", reply64);
   1.103  			g_free(reply64);
   1.104  			if ((ok = read_response(psb, SMTP_CMD_TIMEOUT))) {
   1.105  				if ((ok = check_response(psb, TRUE))) {
   1.106 @@ -632,6 +639,7 @@
   1.107  					reply64 = base64_encode(psb->auth_secret, strlen(psb->auth_secret));
   1.108  					fprintf(psb->out, "%s\r\n", reply64);
   1.109  					fflush(psb->out);
   1.110 +					DEBUG(6) debugf("C: %s\n", reply64);
   1.111  					g_free(reply64);
   1.112  					if ((ok = read_response(psb, SMTP_CMD_TIMEOUT)))
   1.113  						ok = check_response(psb, FALSE);
   1.114 @@ -775,7 +783,7 @@
   1.115  			fprintf(psb->out, "DATA\r\n");
   1.116  			fflush(psb->out);
   1.117  
   1.118 -			DEBUG(4) debugf("DATA\r\n");
   1.119 +			DEBUG(4) debugf("C: DATA\r\n");
   1.120  
   1.121  			if (psb->use_pipelining) {
   1.122  				/* the first pl'ed command was MAIL FROM
   1.123 @@ -879,7 +887,7 @@
   1.124  	fprintf(psb->out, "QUIT\r\n");
   1.125  	fflush(psb->out);
   1.126  
   1.127 -	DEBUG(4) debugf("QUIT\n");
   1.128 +	DEBUG(4) debugf("C: QUIT\n");
   1.129  
   1.130  	signal(SIGALRM, SIG_DFL);
   1.131