comparison src/dnsbl.cpp @ 152:c7fc218686f5

gpl3, block mail to recipients that cannot reply
author carl
date Sat, 07 Jul 2007 10:26:31 -0700
parents a23ef169d322
children 8d7c439bb6fa
comparison
equal deleted inserted replaced
151:0e8ec3c483ce 152:c7fc218686f5
1 /* 1 /*
2 2
3 Copyright (c) 2006 Carl Byington - 510 Software Group, released 3 Copyright (c) 2007 Carl Byington - 510 Software Group, released under
4 under the GPL version 2 or any later version at your choice available at 4 the GPL version 3 or any later version at your choice available at
5 http://www.fsf.org/licenses/gpl.txt 5 http://www.gnu.org/licenses/gpl-3.0.txt
6 6
7 Based on a sample milter Copyright (c) 2000-2003 Sendmail, Inc. and its 7 Based on a sample milter Copyright (c) 2000-2003 Sendmail, Inc. and its
8 suppliers. Inspired by the DCC by Rhyolite Software 8 suppliers. Inspired by the DCC by Rhyolite Software
9 9
10 -r port The port used to talk to our internal dns resolver processes 10 -r port The port used to talk to our internal dns resolver processes
948 { 948 {
949 DNSBLP rejectlist = NULL; // list that caused the reject 949 DNSBLP rejectlist = NULL; // list that caused the reject
950 mlfiPriv &priv = *MLFIPRIV; 950 mlfiPriv &priv = *MLFIPRIV;
951 CONFIG &dc = *priv.pc; 951 CONFIG &dc = *priv.pc;
952 if (!priv.queueid) priv.queueid = strdup(smfi_getsymval(ctx, "i")); 952 if (!priv.queueid) priv.queueid = strdup(smfi_getsymval(ctx, "i"));
953 char *rcptaddr = rcpt[0]; 953 char *rcptaddr = rcpt[0];
954 char *loto = to_lower_string(rcptaddr); 954 char *loto = to_lower_string(rcptaddr);
955 CONTEXT &con = *(dc.find_context(loto)->find_context(priv.mailaddr)); 955 // priv.mailaddr sending original message to loto
956 VERIFYP ver = con.find_verify(loto); 956 CONTEXT &con = *(dc.find_context(loto)->find_context(priv.mailaddr));
957 VERIFYP ver = con.find_verify(loto);
958 char *fromvalue = con.find_from(priv.mailaddr);
959 // loto sending a reply back to priv.mailaddr
960 CONTEXT &con2 = *(dc.find_context(priv.mailaddr)->find_context(loto));
961 char *replyvalue = con2.find_from(loto);
957 if (debug_syslog > 1) { 962 if (debug_syslog > 1) {
958 char buf[maxlen]; 963 char buf[maxlen];
959 char msg[maxlen]; 964 char msg[maxlen];
960 snprintf(msg, sizeof(msg), "from <%s> to <%s> using context %s", priv.mailaddr, loto, con.get_full_name(buf,maxlen)); 965 snprintf(msg, sizeof(msg), "from <%s> to <%s> using context %s out %s reply %s", priv.mailaddr, loto, con.get_full_name(buf,maxlen), fromvalue, replyvalue);
961 my_syslog(&priv, msg); 966 my_syslog(&priv, msg);
962 } 967 }
963 free(loto); 968 free(loto);
964 char *fromvalue = con.find_from(priv.mailaddr);
965 status st; 969 status st;
970 if (replyvalue == token_black) {
971 smfi_setreply(ctx, "550", "5.7.1", "recipient can not reply due to blacklisting");
972 return SMFIS_REJECT;
973 }
966 if (priv.authenticated) { 974 if (priv.authenticated) {
967 int c = incr_rcpt_count(priv.authenticated); 975 int c = incr_rcpt_count(priv.authenticated);
968 int l = dc.default_context->find_rate(priv.authenticated); 976 int l = dc.default_context->find_rate(priv.authenticated);
969 if (debug_syslog > 1) { 977 if (debug_syslog > 1) {
970 char buf[maxlen]; 978 char buf[maxlen];