chiark / gitweb /
Split nameIsInList into nameIsInListRegexp (for most things) and nameIsInListExactly...
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 5 Jan 2011 18:24:22 +0000 (18:24 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 5 Jan 2011 18:24:22 +0000 (18:24 +0000)
stump/bin/needAck
stump/bin/processNoack.pl
stump/bin/processPreapproved
stump/bin/robomod.pl
stump/bin/submission.pl

index 9b464d3cb0575fe1d7fff2aaf03d6cc669318ea2..3a0b663e1e8e0b6bdd7f4751a545abf214419d70 100755 (executable)
@@ -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" );
 
 }
 
index 33f3d047b35886d5be19b59d5c374cdc09f1d80e..521e36f50e1213c2383adbbef944a17ae223e2e7 100755 (executable)
@@ -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 $!;
index 5933a2b52e7c8e71acb74fd65663d8f84f22aa2c..d866490108bfc32d5421eca388e8f200b85fc9b9 100755 (executable)
@@ -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 $!;
index 3534c5ab152d9e303be877c8330b692ecf0c5203..09888a18d3b97fd4976c1d3963064e96618e5d3a 100755 (executable)
@@ -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 = <LIST> ) {
+
+    chop $item;
+
+    next if $item =~ /^ *$/;
+
+    if( "\L$address" eq "\L$item" ) {
       $Result = $item;
     }
   }
index 8a7331a88a58044f5f8e7e74710a9f4a76fb759c..f31961774a9fafbee80594f9f3735d81c8abe477 100755 (executable)
@@ -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;