Skip to content
Snippets Groups Projects
Commit 27079b33 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Recognize DNB blacklist exempted email addresses in From fields

Previously, any DNS blacklist-exempt email addresses (in ctrl/dnsbl_exempt.cfg) had to be used in the mail-envelope (the "MAIL FROM:" address) - that doesn't work for all senders that use re-mailers or whatever where you end-up with some *bounce* address as the envelope-sender.

So now, clear the DNSBL results when the From header field is parsed and the sender was in fact an exempt sender. Note: the Subject line will still contain the SPAM tag if the subject was parsed first (came earlier in the message header). May need to address this limitation in the future if it turns out to be a problem (!).

Lowercase the [smtp|smtps]spy.txt log file.
parent a1c343af
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #1364 passed
......@@ -1923,13 +1923,12 @@ static BOOL email_addr_is_exempt(const char* addr)
if(*addr==0 || strcmp(addr,"<>")==0)
return FALSE;
angle_bracket(netmail, sizeof(netmail), addr);
SAFEPRINTF(fname,"%sdnsbl_exempt.cfg",scfg.ctrl_dir);
if(findstr((char*)addr,fname))
if(findstr(netmail, fname))
return TRUE;
SAFECOPY(netmail, addr);
if(*(p=netmail)=='<')
p++;
truncstr(p,">");
p = netmail + 1;
*lastchar(p) = '\0';
return userdatdupe(&scfg, 0, U_NETMAIL, LEN_NETMAIL, p, /* del */FALSE, /* next */FALSE, NULL, NULL);
}
......@@ -2700,7 +2699,7 @@ static void parse_mail_address(char* p
char* tp;
char tmp[256];
if(p == NULL || name == NULL || addr == NULL)
if(p == NULL || addr == NULL)
return;
SKIP_WHITESPACE(p);
......@@ -2714,6 +2713,7 @@ static void parse_mail_address(char* p
sprintf(addr,"%.*s",(int)addr_len,tp);
truncstr(addr,">( ");
if(name != NULL) {
SAFECOPY(tmp,p);
p=tmp;
/* Get the "name" (if possible) */
......@@ -2733,6 +2733,7 @@ static void parse_mail_address(char* p
truncsp(name);
strip_char(name, name, '\\');
}
}
static BOOL checktag(scfg_t *scfg, char *tag, uint usernum)
{
......@@ -3159,7 +3160,8 @@ static void smtp_thread(void* arg)
if(trashcan(&scfg,host_name,"smtpspy")
|| trashcan(&scfg,host_ip,"smtpspy")) {
SAFEPRINTF(str,"%ssmtpspy.txt", scfg.logs_dir);
SAFEPRINTF2(path,"%s%sspy.txt", scfg.logs_dir, client.protocol);
strlwr(str);
spy=fopen(str,"a");
}
......@@ -3524,12 +3526,21 @@ static void smtp_thread(void* arg)
smb_hfield_str(&msg, hfield_type=RFC822SUBJECT, p);
continue;
}
if(relay_user.number==0 && stricmp(field, "FROM")==0
if(stricmp(field, "FROM")==0) {
if(relay_user.number==0
&& !chk_email_addr(socket, client.protocol,p,host_name,host_ip,rcpt_addr,reverse_path,"FROM")) {
errmsg="554 Sender not allowed.";
smb_error=SMB_FAILURE;
break;
}
char from_addr[128];
parse_mail_address(p, from_addr, sizeof(from_addr)-1, /* name: */NULL, 0);
if(dnsbl_result.s_addr && email_addr_is_exempt(from_addr)) {
lprintf(LOG_INFO,"%04d %s %s Ignoring DNSBL results for exempt sender (from): %s"
,socket, client.protocol, client_id, from_addr);
dnsbl_result.s_addr=0;
}
}
if(relay_user.number==0 && stricmp(field, "TO")==0 && !spam_bait_result
&& !chk_email_addr(socket, client.protocol,p,host_name,host_ip,rcpt_addr,reverse_path,"TO")) {
errmsg="550 Unknown user.";
......@@ -4550,6 +4561,7 @@ static void smtp_thread(void* arg)
&& (trashcan(&scfg,reverse_path,"smtpspy")
|| trashcan(&scfg,rcpt_addr,"smtpspy"))) {
SAFEPRINTF2(path,"%s%sspy.txt", scfg.logs_dir, client.protocol);
strlwr(path);
spy=fopen(path,"a");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment