masqmail-0.2

diff src/smtp_out.c @ 114:a80ebfa16cd5

better debugging output (thanks to Paolo)
author meillo@marmaro.de
date Wed, 30 Jun 2010 15:00:59 +0200
parents f671821d8222
children 1e2fd87d58ea
line diff
     1.1 --- a/src/smtp_out.c	Wed Jun 30 13:23:49 2010 +0200
     1.2 +++ b/src/smtp_out.c	Wed Jun 30 15:00:59 2010 +0200
     1.3 @@ -262,8 +262,9 @@
     1.4  
     1.5  					DEBUG(4) {
     1.6  						gint i = 0;
     1.7 +						debugf("in check_helo_response()\n");
     1.8  						while (psb->auth_names[i]) {
     1.9 -							debugf("offered AUTH %s\n", psb->auth_names[i]);
    1.10 +							debugf("  offered AUTH %s\n", psb->auth_names[i]);
    1.11  							i++;
    1.12  						}
    1.13  					}
    1.14 @@ -277,9 +278,9 @@
    1.15  	}
    1.16  
    1.17  	DEBUG(4) {
    1.18 -		debugf(psb->use_size ? "uses SIZE\n" : "no size\n");
    1.19 -		debugf(psb->use_pipelining ? "uses PIPELINING\n" : "no pipelining\n");
    1.20 -		debugf(psb->use_auth ? "uses AUTH\n" : "no auth\n");
    1.21 +		debugf("  %s\n", psb->use_size ? "uses SIZE" : "no size");
    1.22 +		debugf("  %s\n", psb->use_pipelining ? "uses PIPELINING" : "no pipelining");
    1.23 +		debugf("  %s\n", psb->use_auth ? "uses AUTH" : "no auth");
    1.24  	}
    1.25  
    1.26  	return TRUE;
    1.27 @@ -555,10 +556,10 @@
    1.28  			unsigned int digest_len;
    1.29  #endif
    1.30  
    1.31 -			DEBUG(5) debugf("encoded challenge = %s\n", chall64);
    1.32 -			DEBUG(5) debugf("decoded challenge = %s, size = %d\n", chall, chall_size);
    1.33 -
    1.34 -			DEBUG(5) debugf("secret = %s\n", psb->auth_secret);
    1.35 +			DEBUG(5) debugf("smtp_out_auth_cram_md5():\n");
    1.36 +			DEBUG(5) debugf("  encoded challenge = %s\n", chall64);
    1.37 +			DEBUG(5) debugf("  decoded challenge = %s, size = %d\n", chall, chall_size);
    1.38 +			DEBUG(5) debugf("  secret = %s\n", psb->auth_secret);
    1.39  
    1.40  #ifdef USE_LIB_CRYPTO
    1.41  			HMAC(EVP_md5(), psb->auth_secret, strlen(psb->auth_secret), chall, chall_size, digest, &digest_len);
    1.42 @@ -570,17 +571,17 @@
    1.43  				sprintf(&(digest_string[i + i]), "%02x", (unsigned int) (digest[i]));
    1.44  			digest_string[32] = '\0';
    1.45  
    1.46 -			DEBUG(5) debugf("digest = %s\n", digest_string);
    1.47 +			DEBUG(5) debugf("  digest = %s\n", digest_string);
    1.48  
    1.49  			reply = g_strdup_printf("%s %s", psb->auth_login, digest_string);
    1.50 -			DEBUG(5) debugf("unencoded reply = %s\n", reply);
    1.51 +			DEBUG(5) debugf("  unencoded reply = %s\n", reply);
    1.52  
    1.53  			reply64 = base64_encode(reply, strlen(reply));
    1.54 -			DEBUG(5) debugf("encoded reply = %s\n", reply64);
    1.55 +			DEBUG(5) debugf("  encoded reply = %s\n", reply64);
    1.56  
    1.57  			fprintf(psb->out, "%s\r\n", reply64);
    1.58  			fflush(psb->out);
    1.59 -			DEBUG(4) debugf("%s\n", reply64);
    1.60 +			DEBUG(4) debugf("  reply64 = %s\n", reply64);
    1.61  
    1.62  			if ((ok = read_response(psb, SMTP_CMD_TIMEOUT)))
    1.63  				ok = check_response(psb, FALSE);
    1.64 @@ -607,11 +608,12 @@
    1.65  			gint resp_size;
    1.66  			gchar *reply64;
    1.67  
    1.68 +			DEBUG(5) debugf("smtp_out_auth_login():\n");
    1.69  			resp64 = get_response_arg(&(psb->buffer[4]));
    1.70 -			DEBUG(5) debugf("encoded response = %s\n", resp64);
    1.71 +			DEBUG(5) debugf("  encoded response = %s\n", resp64);
    1.72  			resp = base64_decode(resp64, &resp_size);
    1.73  			g_free(resp64);
    1.74 -			DEBUG(5) debugf("decoded response = %s, size = %d\n", resp, resp_size);
    1.75 +			DEBUG(5) debugf("  decoded response = %s, size = %d\n", resp, resp_size);
    1.76  			g_free(resp);
    1.77  			reply64 = base64_encode(psb->auth_login, strlen(psb->auth_login));
    1.78  			fprintf(psb->out, "%s\r\n", reply64);
    1.79 @@ -620,10 +622,10 @@
    1.80  			if ((ok = read_response(psb, SMTP_CMD_TIMEOUT))) {
    1.81  				if ((ok = check_response(psb, TRUE))) {
    1.82  					resp64 = get_response_arg(&(psb->buffer[4]));
    1.83 -					DEBUG(5) debugf("encoded response = %s\n", resp64);
    1.84 +					DEBUG(5) debugf("  encoded response = %s\n", resp64);
    1.85  					resp = base64_decode(resp64, &resp_size);
    1.86  					g_free(resp64);
    1.87 -					DEBUG(5) debugf("decoded response = %s, size = %d\n", resp, resp_size);
    1.88 +					DEBUG(5) debugf("  decoded response = %s, size = %d\n", resp, resp_size);
    1.89  					g_free(resp);
    1.90  					reply64 = base64_encode(psb->auth_secret, strlen(psb->auth_secret));
    1.91  					fprintf(psb->out, "%s\r\n", reply64);
    1.92 @@ -712,7 +714,8 @@
    1.93  
    1.94  	/* respect maximum size given by server: */
    1.95  	if ((psb->max_size > 0) && (size > psb->max_size)) {
    1.96 -		logwrite(LOG_WARNING, "%s == host=%s message size (%d) > fixed maximum message size of server (%d)",
    1.97 +		logwrite(LOG_WARNING, "%s == host=%s message size (%d) > "
    1.98 +		                      "fixed maximum message size of server (%d)",
    1.99  		         msg->uid, psb->remote_host, size, psb->max_size);
   1.100  		psb->error = smtp_cancel;
   1.101  		ok = FALSE;
   1.102 @@ -747,7 +750,7 @@
   1.103  							ok = FALSE;
   1.104  							break;
   1.105  						} else {
   1.106 -							logwrite(LOG_NOTICE, "%s == %s host=%s failed: %s",
   1.107 +							logwrite(LOG_NOTICE, "%s == %s host=%s failed: %s\n",
   1.108  							         msg->uid, addr_string(rcpt), psb->remote_host, psb->buffer);
   1.109  							if (psb->error == smtp_trylater) {
   1.110  								addr_mark_defered(rcpt);
   1.111 @@ -798,7 +801,7 @@
   1.112  										ok = FALSE;
   1.113  										break;
   1.114  									} else {
   1.115 -										logwrite(LOG_NOTICE, "%s == %s host=%s failed: %s", msg->uid,
   1.116 +										logwrite(LOG_NOTICE, "%s == %s host=%s failed: %s\n", msg->uid,
   1.117  										         addr_string(rcpt), psb->remote_host, psb->buffer);
   1.118  										if (psb->error == smtp_trylater) {
   1.119  											addr_mark_defered(rcpt);
   1.120 @@ -840,9 +843,10 @@
   1.121  	}
   1.122  
   1.123  	DEBUG(5) {
   1.124 -		debugf("psb->error = %d\n", psb->error);
   1.125 -		debugf("ok = %d\n", ok);
   1.126 -		debugf("rcpt_accept = %d\n", rcpt_accept);
   1.127 +		debugf("smtp_out_msg():\n");
   1.128 +		debugf("  psb->error = %d\n", psb->error);
   1.129 +		debugf("  ok = %d\n", ok);
   1.130 +		debugf("  rcpt_accept = %d\n", rcpt_accept);
   1.131  	}
   1.132  
   1.133  	if (psb->error == smtp_ok) {