rpms/rblcheck/devel rblcheck-names.patch, NONE, 1.1 rblcheck-texttweak.patch, NONE, 1.1 rblcheck-txt.patch, NONE, 1.1 rblcheck.spec, NONE, 1.1 rblcheckrc, NONE, 1.1 .cvsignore, 1.1, 1.2 sources, 1.1, 1.2

Oliver Falk (oliver) fedora-extras-commits at redhat.com
Wed Jun 29 08:33:46 UTC 2005


Author: oliver

Update of /cvs/extras/rpms/rblcheck/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv32752/devel

Modified Files:
	.cvsignore sources 
Added Files:
	rblcheck-names.patch rblcheck-texttweak.patch 
	rblcheck-txt.patch rblcheck.spec rblcheckrc 
Log Message:
auto-import rblcheck-1.5-9 on branch devel from rblcheck-1.5-9.src.rpm

rblcheck-names.patch:

--- NEW FILE rblcheck-names.patch ---
--- rblcheck.c.orig	Mon Dec  2 07:07:10 2002
+++ rblcheck.c		Mon Dec  2 09:23:13 2002
@@ -24,13 +24,16 @@
 #include "config.h"
 
 #include <stdio.h>
+#include <assert.h>
 #include <string.h>
 #include <sys/types.h>
 #include <netinet/in.h>
 #include <arpa/nameser.h>
+#include <arpa/inet.h>
 #include <resolv.h>
 #include <netdb.h>
 
+
 /*-- PORTABILITY ------------------------------------------------------------*/
 
 #ifdef STDC_HEADERS
@@ -284,6 +287,104 @@
 	return result;
 }
 
+static const char *printable_ipaddr(void *ipa)
+{
+struct in_addr	a;
+
+	memcpy(&a, ipa, 4);
+
+	return inet_ntoa(a);
+}
+
+/*
+ * lookup_target()
+ *
+ *	Given a "target", determine the IP address for it. If it's a regular IP
+ *	address, we just convert to binary form and return straightaway. If it's
+ *	a hostname, we look up the hosts for it and detect how many A records
+ *	we got back. -- SJF
+ */
+
+static unsigned long lookup_target(const char *target)
+{
+struct hostent	*hp;
+unsigned long	ipaddr;
+int		naddr;
+
+	assert(target != 0);
+
+	/*----------------------------------------------------------------
+	 * JUST AN IP ADDRESS?
+	 *
+ 	 * This should be the usual case...
+	 */
+	if ( (ipaddr = inet_addr(target)) != INADDR_NONE )
+	{
+		return ntohl(ipaddr);
+	}
+
+	/*----------------------------------------------------------------
+	 * If it's not an IP address, it must be a name, so look it up in
+	 * the DNS. It's an error for this name to be unknown. Note that
+	 * if the name is known but there are no "A" records, this looks
+	 * like an "unknown" error. That's OK.
+	 */
+	if ( (hp = gethostbyname(target)) == 0 )
+	{
+		fprintf(stderr, "ERROR: cannot find target {%s} in DNS\n", target);
+		exit(1);
+	}
+
+	/*----------------------------------------------------------------
+	 * Now we have a name from DNS, so see how many address records
+	 * we actually got. If we have none then of course we're not going
+	 * to do *anything* useful, but if we get more than one we have
+	 * to 
+	 */
+	for (naddr = 0; hp->h_addr_list[naddr]; naddr++)
+	{
+		/* NOTHING */
+	}
+
+	if ( naddr == 0 )
+	{
+		fprintf(stderr, "ERROR: target {%s} has no Address records\n", target);
+		exit(1);
+	}
+
+	assert(hp->h_length == 4);	// must be IPv4
+
+	memcpy(&ipaddr, hp->h_addr_list[0], 4);
+
+	if ( naddr > 1 )
+	{
+	int	i;
+
+		for ( i = 0; i < naddr; i++ )
+		{
+		const char *addr = printable_ipaddr(hp->h_addr_list[i]);
+
+			if ( i == 0 )
+			{
+				printf("# Target %s has %d address records, using %s\n",
+					target, naddr, addr);
+			}
+			else
+			{
+				printf("# addr[%d]: %s\n", i, addr);
+			}
+		}
+	}
+	else
+	{
+		printf("# Target %s -> %s\n", target, printable_ipaddr(hp->h_addr_list[0]));
+	}
+
+
+	return ntohl(ipaddr);
+}
+
+
 /* full_rblcheck
  * Takes an IP address, and feeds it to rblcheck() for each defined
  * RBL listing, handling output of results if necessary. */
