Russell Nelson ([EMAIL PROTECTED]) wrote:
: Yusuf Goolamabbas writes:
: > Hi, The following web site
: >
: > http://www.imrss.org/dssl/
: >
: > seems to have a mechanism to prevent spammers from sending directly
: > from dial-up lines. The site has no docs on how to get qmail
: > integrated with it, Anybody have any idea
: Ought to work just fine using rblsmtpd. Look on koobera (as usual).
This might answer.
/*
Filter connections from dial-up hosts, based on patterns.txt
which is a list of regular expressions of dial-up ip hostnames
obtainable from www.imrss.org/dssl/
To build this, you must have already built djb's cdb package.
Compile with something like:
cc dssl-filter.c -o dssl-filter -I<path> -L<path> -lcdb
where <path> is the path to the cdb source directory.
To use this, first build the cdb version of the patterns.txt file:
{ while read dom hos; do
echo "+${#dom},${#hos}:${dom}->${hos}"
done; echo; } <patterns.txt |cdbmake cdbfile cdbtmp
(assuming a fairly modern sh-type shell.)
Make sure patterns.txt does not contain blank lines.
To run this, insert into standard djb exec chain:
tcpserver 0 smtp dssl-filter cdbfile qmail-smtpd
The filter requires TCPREMOTEHOST to be set if it is to do any
filtering, so don't use option -H to tcpserver.
No warranty, no restrictions, YMMV.
-harold
*/
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <regex.h>
#include <uint32.h>
#include <cdb.h>
#define FLAGS (REG_EXTENDED|REG_ICASE|REG_NOSUB)
int cdbfd;
char *
lookup(char * key, int len)
{
uint32 dlen;
static char buf[256];
if( 1 != cdb_seek(cdbfd, key, len, &dlen) )return(0);
if( dlen > 255 )return(0);
if( dlen != read(cdbfd, buf, dlen) )return(0);
buf[dlen] = '\0';
return(buf);
}
int
main(int argc, char ** argv)
{
char * remotehost;
char * dom;
char * hos;
regex_t regex;
int len;
if( argc < 3 )_exit(1);
if( ! (remotehost = getenv("TCPREMOTEHOST")) )goto done;
if( -1 == (cdbfd = open(argv[1], O_RDONLY)) )goto done;
for(dom = remotehost; *dom; dom++);
for(len = 0, dom--; dom > remotehost; dom--, len++)
if( '.' == *dom )
if( (hos = lookup(dom + 1, len)) ){
*dom = '\0';
if( 0 == regcomp(®ex, hos, FLAGS) )
if( 0 == regexec(®ex, remotehost, 0, 0, 0) )
exit(3);
*dom = '.';
}
done:
execvp(argv[2], argv + 2);
_exit(128);
}