comparison 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
comparison
equal deleted inserted replaced
113:c93023f58cc7 114:a80ebfa16cd5
260 psb->auth_names = g_strsplit(arg, " ", 0); 260 psb->auth_names = g_strsplit(arg, " ", 0);
261 g_free(arg); 261 g_free(arg);
262 262
263 DEBUG(4) { 263 DEBUG(4) {
264 gint i = 0; 264 gint i = 0;
265 debugf("in check_helo_response()\n");
265 while (psb->auth_names[i]) { 266 while (psb->auth_names[i]) {
266 debugf("offered AUTH %s\n", psb->auth_names[i]); 267 debugf(" offered AUTH %s\n", psb->auth_names[i]);
267 i++; 268 i++;
268 } 269 }
269 } 270 }
270 } 271 }
271 } 272 }
275 ptr++; 276 ptr++;
276 ptr++; 277 ptr++;
277 } 278 }
278 279
279 DEBUG(4) { 280 DEBUG(4) {
280 debugf(psb->use_size ? "uses SIZE\n" : "no size\n"); 281 debugf(" %s\n", psb->use_size ? "uses SIZE" : "no size");
281 debugf(psb->use_pipelining ? "uses PIPELINING\n" : "no pipelining\n"); 282 debugf(" %s\n", psb->use_pipelining ? "uses PIPELINING" : "no pipelining");
282 debugf(psb->use_auth ? "uses AUTH\n" : "no auth\n"); 283 debugf(" %s\n", psb->use_auth ? "uses AUTH" : "no auth");
283 } 284 }
284 285
285 return TRUE; 286 return TRUE;
286 } 287 }
287 288
553 gint i; 554 gint i;
554 #ifdef USE_LIB_CRYPTO 555 #ifdef USE_LIB_CRYPTO
555 unsigned int digest_len; 556 unsigned int digest_len;
556 #endif 557 #endif
557 558
558 DEBUG(5) debugf("encoded challenge = %s\n", chall64); 559 DEBUG(5) debugf("smtp_out_auth_cram_md5():\n");
559 DEBUG(5) debugf("decoded challenge = %s, size = %d\n", chall, chall_size); 560 DEBUG(5) debugf(" encoded challenge = %s\n", chall64);
560 561 DEBUG(5) debugf(" decoded challenge = %s, size = %d\n", chall, chall_size);
561 DEBUG(5) debugf("secret = %s\n", psb->auth_secret); 562 DEBUG(5) debugf(" secret = %s\n", psb->auth_secret);
562 563
563 #ifdef USE_LIB_CRYPTO 564 #ifdef USE_LIB_CRYPTO
564 HMAC(EVP_md5(), psb->auth_secret, strlen(psb->auth_secret), chall, chall_size, digest, &digest_len); 565 HMAC(EVP_md5(), psb->auth_secret, strlen(psb->auth_secret), chall, chall_size, digest, &digest_len);
565 #else 566 #else
566 hmac_md5(chall, chall_size, psb->auth_secret, strlen(psb->auth_secret), digest); 567 hmac_md5(chall, chall_size, psb->auth_secret, strlen(psb->auth_secret), digest);
568 569
569 for (i = 0; i < 16; i++) 570 for (i = 0; i < 16; i++)
570 sprintf(&(digest_string[i + i]), "%02x", (unsigned int) (digest[i])); 571 sprintf(&(digest_string[i + i]), "%02x", (unsigned int) (digest[i]));
571 digest_string[32] = '\0'; 572 digest_string[32] = '\0';
572 573
573 DEBUG(5) debugf("digest = %s\n", digest_string); 574 DEBUG(5) debugf(" digest = %s\n", digest_string);
574 575
575 reply = g_strdup_printf("%s %s", psb->auth_login, digest_string); 576 reply = g_strdup_printf("%s %s", psb->auth_login, digest_string);
576 DEBUG(5) debugf("unencoded reply = %s\n", reply); 577 DEBUG(5) debugf(" unencoded reply = %s\n", reply);
577 578
578 reply64 = base64_encode(reply, strlen(reply)); 579 reply64 = base64_encode(reply, strlen(reply));
579 DEBUG(5) debugf("encoded reply = %s\n", reply64); 580 DEBUG(5) debugf(" encoded reply = %s\n", reply64);
580 581
581 fprintf(psb->out, "%s\r\n", reply64); 582 fprintf(psb->out, "%s\r\n", reply64);
582 fflush(psb->out); 583 fflush(psb->out);
583 DEBUG(4) debugf("%s\n", reply64); 584 DEBUG(4) debugf(" reply64 = %s\n", reply64);
584 585
585 if ((ok = read_response(psb, SMTP_CMD_TIMEOUT))) 586 if ((ok = read_response(psb, SMTP_CMD_TIMEOUT)))
586 ok = check_response(psb, FALSE); 587 ok = check_response(psb, FALSE);
587 588
588 g_free(reply64); 589 g_free(reply64);
605 gchar *resp64; 606 gchar *resp64;
606 guchar *resp; 607 guchar *resp;
607 gint resp_size; 608 gint resp_size;
608 gchar *reply64; 609 gchar *reply64;
609 610
611 DEBUG(5) debugf("smtp_out_auth_login():\n");
610 resp64 = get_response_arg(&(psb->buffer[4])); 612 resp64 = get_response_arg(&(psb->buffer[4]));
611 DEBUG(5) debugf("encoded response = %s\n", resp64); 613 DEBUG(5) debugf(" encoded response = %s\n", resp64);
612 resp = base64_decode(resp64, &resp_size); 614 resp = base64_decode(resp64, &resp_size);
613 g_free(resp64); 615 g_free(resp64);
614 DEBUG(5) debugf("decoded response = %s, size = %d\n", resp, resp_size); 616 DEBUG(5) debugf(" decoded response = %s, size = %d\n", resp, resp_size);
615 g_free(resp); 617 g_free(resp);
616 reply64 = base64_encode(psb->auth_login, strlen(psb->auth_login)); 618 reply64 = base64_encode(psb->auth_login, strlen(psb->auth_login));
617 fprintf(psb->out, "%s\r\n", reply64); 619 fprintf(psb->out, "%s\r\n", reply64);
618 fflush(psb->out); 620 fflush(psb->out);
619 g_free(reply64); 621 g_free(reply64);
620 if ((ok = read_response(psb, SMTP_CMD_TIMEOUT))) { 622 if ((ok = read_response(psb, SMTP_CMD_TIMEOUT))) {
621 if ((ok = check_response(psb, TRUE))) { 623 if ((ok = check_response(psb, TRUE))) {
622 resp64 = get_response_arg(&(psb->buffer[4])); 624 resp64 = get_response_arg(&(psb->buffer[4]));
623 DEBUG(5) debugf("encoded response = %s\n", resp64); 625 DEBUG(5) debugf(" encoded response = %s\n", resp64);
624 resp = base64_decode(resp64, &resp_size); 626 resp = base64_decode(resp64, &resp_size);
625 g_free(resp64); 627 g_free(resp64);
626 DEBUG(5) debugf("decoded response = %s, size = %d\n", resp, resp_size); 628 DEBUG(5) debugf(" decoded response = %s, size = %d\n", resp, resp_size);
627 g_free(resp); 629 g_free(resp);
628 reply64 = base64_encode(psb->auth_secret, strlen(psb->auth_secret)); 630 reply64 = base64_encode(psb->auth_secret, strlen(psb->auth_secret));
629 fprintf(psb->out, "%s\r\n", reply64); 631 fprintf(psb->out, "%s\r\n", reply64);
630 fflush(psb->out); 632 fflush(psb->out);
631 g_free(reply64); 633 g_free(reply64);
710 712
711 size = msg_calc_size(msg, TRUE); 713 size = msg_calc_size(msg, TRUE);
712 714
713 /* respect maximum size given by server: */ 715 /* respect maximum size given by server: */
714 if ((psb->max_size > 0) && (size > psb->max_size)) { 716 if ((psb->max_size > 0) && (size > psb->max_size)) {
715 logwrite(LOG_WARNING, "%s == host=%s message size (%d) > fixed maximum message size of server (%d)", 717 logwrite(LOG_WARNING, "%s == host=%s message size (%d) > "
718 "fixed maximum message size of server (%d)",
716 msg->uid, psb->remote_host, size, psb->max_size); 719 msg->uid, psb->remote_host, size, psb->max_size);
717 psb->error = smtp_cancel; 720 psb->error = smtp_cancel;
718 ok = FALSE; 721 ok = FALSE;
719 } 722 }
720 723
745 give up. */ 748 give up. */
746 if ((psb->error != smtp_trylater) && (psb->error != smtp_fail)) { 749 if ((psb->error != smtp_trylater) && (psb->error != smtp_fail)) {
747 ok = FALSE; 750 ok = FALSE;
748 break; 751 break;
749 } else { 752 } else {
750 logwrite(LOG_NOTICE, "%s == %s host=%s failed: %s", 753 logwrite(LOG_NOTICE, "%s == %s host=%s failed: %s\n",
751 msg->uid, addr_string(rcpt), psb->remote_host, psb->buffer); 754 msg->uid, addr_string(rcpt), psb->remote_host, psb->buffer);
752 if (psb->error == smtp_trylater) { 755 if (psb->error == smtp_trylater) {
753 addr_mark_defered(rcpt); 756 addr_mark_defered(rcpt);
754 } else { 757 } else {
755 addr_mark_failed(rcpt); 758 addr_mark_failed(rcpt);
796 if ((psb->error != smtp_trylater) && 799 if ((psb->error != smtp_trylater) &&
797 (psb->error != smtp_fail)) { 800 (psb->error != smtp_fail)) {
798 ok = FALSE; 801 ok = FALSE;
799 break; 802 break;
800 } else { 803 } else {
801 logwrite(LOG_NOTICE, "%s == %s host=%s failed: %s", msg->uid, 804 logwrite(LOG_NOTICE, "%s == %s host=%s failed: %s\n", msg->uid,
802 addr_string(rcpt), psb->remote_host, psb->buffer); 805 addr_string(rcpt), psb->remote_host, psb->buffer);
803 if (psb->error == smtp_trylater) { 806 if (psb->error == smtp_trylater) {
804 addr_mark_defered(rcpt); 807 addr_mark_defered(rcpt);
805 } else { 808 } else {
806 addr_mark_failed(rcpt); 809 addr_mark_failed(rcpt);
838 } 841 }
839 } 842 }
840 } 843 }
841 844
842 DEBUG(5) { 845 DEBUG(5) {
843 debugf("psb->error = %d\n", psb->error); 846 debugf("smtp_out_msg():\n");
844 debugf("ok = %d\n", ok); 847 debugf(" psb->error = %d\n", psb->error);
845 debugf("rcpt_accept = %d\n", rcpt_accept); 848 debugf(" ok = %d\n", ok);
849 debugf(" rcpt_accept = %d\n", rcpt_accept);
846 } 850 }
847 851
848 if (psb->error == smtp_ok) { 852 if (psb->error == smtp_ok) {
849 GList *rcpt_node; 853 GList *rcpt_node;
850 for (rcpt_node = g_list_first(rcpt_list); rcpt_node; rcpt_node = g_list_next(rcpt_node)) { 854 for (rcpt_node = g_list_first(rcpt_list); rcpt_node; rcpt_node = g_list_next(rcpt_node)) {