@@ -293,17 +396,17 @@
 	int count = 0;
 	char * response;
 	struct rbl * ptr;
+	char	addrbuf[32];
+
+	unsigned long ipaddr = lookup_target(addr);
+
+	a = (ipaddr >> 24) & 0xFF;
+	b = (ipaddr >> 16) & 0xFF;
+	c = (ipaddr >>  8) & 0xFF;
+	d = (ipaddr      ) & 0xFF;
 
 	for( ptr = rblsites; ptr != NULL; ptr = ptr->next )
 	{
-		if( sscanf( addr, "%d.%d.%d.%d", &a, &b, &c, &d ) != 4
-		  || a < 0 || a > 255 || b < 0 || b > 255 || c < 0 || c > 255
-		  || d < 0 || d > 255 )
-		{
-			fprintf( stderr, "%s: warning: invalid address `%s'\n",
-			  progname, addr );
-			return 0;
-		}
 		response = rblcheck( a, b, c, d, ptr->site, txt );
 		if( !quiet || response )
			printf( "%s %s%s%s%s%s%s", addr,

rblcheck-texttweak.patch:

--- NEW FILE rblcheck-texttweak.patch ---
--- rblcheck-1.5/rblcheck.c.orig	Thu Nov  8 22:05:27 2001
+++ rblcheck-1.5/rblcheck.c		Thu Sep  5 17:30:17 2002
@@ -308,7 +308,7 @@
 		if( !quiet || response )
 			printf( "%s %s%s%s%s%s%s", addr,
 			  ( !quiet && !response ? "not " : "" ),
-			  ( !quiet ? "RBL filtered by " : "" ),
+			  ( !quiet ? "listed by " : "" ),
 			  ( !quiet ? ptr->site : "" ),
 			  ( txt && response && strlen( response ) && !quiet ?
 			    ": " : "" ),

rblcheck-txt.patch:

--- NEW FILE rblcheck-txt.patch ---
--- rblcheck.c.orig	2001-11-08 22:05:27.000000000 +0000
+++ rblcheck.c		2003-03-26 12:53:13.000000000 +0000
@@ -64,13 +64,25 @@
 #endif
 
 #ifndef NS_GET16
-#define NS_GET16(s, cp) { \
+#define NS_GET16(s, cp) do { \
 	register unsigned char *t_cp = (unsigned char *)(cp); \
 	(s) = ((unsigned short)t_cp[0] << 8) \
 	    | ((unsigned short)t_cp[1]) \
 	    ; \
 	(cp) += NS_INT16SZ; \
-}
+} while (0)
+#endif
+
+#ifndef NS_GET32
+#define NS_GET32(l, cp) do { \
+	register unsigned char *t_cp = (unsigned char *)(cp); \
+	(l) = ((unsigned long)t_cp[0] << 24) \
+	    | ((unsigned long)t_cp[1] << 16) \
+	    | ((unsigned long)t_cp[2] << 8) \
+	    | ((unsigned long)t_cp[3]) \
+	    ; \
+	(cp) += NS_INT32SZ; \
+} while (0)
 #endif
 
 #ifndef T_TXT
@@ -195,6 +207,9 @@
 	const u_char * cend;
 	const u_char * rend;
 	int len;
+	int rectype, dummy, reclength;
+	int qid, qc, ac, nc, xc;
+	int q, curanswer;
 
 	/* 16 characters max in a dotted-quad address, plus 1 for null */
 	domain = ( char * )malloc( 17 + strlen( rbldomain ) );
@@ -238,49 +253,72 @@
 		return result;
 	}
 
