On Sun, Nov 07, 1999 at 02:24:52PM -0700, Bob ross wrote:
> Is there a way to change this code from a user .qmail to only allow users or domains 
>listed in the file.
> 
> |if test -n "`fgrep -x $SENDER badmailfrom`"; then echo Go Away;exit 99; else exit 
>0; fi


At this stage, I'll go for a perl oneliner:

|perl -e '($u,$d)=$ENV{SENDER}=~/(.+)?\@(.+)/;if(`grep "$d" baddomainfrom`){print "Go 
|Away";exit 99}else{exit 0}'

Remember that if ross.com is in baddomainfrom, then a grep on oss.com will
also get a hit here, so I rather go for this one:

|perl -e '($u,$d)=$ENV{SENDER}=~/(.+)?\@(.+)/;if(`grep "^$d\$" baddomainfrom`){print 
|"Go Away";exit 99}else{exit 0}'

(NB! no trailing whitespace wanted in the baddomainfrom here!)

If you want to make it even simpler, don't print the "Go Away" message:

|perl -e '($u,$d)=$ENV{SENDER}=~/(.+)?\@(.+)/; exit(`grep "^$d\$" 
|baddomainfrom`?99:0;)'


(Note that you can modify this solution to reject on users instead although
that would be more than silly.)

/magnus

--
MOST useless 1998 * http://x42.com/

Reply via email to