Mercurial > dnsbl
changeset 124:ea6f9c812faa stable-5-16
put hostname in smtp message for uribl style lookups
author | carl |
---|---|
date | Thu, 16 Mar 2006 15:20:37 -0800 |
parents | ecd97e7eb1f0 |
children | 8b1562482b29 |
files | dnsbl.spec.in src/dnsbl.cpp xml/dnsbl.in |
diffstat | 3 files changed, 62 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/dnsbl.spec.in Wed Mar 15 08:21:51 2006 -0800 +++ b/dnsbl.spec.in Thu Mar 16 15:20:37 2006 -0800 @@ -61,14 +61,14 @@ sysconfdir=$RPM_BUILD_ROOT%{_sysconfdir} install mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d mkdir -p $RPM_BUILD_ROOT%{_datadir}/doc/@PACKAGE@-@VERSION@ -mv -f $RPM_BUILD_ROOT%{_sysconfdir}/dnsbl/dnsbl $RPM_BUILD_ROOT/etc/rc.d/init.d +mv -f $RPM_BUILD_ROOT%{_sysconfdir}/@PACKAGE@/@PACKAGE@ $RPM_BUILD_ROOT/etc/rc.d/init.d mv AUTHORS COPYING ChangeLog NEWS README $RPM_BUILD_ROOT%{_datadir}/doc/@PACKAGE@-@VERSION@ mkdir -p %{buildroot}/var/run/@PACKAGE@ %pre -/usr/bin/getent passwd dnsbl >/dev/null || - useradd -r -d /etc/dnsbl -M -c "dnsbl pseudo-user" -s /sbin/nologin dnsbl +/usr/bin/getent passwd @PACKAGE@ >/dev/null || + useradd -r -d %{_sysconfdir}/@PACKAGE@ -M -c "@PACKAGE@ pseudo-user" -s /sbin/nologin @PACKAGE@ %post @@ -102,6 +102,9 @@ %changelog +* Thu Mar 16 2006 Carl Byington 5.16 +- use @PACKAGE@ in more places + * Fri Mar 10 2006 Carl Byington 5.13 - remove redundant entry in files section
--- a/src/dnsbl.cpp Wed Mar 15 08:21:51 2006 -0800 +++ b/src/dnsbl.cpp Thu Mar 16 15:20:37 2006 -0800 @@ -658,16 +658,17 @@ //////////////////////////////////////////////// // lookup the domain name part of a hostname on two lists // -bool uriblookup(mlfiPriv &priv ,char *hostname, char *top) ; -bool uriblookup(mlfiPriv &priv, char *hostname, char *top) { +// if we find part of the hostname on the uribl, return +// true and point found to the part of the hostname that we found. +// otherwise, return false and preserve the value of found. +// +bool uriblookup(mlfiPriv &priv ,char *hostname, char *top, char *&found) ; +bool uriblookup(mlfiPriv &priv, char *hostname, char *top, char *&found) { // top is pointer to '.' char at end of base domain, or null for ip address form // so for hostname of www.fred.mydomain.co.uk // top points to-----------------------^ // and we end up looking at only mydomain.co.uk, ignoring the www.fred stuff char buf[maxlen]; - char buf2[maxlen]; - const char *uriblname[2] = { "multi.surbl.org", "multi.uribl.com" }; - if (top) { // add one more component *top = '\0'; @@ -682,6 +683,7 @@ snprintf(tmp, sizeof(tmp), "found %s on %s", hostname, priv.uribl_suffix); my_syslog(tmp); } + found = hostname; return true; } return false; @@ -694,14 +696,19 @@ // hostname MUST not have a trailing dot // If tld, two level lookup. // Else, look up three level domain. -bool check_uribl(mlfiPriv &priv, char *hostname) ; -bool check_uribl(mlfiPriv &priv, char *hostname) { +// +// if we find part of the hostname on the uribl, return +// true and point found to the part of the hostname that we found. +// otherwise, return false and preserve the value of found. +// +bool check_uribl(mlfiPriv &priv, char *hostname, char *&found) ; +bool check_uribl(mlfiPriv &priv, char *hostname, char *&found) { in_addr ip; if (inet_aton(hostname, &ip)) { const u_char *src = (const u_char *)&ip.s_addr; - char adr[sizeof "255.255.255.255"]; + static char adr[sizeof "255.255.255.255"]; snprintf(adr, sizeof(adr), "%u.%u.%u.%u", src[3], src[2], src[1], src[0]); - return (uriblookup(priv, adr, NULL)); + return (uriblookup(priv, adr, NULL, found)); } char *top, *top2, *top3; @@ -715,18 +722,18 @@ string_set::iterator i = priv.memory->get_cctlds()->find(top2+1); string_set::iterator x = priv.memory->get_cctlds()->end(); // if we have a 2-level-cctld, just look at top three levels of the name - if (i != x) return uriblookup(priv, hostname, top2); + if (i != x) return uriblookup(priv, hostname, top2, found); *top2 = '\0'; top3 = strrchr(hostname, '.'); *top2 = '.'; // if we have more than 3 levels in the name, look at the top three levels of the name - if (top3 && uriblookup(priv, hostname, top2)) return true; + if (top3 && uriblookup(priv, hostname, top2, found)) return true; // if that was not found, fall thru to looking at the top two levels } // look at the top two levels of the name - return uriblookup(priv, hostname, top); + return uriblookup(priv, hostname, top, found); } return false; } @@ -735,8 +742,10 @@ //////////////////////////////////////////////// // check the hosts from the body against the content filter and uribl dnsbls // -bool check_hosts(mlfiPriv &priv, bool random, int limit, char *&msg, char *&host, int &ip); -bool check_hosts(mlfiPriv &priv, bool random, int limit, char *&msg, char *&host, int &ip) { +// +bool check_hosts(mlfiPriv &priv, bool random, int limit, char *&msg, char *&host, int &ip, char *&found); +bool check_hosts(mlfiPriv &priv, bool random, int limit, char *&msg, char *&host, int &ip, char *&found) { + found = NULL; // normally ip address style if (!priv.content_suffix && !priv.uribl_suffix) return false; // nothing to check CONFIG &dc = *priv.pc; string_set &hosts = priv.memory->get_hosts(); @@ -785,12 +794,13 @@ if (i == ips.end()) { // we haven't looked this up yet ips.insert(ip); - if (check_single(priv, ip, priv.content_suffix)) { + // check dnsbl style list + if (priv.content_suffix && check_single(priv, ip, priv.content_suffix)) { msg = priv.content_message; return true; } - // Check uribl & surbl - if (check_uribl(priv, host)) { + // Check uribl & surbl style list + if (priv.uribl_suffix && check_uribl(priv, host, found)) { msg = priv.uribl_message; return true; } @@ -995,12 +1005,19 @@ } bool rejecting = alive.empty(); // if alive is empty, we must have set msg above in acceptable_content() if (!rejecting) { - char *fmt; - if (check_hosts(priv, random, limit, fmt, host, ip)) { + char *fmt, *found; + if (check_hosts(priv, random, limit, fmt, host, ip, found)) { + if (found) { + // uribl style + snprintf(buf, sizeof(buf), fmt, host, found); + } + else { + // dnsbl style char adr[sizeof "255.255.255.255"]; adr[0] = '\0'; inet_ntop(AF_INET, (const u_char *)&ip, adr, sizeof(adr)); snprintf(buf, sizeof(buf), fmt, host, adr); + } msg = buf; rejecting = true; }
--- a/xml/dnsbl.in Wed Mar 15 08:21:51 2006 -0800 +++ b/xml/dnsbl.in Thu Mar 16 15:20:37 2006 -0800 @@ -520,21 +520,26 @@ STATEMENT = (DNSBL | DNSBLLIST | CONTENT | ENV-TO | VERIFY | CONTEXT | ENV-FROM) ";" -DNSBL = "dnsbl" NAME DNSPREFIX ERROR-MSG +DNSBL = "dnsbl" NAME DNSPREFIX ERROR-MSG1 DNSBLLIST = "dnsbl_list" {NAME}+ CONTENT = "content" ("on" | "off") "{" {CONTENT-ST}+ "}" CONTENT-ST = (FILTER | URIBL | IGNORE | TLD | CCTLD | HTML-TAGS | HTML-LIMIT | HOST-LIMIT) ";" -FILTER = "filter" DNSPREFIX ERROR-MSG -URIBL = "uribl" DNSPREFIX ERROR-MSG +FILTER = "filter" DNSPREFIX ERROR-MSG2 +URIBL = "uribl" DNSPREFIX ERROR-MSG3 IGNORE = "ignore" "{" {HOSTNAME [";"]}+ "}" TLD = "tld" "{" {TLD [";"]}+ "}" CCTLD = "cctld" "{" {TLD [";"]}+ "}" HTML-TAGS = "html_tags" "{" {HTMLTAG [";"]}+ "}" -ERROR-MSG = string containing exactly two %s replacement tokens - for the client ip address +ERROR-MSG1 = string containing exactly two %s replacement tokens + both are replaced with the client ip address +ERROR-MSG2 = string containing exactly two %s replacement tokens + the first is replaced with the hostname, and the second + is replaced with the ip address +ERROR-MSG3 = string containing exactly two %s replacement tokens + both are replaced with the hostname HTML-LIMIT = "html_limit" ("on" INTEGER ERROR-MSG | "off")