comparison src/dnsbl.cpp @ 179:8b86a894514d

embedded dcc filtering
author carl
date Sat, 06 Oct 2007 10:56:35 -0700
parents d6531c702be3
children cb5c0d7ec451
comparison
equal deleted inserted replaced
178:d6531c702be3 179:8b86a894514d
780 if (src[0] == 10) return false; // don't do dns lookups on rfc1918 space 780 if (src[0] == 10) return false; // don't do dns lookups on rfc1918 space
781 if ((src[0] == 192) && (src[1] == 168)) return false; 781 if ((src[0] == 192) && (src[1] == 168)) return false;
782 if ((src[0] == 172) && (16 <= src[1]) && (src[1] <= 31)) return false; 782 if ((src[0] == 172) && (16 <= src[1]) && (src[1] <= 31)) return false;
783 char adr[sizeof "255.255.255.255 "]; 783 char adr[sizeof "255.255.255.255 "];
784 snprintf(adr, sizeof(adr), "%u.%u.%u.%u", src[3], src[2], src[1], src[0]); 784 snprintf(adr, sizeof(adr), "%u.%u.%u.%u", src[3], src[2], src[1], src[0]);
785 // cannot use inet_ntop here since we want the octets reversed.
785 return (uriblookup(priv, hosts, adr, NULL, found)); 786 return (uriblookup(priv, hosts, adr, NULL, found));
786 } 787 }
787 788
788 char *top, *top2, *top3; 789 char *top, *top2, *top3;
789 top = strrchr(hostname, '.'); 790 top = strrchr(hostname, '.');
986 if (priv.client_name) priv.client_name = strdup(priv.client_name); 987 if (priv.client_name) priv.client_name = strdup(priv.client_name);
987 if (spamc != spamc_empty) { 988 if (spamc != spamc_empty) {
988 priv.assassin = new SpamAssassin(&priv, priv.ip, priv.helo, priv.mailaddr, priv.queueid); 989 priv.assassin = new SpamAssassin(&priv, priv.ip, priv.helo, priv.mailaddr, priv.queueid);
989 } 990 }
990 if (dccifd_port) { 991 if (dccifd_port) {
991 priv.dccifd = new DccInterface(dccifd_port, &priv, priv.ip, priv.helo, priv.mailaddr, priv.queueid); 992 priv.dccifd = new DccInterface(dccifd_port, &priv, priv.ip, priv.helo, priv.mailaddr);
992 } 993 }
993 return SMFIS_CONTINUE; 994 return SMFIS_CONTINUE;
994 } 995 }
995 996
996 sfsistat mlfi_envrcpt(SMFICTX *ctx, char **rcpt) 997 sfsistat mlfi_envrcpt(SMFICTX *ctx, char **rcpt)
1004 // some version of sendmail allowed rcpt to:<> and passed it thru to the milters 1005 // some version of sendmail allowed rcpt to:<> and passed it thru to the milters
1005 if (strcmp(loto, "<>") == 0) { 1006 if (strcmp(loto, "<>") == 0) {
1006 smfi_setreply(ctx, "550", "5.7.1", "bogus recipient"); 1007 smfi_setreply(ctx, "550", "5.7.1", "bogus recipient");
1007 return SMFIS_REJECT; 1008 return SMFIS_REJECT;
1008 } 1009 }
1009
1010 if (priv.assassin) priv.assassin->mlfi_envrcpt(ctx, loto);
1011 if (priv.dccifd) priv.dccifd->mlfi_envrcpt(loto);
1012 // priv.mailaddr sending original message to loto 1010 // priv.mailaddr sending original message to loto
1013 CONTEXT &con = *(dc.find_context(loto)->find_context(priv.mailaddr)); 1011 CONTEXT &con = *(dc.find_context(loto)->find_context(priv.mailaddr));
1014 VERIFYP ver = con.find_verify(loto); 1012 VERIFYP ver = con.find_verify(loto);
1015 char *fromvalue = con.find_from(priv.mailaddr, true); 1013 char *fromvalue = con.find_from(priv.mailaddr, true);
1014 // tell spam assassin and dccifd about this recipient
1015 if (priv.assassin) priv.assassin->mlfi_envrcpt(ctx, loto);
1016 if (priv.dccifd) priv.dccifd->mlfi_envrcpt(loto, con.get_grey());
1016 // loto sending a reply back to priv.mailaddr 1017 // loto sending a reply back to priv.mailaddr
1017 CONTEXT &con2 = *(dc.find_context(priv.mailaddr)->find_context(loto)); 1018 CONTEXT &con2 = *(dc.find_context(priv.mailaddr)->find_context(loto));
1018 char *replyvalue = con2.find_from(loto); 1019 char *replyvalue = con2.find_from(loto);
1019 if (debug_syslog > 1) { 1020 if (debug_syslog > 1) {
1020 char buf[maxlen]; 1021 char buf[maxlen];
1102 w->sent(loto); // don't free it, the whitelister takes ownership of the string 1103 w->sent(loto); // don't free it, the whitelister takes ownership of the string
1103 } 1104 }
1104 else { 1105 else {
1105 free(loto); 1106 free(loto);
1106 } 1107 }
1107 // remember first content filtering context 1108
1108 if (con.get_content_filtering()) {
1109 if (!priv.content_context) priv.content_context = &con;
1110 else if (con.get_require() && (priv.content_context != &con)) {
1111 smfi_setreply(ctx, "452", "4.2.1", "incompatible filtering contexts");
1112 return SMFIS_TEMPFAIL;
1113 }
1114 }
1115 // accept the recipient 1109 // accept the recipient
1116 if (!con.get_content_filtering()) st = white; 1110 if (!con.get_content_filtering()) st = white;
1111
1117 if (st == oksofar) { 1112 if (st == oksofar) {
1118 // but remember the non-whites 1113 // remember first content filtering context
1114 if (con.get_content_filtering()) {
1115 if (!priv.content_context) priv.content_context = &con;
1116 else if (con.get_require() && (priv.content_context != &con)) {
1117 smfi_setreply(ctx, "452", "4.2.1", "incompatible filtering contexts");
1118 return SMFIS_TEMPFAIL;
1119 }
1120 }
1121 // remember the non-whites
1119 priv.need_content_filter(rcptaddr, con); 1122 priv.need_content_filter(rcptaddr, con);
1120 priv.only_whites = false; 1123 priv.only_whites = false;
1121 priv.want_spamassassin |= (priv.assassin) && // have spam assassin available and 1124 priv.want_spamassassin |= (priv.assassin) && // have spam assassin available and
1122 (con.get_spamassassin_limit() != 0); // want to use it with a non-zero score 1125 (con.get_spamassassin_limit() != 0); // want to use it with a non-zero score
1123 priv.want_dccgrey |= (priv.dccifd) && // have dcc interface and 1126 priv.want_dccgrey |= (priv.dccifd) && // have dcc interface and