-	/* Skip the header and the address we queried. */
-	cp = answer + sizeof( HEADER );
-	while( *cp != '\0' )
-	{
-		a = *cp++;
-		while( a-- )
-			cp++;
-	}
-
-	/* This seems to be a bit of magic data that we need to
-	   skip. I wish there were good online documentation
-	   for programming for libresolv, so I'd know what I'm
-	   skipping here. Anyone reading this, feel free to
-	   enlighten me. */
-	cp += 1 + NS_INT16SZ + NS_INT32SZ;
-
-	/* Skip the type, class and ttl. */
-	cp += ( NS_INT16SZ * 2 ) + NS_INT32SZ;
-
-	/* Get the length and end of the buffer. */
-	NS_GET16( c, cp );
-	cend = cp + c;
-
-	/* Iterate over any multiple answers we might have. In
-	   this context, it's unlikely, but anyway. */
-	rp = result;
-	rend = result + RESULT_SIZE - 1;
-	while( cp < cend && rp < rend )
-	{
-		a = *cp++;
-		if( a != 0 )
-			for( b = a; b > 0 && cp < cend && rp < rend;
-			  b-- )
+	/* Skip the header. */
+	cp = answer;
+	NS_GET16(qid, cp);
+	cp += 2; /* flags */
+	NS_GET16(qc, cp);
+	NS_GET16(ac, cp);
+	NS_GET16(nc, cp);
+	NS_GET16(xc, cp);
+
+	/* Skip the queries. */
+	q = 0;
+	while (q < qc && cp < answer + len) {
+		if (*cp > 63) { /* pointer */
+			cp += 6; /* skip pointer, class and type */
+			q++;
+		} else { /* label */
+			if (*cp == 0) {
+				cp += 5; /* skip nil, class and type */
+				q++;
+			} else
+				cp += *cp + 1; /* skip length and label */
+		}
+	}
+
+	/* cp should now be at the start of the first response */
+	curanswer = 0;
+	while (curanswer < ac) {
+		while (cp < answer + len) {
+			if (*cp > 63) { /* pointer */
+				cp += 2; /* skip pointer */
+				break;
+			} else { /* label */
+				if (*cp == 0) {
+					cp++;
+					break;
+				} else
+					cp += *cp + 1; /* skip length and label */
+			}
+		}
+		/* Get the record type, class, ttl, and length. */
+		NS_GET16( rectype, cp );
+		NS_GET16( dummy, cp );
+		NS_GET32( dummy, cp );
+		NS_GET16( reclength, cp );
+
+		/* Dump the contents of the record */
+		if (rectype != T_TXT) {
+			cp += reclength;
+			curanswer++;
+			continue;
+		}
+		cp++; /* skip TXT length byte */
+		cend = cp + reclength - 1;
+		rp = result;
+		rend = result + RESULT_SIZE - 1;
+		while( cp < cend && rp < rend )
+		{
+			if( *cp == '\n' || *cp == '"' || *cp == '\\' )
 			{
-				if( *cp == '\n' || *cp == '"' ||
-				  *cp == '\\' )
-				{
-					*rp++ = '\\';
-				}
-				*rp++ = *cp++;
+				*rp++ = '\\';
 			}
+			*rp++ = *cp++;
+		}
+		*rp = '\0';
+		return result;
 	}
-	*rp = '\0';
 	return result;
 }
 


--- NEW FILE rblcheck.spec ---
# $Id: rblcheck.spec,v 1.15 2005/06/29 07:46:35 oliver Exp $

Name:		rblcheck
Summary:	Command-line interface to RBL-style listings

Version:	1.5
Release:	9%{?dist}

Source0:	http://dl.sf.net/rblcheck/rblcheck-%{version}.tar.gz
Source1:	rblcheckrc
Group:		Applications/Internet

License:	GPL
URL:		http://rblcheck.sourceforge.net/

BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

# Change the text "RBL filtered by" to "listed by"
# (RBL is a trademark of MAPS LLC.)
# 'listed by' is more accurate
Patch0:		rblcheck-texttweak.patch

# Fix broken code for looking up TXT records, code borrowed
# from Ian Gulliver's "firedns" library (GPL), which can be found at:
# http://firestuff.org/
Patch1:		rblcheck-txt.patch

# Comes from a post to the rblcheck users mailing list. See:
# http://sourceforge.net/mailarchive/forum.php?thread_id=1371771&forum_id=4256
Patch2:		rblcheck-names.patch

BuildRequires:	docbook-utils

