🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #80303

Re: Can Cleanfeed filter on a specific user?

#80303
From: John F. Morse
Date: Mon, 09 Mar 2009 17:27
187 lines
8439 bytes
Steve wrote:
> On Mon, 09 Mar 2009 11:15:41 -0500, John F. Morse wrote in
> Message-Id: <gp3fbd$k29$1@optima7.xanadu-bbs.net>:
>   
>> Here is what I have added to the bottom of the sub local_filter_first 
>> (the "from_name_here" is the actual name in the header From entry):
>>     
>
> [snip]
>
> Hi John,
>
> It looks like you're using the example cleanfeed.local supplied with
> cleanfeed-20020501.  I'd suggest you use this for examples rather than
> going live with it.  It contains various sections that are specific to
> the environment it was created on.  For example:
>
> $localpost = 1 if $hdr{'X-Trace'} and $hdr{'X-Trace'} =~ /\.inwind\.it /;
>
> This will only work if your domain is inwind.it, so anything that sits
> within the "if localpost" conditional will not work.
>
> I'd suggest keeping that file as a reference and creating your own from
> scratch.  All you want at the moment in local_filter_first is:
>
> sub local_filter_first {
>     if ($hdr{'From'} =~ /$from_name_here/) {
>         return reject('Spam');    
> };
>
> I'd further suggest:
> * Delete all the other local_filter sections and create them as needed.
> * Keep local_config for defining things specific to your environment.
> * Use local_filter_reject to log what you're filtering.
> * Keep the few lines at the bottom that reside outside any functions,
>   they're important.
>   


Thanks for the fast reply, Steve.

Have made your suggested edits, but am now receiving an error message in 
news.notice :

Mar  9 11:58:08 localhost innd: filter: Cannot load 
/etc/news/filter/cleanfeed.local: Missing right curly or square bracket 
at (eval 7) line 90, at end of line syntax error at (eval 7) line 90, at 
EOF

This is odd because there are only 88 lines in the cleanfeed.local file 
(see complete file below).

I do see an unbalance in the curly brackets in the sub 
local_filter_first section. Should it be like this? :

sub local_filter_first {
    if ($hdr{'From'} =~ /$from_name_here/) {
        return reject('Spam');    
    }  <==Added?
};



Here is how I "butchered" the example cleanfeed.local file:


      1 # vim: set syntax=perl ts=4 ai si:
      2
      3 ######################### IMPORTANT! - READ CAREFULLY 
########################
      4 # This file contains some parts of my own cleafeed.local.
      5 # Many of these checks are too much content based than what I feel
      6 # confortable to put in the official source and others are just
      7 # experimental or need site-specific tweaks.
      8 # Before using any of this code please *think*, and be sure you 
really
      9 # understand what it does.
     10 ######################### IMPORTANT! - READ CAREFULLY 
########################
     11
     12 my @badaspnntps = (
     13         'PostIT Now',
     14         'Jobsearch Limited',
     15         'AudioWeb',                                     # 
audioweb.com
     16         'Alex',                                         # sex spam
     17         'Paul Simmons',                         # OperationIT.com
     18         'Alan',                                         # equest.com
     19         'Digital Media Works',          # html sex spam
     20         'Captive Technology',           # ccsscorp.com jobs flood
     21         'Computer Horzions ISG',        # isgjobs.com jobs flood
     22         'Mike Powers',                          # 
ResumeGateway.com jobs flood
     23         'from_name_here',
     24 );
     25
     26 my %badaspnntp = map { $_ => 1 } @badaspnntps;
     27 undef @badaspnntps;
     28
     29 sub local_filter_first {
     30                     if ($hdr{'From'} =~ /$from_name_here/) {
     31                                 return reject('Spam');
     32 };
     33
     34                        
     35 sub local_filter_reject {
     36         my ($vr, $sr) = @_;
     37
     38         saveart('CF.local', $vr)
     39                                 if $hdr{'X-Trace'} and 
$hdr{'X-Trace'} =~ /\.inwind\.it /;
     40             saveart('WARN.it', $vr)
     41                     if $vr =~ /^NewsAgent/ and $hdr{Newsgroups} 
=~ /\bit\./;
     42             saveart('W.supersedes') if $vr =~ /^Excessive 
Supersedes/;
     43 #       saveart('CF.scoring', $vr) if $vr =~ /^Scoring filter/;
     44             saveart('CF.NewsAgent', $vr) if $vr =~ /^NewsAgent/;
     45             saveart('CF.SEX', $vr) if $vr =~ /^Sex spam/ and 
$lines < 300;
     46             saveart('Z.EMP', $vr) if $vr =~ /^EMP/;
     47             saveart('R.nanacancel') if $vr eq 'Cancel in 
forbidden group';
     48
     49             return @_;
     50 }
     51
     52
     53 sub local_config {
     54         %config_local = (
     55                 block_late_cancels => 1,
     56                 active_file => '/var/lib/news/active',
     57                 statfile => '/var/spool/news/cleanfeed.stats',
     58 #               html_statfile => 
'/var/spool/news/cleanfeed.stats.html',
     59                 stats_interval => 300,
     60                 do_emp_dump => 1,
     61                 emp_dump_file => '/tmp/empdump',
     62                 debug_batch_directory => '/var/spool/news/spam',
     63         );
     64
     65         %config_append = (
     66                 bin_allowed => 
'^alt\.mag\.'|'^alt\.binaries\.joker'|'^xanadu\.binaries'|'^xanadu\.brisbee'|'
     66 ^xanadu\.test',
     67         );
     68
     69         $Restricted_Groups{netscape} = '^netscape\.';
     70
     71         $config{reject_suspect_cancels} = 0;
     72         $config{watch_cancels} = 0;
     73         if ($config{watch_cancels}) {
     74                 eval { require AnyDBM_File; import AnyDBM_File;
     75                                 require Fcntl; import Fcntl; }; 
# XXX ugly
     76                 if ($@) {
     77                         $config{watch_cancels} = undef;
     78                         slog('E', 'Cannot load AnyDBM_File: ' . $@);
     79                 }
     80                 tie %LocalPosts, 'AnyDBM_File', "$config_dir/posts",
     81                                 &Fcntl::O_CREAT|&Fcntl::O_RDWR, 0666
     82                         or slog('E', 'Cannot load AnyDBM_File: ' 
. $!);
     83         }
     84 }
     85
     86 print 
$now.$config_dir.$lines.%Restricted_Groups.%Moderated.%config_local.%config_append.@followups 
if 0; # l
     86 int food
     87
     88 1;


Does that resemble what you suggested?

Note I also had an addition on line 23 from earlier, which didn't seem 
to work. I probably should remove it. Maybe remove everything from line 
2 through line 28?


-- 
John 

No Microsoft, Apple, AT&T, Novell, Trend Micro, nor Ford products were used in the preparation or transmission of this message.

The EULA sounds like it was written by a team of lawyers who want to tell me what I can't do. The GPL sounds like it was written by a human being, who wants me to know what I can do.
Technical Details
Message-ID: <gp3jhm$l97$1@optima7.xanadu-bbs.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!border1.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.straub-nv.de!pitt.edu!usenet01.sei.cmu.edu!nntp.club.cc.cmu.edu!74.222.216.191.MISMATCH!optima7.xanadu-bbs.net!not-for-mail
References: <gou9pu$a8c$1@optima7.xanadu-bbs.net> <80ocwdgpxd.fsf@banana.shacknet.nu> <gp3fbd$k29$1@optima7.xanadu-bbs.net> <slrngrahju.6et.steve@news.mixmin.net>

Show Full Headers
Complete Article Headers
Message-ID: <gp3jhm$l97$1@optima7.xanadu-bbs.net>
Subject: Re: Can Cleanfeed filter on a specific user?
Date: Mon, 09 Mar 2009 12:27:18 -0500
From: "John F. Morse" <xanadu.bbs@example.invalid>
References: <gou9pu$a8c$1@optima7.xanadu-bbs.net> <80ocwdgpxd.fsf@banana.shacknet.nu> <gp3fbd$k29$1@optima7.xanadu-bbs.net> <slrngrahju.6et.steve@news.mixmin.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!border1.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.straub-nv.de!pitt.edu!usenet01.sei.cmu.edu!nntp.club.cc.cmu.edu!74.222.216.191.MISMATCH!optima7.xanadu-bbs.net!not-for-mail
Newsgroups: news.software.nntp
Organization: Xanadu BBS
Lines: 187
Reply-To: dont.bother
NNTP-Posting-Host: n100.xanadu-bbs.net
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: optima7.xanadu-bbs.net 1236619638 21799 192.168.89.210 (9 Mar 2009
X-Complaints-To: newsmaster@xanadu-bbs.net
NNTP-Posting-Date: Mon, 9 Mar 2009 17:27:18 +0000 (UTC)
User-Agent: Thunderbird 2.0.0.19 (X11/20090105)
In-Reply-To: <slrngrahju.6et.steve@news.mixmin.net>