From 8d19917103cd5b8185056a6ebfe951a45535c3ea Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 5 Jan 2011 18:24:22 +0000 Subject: [PATCH 1/1] Split nameIsInList into nameIsInListRegexp (for most things) and nameIsInListExactly (good posters and noack lists) --- stump/bin/needAck | 2 +- stump/bin/processNoack.pl | 2 +- stump/bin/processPreapproved | 2 +- stump/bin/robomod.pl | 30 ++++++++++++++++++++++++++++-- stump/bin/submission.pl | 12 ++++++------ 5 files changed, 37 insertions(+), 11 deletions(-) diff --git a/stump/bin/needAck b/stump/bin/needAck index 9b464d3..3a0b663 100755 --- a/stump/bin/needAck +++ b/stump/bin/needAck @@ -9,7 +9,7 @@ require "$MNG_ROOT/bin/robomod.pl"; # checks if poster needs ack sub checkAck { - $needAck = ! &nameIsInList( $From, "noack.list" ); + $needAck = ! &nameIsInListExactly( $From, "noack.list" ); } diff --git a/stump/bin/processNoack.pl b/stump/bin/processNoack.pl index 33f3d04..521e36f 100755 --- a/stump/bin/processNoack.pl +++ b/stump/bin/processNoack.pl @@ -27,7 +27,7 @@ if( $From =~ m/([\w-\.]*)\@([\w-\.]+)/ ) { exit 0; } -if( !&nameIsInList( $From, "noack.list" ) ) { # need to preapprove +if( !&nameIsInListExactly( $From, "noack.list" ) ) { # need to preapprove print STDERR "Adding $From to the noack list...\n"; open( NOACK, ">>$NoAckFile" ) or die $!; print NOACK "$From\n" or die $!; diff --git a/stump/bin/processPreapproved b/stump/bin/processPreapproved index 5933a2b..d866490 100755 --- a/stump/bin/processPreapproved +++ b/stump/bin/processPreapproved @@ -39,7 +39,7 @@ if( $From =~ m/([\w-\.]*)\@([\w-\.]+)/ ) { exit 0; } -if( !&nameIsInList( $From, "good.guys.list" ) ) { # need to preapprove +if( !&nameIsInListExactly( $From, "good.guys.list" ) ) { # need to preapprove &logAction( "Action: processPreapproved $From\n" ); open( GOOD_GUYS, ">>$GoodGuys" ) or die $!; print GOOD_GUYS "$From\n" or die $!; diff --git a/stump/bin/robomod.pl b/stump/bin/robomod.pl index 3534c5a..09888a1 100755 --- a/stump/bin/robomod.pl +++ b/stump/bin/robomod.pl @@ -7,7 +7,7 @@ $MNG_ROOT = $ENV{'MNG_ROOT'} || die "Root dir for moderation not specified"; ###################################################################### checkAck # checks if poster needs ack -sub nameIsInList { +sub nameIsInListRegexp { local( $listName ) = pop( @_ ); local( $address ) = pop( @_ ); @@ -23,7 +23,33 @@ sub nameIsInList { next if $item =~ /^ *$/; - if( eval { $address =~ /$item/i; } || "\L$address" eq "\L$item" ) { + if( eval { $address =~ /$item/i; } ) { + $Result = $item; + } + } + + close( LIST ); + + return $Result; +} + +sub nameIsInListExactly { + local( $listName ) = pop( @_ ); + local( $address ) = pop( @_ ); + + local( $item ); + + $Result = 0; + + open( LIST, "$MNG_ROOT/data/$listName" ); + + while( $item = ) { + + chop $item; + + next if $item =~ /^ *$/; + + if( "\L$address" eq "\L$item" ) { $Result = $item; } } diff --git a/stump/bin/submission.pl b/stump/bin/submission.pl index 8a7331a..f319617 100755 --- a/stump/bin/submission.pl +++ b/stump/bin/submission.pl @@ -133,7 +133,7 @@ print STDERR "Too many newsgroups\n"; # checks if poster needs acknowledgment of receipt # sub checkAck { - if( &nameIsInList( $From, "noack.list" ) ) { + if( &nameIsInListExactly( $From, "noack.list" ) ) { $needAck = "no"; } else { $needAck = "yes"; @@ -163,8 +163,8 @@ print STDERR "FromSig = $FromSig, good = $good\n" if $FromSig; return "$Command_Reject signature Your PGP signature does NOT match, or is not in our keyring"; } - if( &nameIsInList( $From, $PGPMustList ) || - ($PGPCheckPreapproved && &nameIsInList($From, $goodGuys) ) ) { + if( &nameIsInListRegexp( $From, $PGPMustList ) || + ($PGPCheckPreapproved && &nameIsInListExactly($From, $goodGuys) ) ) { if( $FromSig eq "" ) { return "$Command_Reject signature You are REQUIRED to sign your posts."; } @@ -214,7 +214,7 @@ sub Filter { } } - if( &nameIsInList( $From, $badGuys ) ) { + if( &nameIsInListRegexp( $From, $badGuys ) ) { return "$Command_Reject blocklist"; } @@ -223,7 +223,7 @@ sub Filter { # "suspicious" and will be forwarded to a humen mod for review. # As an example of a bad word may be "MAKE MONEY FAST - IT REALLY WORKS!!!" # - if( $badWord = &nameIsInList( $Body, $badWords ) ) { + if( $badWord = &nameIsInListRegexp( $Body, $badWords ) ) { print STDERR "BAD WORD $badWord FOUND!!!\n"; return $Command_Suspicious; # messages from approved guys MAY be # suspicious if they write about @@ -237,7 +237,7 @@ print STDERR "BAD WORD $badWord FOUND!!!\n"; } # Checking preapproved list - if( &nameIsInList( $From, $goodGuys ) ) { + if( &nameIsInListExactly( $From, $goodGuys ) ) { local( $from ) = $From; $from =~ s/^From: //i; print STDERR "$from is a PREAPPROVED person\n"; return $Command_Approve; -- 2.30.2