%description
rblcheck is a very basic interface to RBL-style DNS listings such as those
operated by the MAPS (http://www.mail-abuse.org/) and ORBL
(http://www.orbl.org/) projects.

%prep
%setup -q

%patch0 -p1 -b .texttweak
%patch1 -p0 -b .txt
%patch2 -p0 -b .names

%build
%configure
%{__make}

%install
rm -rf $RPM_BUILD_ROOT
%makeinstall

%{__install} -D -m644 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/rblcheckrc

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root,0755)
%doc AUTHORS ChangeLog NEWS README COPYING
%doc docs/rblcheck.ps docs/rblcheck.rtf docs/html/
%{_bindir}/rbl
%{_bindir}/rblcheck
%config(noreplace) %{_sysconfdir}/rblcheckrc

%changelog
* Wed Jun 29 2005 Oliver Falk <oliver at linux-kernel.at>		- 1.5-9
- Applied patch from Matthias (readability changes in specfile)

* Mon May 23 2005 Oliver Falk <oliver at linux-kernel.at>		- 1.5-8
- Fix defattr (permissions)

* Sat May 21 2005 Oliver Falk <oliver at linux-kernel.at>		- 1.5-7
- Even more changes that Paul suggested
- Remove the faulty lists
- Fix rpmlint warnings

* Fri May 20 2005 Oliver Falk <oliver at linux-kernel.at>		- 1.5-6
- Integrate more changes from Paul:
- Changed URL for MAPS (only spec related change)
- Add BuildRequires: docbook-utils
- Remove INSTALL from %doc section, as it is generic and not
  of any use to and end usser
- Remove duplicates from rblcheckrc (thanks Paul for mentioning!)
- Added xbl.spamhaus.org to the rblcheckrc
- Removed dead lists (dev.null.dk, monkeys.com, dorkslayers.com) from
  the rblcheckrc

* Thu May 19 2005 Oliver Falk <oliver at linux-kernel.at>		- 1.5-5
- Move setting of default list from the patch to
  %{_sysconfdir}/rblcheckrc, which is easier to maintain

* Thu May 19 2005 Oliver Falk <oliver at linux-kernel.at>		- 1.5-4
- Integrated patches Paul Howarth suggested

* Fri Mar 25 2005 Oliver Falk <oliver at linux-kernel.at>		- 1.5-3.2
- Fix rpmlint warnings

* Thu Mar 24 2005 Oliver Falk <oliver at linux-kernel.at>		- 1.5-3.1
- Rebuild

* Thu Sep 16 2004 Oliver Falk <oliver at linux-kernel.at>		- 1.5-3
- Name changed
- Added packager

* Wed Sep 08 2004 Oliver Pitzeier <oliver at linux-kernel.at>	- 1.5-2
- Cleanup

* Mon Apr  2 2001 Edward S. Marshall <esm at logic.net>
- Created this RPM spec.



--- NEW FILE rblcheckrc ---
-c
-t
-s sbl.spamhaus.org
-s xbl.spamhaus.org
-s dnsbl.njabl.org
-s unconfirmed.dsbl.org
-s multihop.dsbl.org
-s list.dsbl.org
-s opm.blitzed.org
-s relays.ordb.org
-s dul.dnsbl.sorbs.net
-s spam.dnsbl.sorbs.net
-s cbl.abuseat.org
-s blackholes.brainerd.net
-s blackholes.five-ten-sg.com
-s blackholes.intersil.net
-s block.blars.org
-s t1.dnsbl.net.au
-s t2.dnsbl.net.au
-s t3.dnsbl.net.au
-s bl.spamcop.net
-s flowgoaway.com
-s korea.services.net
-s pm0-no-more.compu.net
-s spamguard.leadmon.net
-s spamsources.fabel.dk
-s work.drbl.croco.net
-s relays.linux-kernel.at


Index: .cvsignore
===================================================================
RCS file: /cvs/extras/rpms/rblcheck/devel/.cvsignore,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- .cvsignore	29 Jun 2005 08:32:53 -0000	1.1
+++ .cvsignore	29 Jun 2005 08:33:44 -0000	1.2
@@ -0,0 +1 @@
+rblcheck-1.5.tar.gz


Index: sources
===================================================================
RCS file: /cvs/extras/rpms/rblcheck/devel/sources,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sources	29 Jun 2005 08:32:53 -0000	1.1
+++ sources	29 Jun 2005 08:33:44 -0000	1.2
@@ -0,0 +1 @@
+fb7ee9adc0e09eee9dda195f9b9e7ca4  rblcheck-1.5.tar.gz




More information about the fedora-extras-commits mailing list