* When rejecting SMTP connections immediately upon connect,
authorArt Cancro <ajc@citadel.org>
Thu, 29 Mar 2007 15:46:17 +0000 (15:46 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 29 Mar 2007 15:46:17 +0000 (15:46 +0000)
  don't engage in this behavior when running in MSA mode (port 587).

citadel/locate_host.c
citadel/serv_smtp.c

index cb99a28fc540b9587144357229d0ac7b5093c35f..68eb64dd07e56a0e86bb19b8476e0f0beff27a9c 100644 (file)
@@ -9,6 +9,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <stdio.h>
+#include <ctype.h>
 #include <signal.h>
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -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);
index a6bae93427cd92253bc9841bd23eaac4fa02ef2f..c52fca5864cd33ba9372d036f403e0c08854dff5 100644 (file)
@@ -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);