From: Art Cancro Date: Thu, 29 Mar 2007 15:46:17 +0000 (+0000) Subject: * When rejecting SMTP connections immediately upon connect, X-Git-Tag: v7.86~3469 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=ae95f329c66c54203bc4c92a8cda451c294d0592;p=citadel.git * When rejecting SMTP connections immediately upon connect, don't engage in this behavior when running in MSA mode (port 587). --- diff --git a/citadel/locate_host.c b/citadel/locate_host.c index cb99a28fc..68eb64dd0 100644 --- a/citadel/locate_host.c +++ b/citadel/locate_host.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -109,6 +110,7 @@ int rblcheck_backend(char *domain, char *txtbuf, int txtbufsize) { const u_char *cend; const u_char *rend; int len; + char *p = NULL; /* Make our DNS query. */ //res_init(); @@ -206,6 +208,10 @@ int rblcheck_backend(char *domain, char *txtbuf, int txtbufsize) { if (txtbuf != NULL) { snprintf(txtbuf, txtbufsize, "%s", result); } + /* Remove nonprintable characters */ + for (p=txtbuf; *p; ++p) { + if (!isprint(*p)) strcpy(p, p+1); + } if (need_to_free_answer) free(answer); free(result); return(1); diff --git a/citadel/serv_smtp.c b/citadel/serv_smtp.c index a6bae9342..c52fca586 100644 --- a/citadel/serv_smtp.c +++ b/citadel/serv_smtp.c @@ -128,7 +128,7 @@ int run_queue_now = 0; /* Set to 1 to ignore SMTP send retry times */ /* * Here's where our SMTP session begins its happy day. */ -void smtp_greeting(void) +void smtp_greeting(int is_msa) { char message_to_spammer[1024]; @@ -141,11 +141,12 @@ void smtp_greeting(void) memset(SMTP, 0, sizeof(struct citsmtp)); memset(SMTP_RECPS, 0, SIZ); memset(SMTP_ROOMS, 0, SIZ); + SMTP->is_msa = is_msa; /* If this config option is set, reject connections from problem * addresses immediately instead of after they execute a RCPT */ - if (config.c_rbl_at_greeting) { + if ( (config.c_rbl_at_greeting) && (SMTP->is_msa == 0) ) { if (rbl_check(message_to_spammer)) { cprintf("550 %s\r\n", message_to_spammer); CC->kill_me = 1; @@ -175,7 +176,7 @@ void smtp_greeting(void) #ifdef HAVE_OPENSSL void smtps_greeting(void) { CtdlStartTLS(NULL, NULL, NULL); - smtp_greeting(); + smtp_greeting(0); } #endif @@ -184,8 +185,7 @@ void smtps_greeting(void) { * SMTP MSA port requires authentication. */ void smtp_msa_greeting(void) { - smtp_greeting(); - SMTP->is_msa = 1; + smtp_greeting(1); } @@ -193,16 +193,24 @@ void smtp_msa_greeting(void) { * LMTP is like SMTP but with some extra bonus footage added. */ void lmtp_greeting(void) { - smtp_greeting(); + smtp_greeting(0); SMTP->is_lmtp = 1; } +/* + * Generic SMTP MTA greeting + */ +void smtp_mta_greeting(void) { + smtp_greeting(0); +} + + /* * We also have an unfiltered LMTP socket that bypasses spam filters. */ void lmtp_unfiltered_greeting(void) { - smtp_greeting(); + smtp_greeting(0); SMTP->is_lmtp = 1; SMTP->is_unfiltered = 1; } @@ -1908,7 +1916,7 @@ char *serv_smtp_init(void) CtdlRegisterServiceHook(config.c_smtp_port, /* SMTP MTA */ NULL, - smtp_greeting, + smtp_mta_greeting, smtp_command_loop, NULL);