From b2e2126e922c2428d7dd1a39c953cc920c65e68b Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sun, 4 Feb 2007 00:01:03 +0000 Subject: [PATCH] * Added a config option to check RBL's immediately upon connection instead of waiting for them to execute a RCPT command. (Still need to implement client config option.) * Bumped the rev level and compatible export file level to 7.04 because we amended the config file format. --- citadel/citadel.h | 4 ++-- citadel/config.h | 1 + citadel/serv_smtp.c | 31 ++++++++++++++++++++++++------- citadel/serv_vandelay.c | 2 ++ 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/citadel/citadel.h b/citadel/citadel.h index 7e6536ce5..d8025653d 100644 --- a/citadel/citadel.h +++ b/citadel/citadel.h @@ -47,9 +47,9 @@ extern "C" { * usually more strict because you're not really supposed to dump/load and * upgrade at the same time. */ -#define REV_LEVEL 703 /* This version */ +#define REV_LEVEL 704 /* This version */ #define REV_MIN 591 /* Oldest compatible database */ -#define EXPORT_REV_MIN 701 /* Oldest compatible export files */ +#define EXPORT_REV_MIN 704 /* Oldest compatible export files */ #define SERVER_TYPE 0 /* zero for stock Citadel; other developers please obtain SERVER_TYPE codes for your implementations */ diff --git a/citadel/config.h b/citadel/config.h index 1dd6c8b92..176aaf45f 100644 --- a/citadel/config.h +++ b/citadel/config.h @@ -80,6 +80,7 @@ struct config { int c_funambol_port; /* Funambol port */ char c_funambol_source[256]; /* Funambol sync source */ char c_funambol_auth[256]; /* Funambol auth details */ + char c_rbl_at_greeting; /* Check RBL's at connect instead of after RCPT */ }; diff --git a/citadel/serv_smtp.c b/citadel/serv_smtp.c index 88907a260..cc05b14db 100644 --- a/citadel/serv_smtp.c +++ b/citadel/serv_smtp.c @@ -128,7 +128,9 @@ 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(void) +{ + char message_to_spammer[1024]; strcpy(CC->cs_clientname, "SMTP session"); CC->internal_pgm = 1; @@ -140,6 +142,19 @@ void smtp_greeting(void) { memset(SMTP_RECPS, 0, SIZ); memset(SMTP_ROOMS, 0, SIZ); + /* 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 (rbl_check(message_to_spammer)) { + cprintf("550 %s\r\n", message_to_spammer); + CC->kill_me = 1; + /* no need to free(valid), it's not allocated yet */ + return; + } + } + + /* Otherwise we're either clean or we check later. */ cprintf("220 %s ESMTP Citadel server ready.\r\n", config.c_fqdn); } @@ -637,12 +652,14 @@ void smtp_rcpt(char *argbuf) { } /* RBL check */ - if ( (!CC->logged_in) - && (!SMTP->is_lmtp) ) { - if (rbl_check(message_to_spammer)) { - cprintf("550 %s\r\n", message_to_spammer); - /* no need to free(valid), it's not allocated yet */ - return; + if ( (!CC->logged_in) /* Don't RBL authenticated users */ + && (!SMTP->is_lmtp) ) { /* Don't RBL LMTP clients */ + if (config.c_rbl_at_greeting == 0) { /* Don't RBL again if we already did it */ + if (rbl_check(message_to_spammer)) { + cprintf("550 %s\r\n", message_to_spammer); + /* no need to free(valid), it's not allocated yet */ + return; + } } } diff --git a/citadel/serv_vandelay.c b/citadel/serv_vandelay.c index 0ab094f05..9152160ea 100644 --- a/citadel/serv_vandelay.c +++ b/citadel/serv_vandelay.c @@ -324,6 +324,7 @@ void artv_do_export(void) { cprintf("%d\n", config.c_funambol_port); cprintf("%s\n", config.c_funambol_source); cprintf("%s\n", config.c_funambol_auth); + cprintf("%d\n", config.c_rbl_at_greeting); /* Export the control file */ get_control(); @@ -412,6 +413,7 @@ void artv_import_config(void) { client_getln(buf, sizeof buf); config.c_funambol_port = atoi(buf); client_getln(config.c_funambol_source, sizeof config.c_funambol_source); client_getln(config.c_funambol_auth, sizeof config.c_funambol_auth); + client_getln(buf, sizeof buf); config.c_rbl_at_greeting = atoi(buf); config.c_enable_fulltext = 0; /* always disable */ put_config(); -- 2.30.2