4 # Copyright (C) 2002-2003 Jan Kratochvil <project-PerlMail@jankratochvil.net>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 package PerlMail::Config;
22 use vars qw($VERSION);
23 $VERSION=do { my @r=(q$Revision$=~/\d+/g); sprintf "%d.".("%03d"x$#r),@r; };
28 use vars qw(@ISA @EXPORT);
32 $Mail @ValidUsers $IdleMax $MaxBodySMS @SMSwebRcpt $SMSwebRcpt_username
33 $Lock_pathname $PeerAddr $Socket_timeout $DB_table $DBI_database $DBI_user $DBI_pwd
34 $clamscan_waitpid_timeout
35 $sendmail_orig @addr_addon @h_rcpt @h_from
36 %audit_profile @sms_squeezes @alternates_host @dnsbl_whitelist
38 $Audit $is_pgp $opt_F $procmailFROM_MAILER $store_ignore $store_ignorenewmail
43 use Carp qw(confess cluck);
47 for (qw(headerhas store headeris did dnsbl store_muttrc_alternates Received_for parts_linear mime_type
48 body_first body_simple is_multipart mimehead mimebody spamassassin clamscan header_remap)) {
49 eval 'sub '.$_.' { return ::'.$_.'(@_); }';
54 # perlmail-accept & perlmail-sendmail
56 # Various configuration files location is derived from it:
57 our $HOME="/home/jkratoch";
63 our $Mail="$HOME/Mail";
64 # Users respected for the 'idle' state (see $IdleMax):
65 our @ValidUsers=qw(root lace short kratochvil _local jkratoch);
66 # Maximum number of local console idle seconds while still considered as 'active user':
68 # Maxium number of bytes to pass to Lingua::EN::Squeeze (performance optimization):
69 our $MaxBodySMS=0x1000;
70 # Telephone number to send SMSes by WWW::SMS to:
71 our @SMSwebRcpt=qw(420 602 431329);
72 # Some WWW::SMS modules require username:
73 our $SMSwebRcpt_username="lace2";
74 our $clamscan_waitpid_timeout=3;
79 # Global system lock for exclusive $DB_table access:
80 our $Lock_pathname="/tmp/PerlMail.lock";
81 # 'workstation' hostname and port. Hostname may be dyndns:
82 our $PeerAddr="kashome.dyn.jankratochvil.net.:852";
83 #our $PeerAddr="127.0.0.1:2852";
84 # 15sec is NOT enough as the remote peer must complete mail store:
85 our $Socket_timeout=7600;
87 our $DB_table="PerlMail_folder";
88 # MySQL database name:
89 our $DBI_database="short";
91 our $DBI_user="short";
92 # MySQL user password:
93 our $DBI_pwd=$HOME."/priv/mysql.".$DBI_user.".pwd";
96 # Pathname of the original sendmail(8) binary:
97 our $sendmail_orig=(-x ($_="/usr/sbin/sendmail-orig") ? $_ : "/usr/sbin/sendmail");
98 # List of addresses to locally Bcc all mails to:
99 # Mail-Alias-1.12 defaults to "/etc/mail/aliases" which does not exist on RedHat sendmail-8.12.5-7
100 # Mail-Alias-1.12 will clutter $_ !
101 our @addr_addon=(Mail::Alias->new("/etc/aliases")->exists("sentout") ? ("sentout") : ());
103 our $opt_F; # imported
104 our $is_pgp; # imported
105 # Generate new From address for the target $rcpt of type Mail::Address.
107 # RedHat sendmail-8.9.3-20/src/conf.c/HdrInfo[]/\Q/* destination fields */\E
108 # FIXME: Recognize "Resent-$_" headers for -t but when we are in 'resent' mode?
109 our @h_rcpt=( # case in-sensitive!
115 # ordering matters; first header found is substituted
116 # last header is subsituted if no one is found
125 # Setup profile names.
126 # First element of /^=/ form copies it referenced profile to be extended.
127 # 'did' =>did() subroutine will return true for it.
128 # 'syslog' =>Use syslog(3).
129 # 'bell' =>Bell sound.
130 # 'sms=\d+'=>Send SMS by WWW::SMS with specified maximum # of parts
133 "silent"=>["=btw" ,"did"],
134 "log" =>["=silent","syslog"],
135 "bell" =>["=log" ,"bell"],
136 "sms" =>["=bell" ,"sms=1"],
137 "crit" =>["=sms" ,"sms=3"],
139 # Try the squeezing methods in this order:
141 { "SqueezeControl"=>"noconv" },
142 { "SqueezeControl"=>"conv" ,"SQZ_OPTIMIZE_LEVEL"=>0 },
143 { "SqueezeControl"=>"conv" ,"SQZ_OPTIMIZE_LEVEL"=>1 },
144 { "SqueezeControl"=>"med" ,"SQZ_OPTIMIZE_LEVEL"=>0 },
145 { "SqueezeControl"=>"med" ,"SQZ_OPTIMIZE_LEVEL"=>1 },
146 { "SqueezeControl"=>"max" ,"SQZ_OPTIMIZE_LEVEL"=>0 },
147 { "SqueezeControl"=>"max" ,"SQZ_OPTIMIZE_LEVEL"=>1 },
149 # Hostnames where we had alternate e-mail addresses:
150 our @alternates_host=(
151 "jabberwock.ucw.cz", # short@ucw.cz
152 "atrey.karlin.mff.cuni.cz", # short@atrey.karlin.mff.cuni.cz
153 "k332.feld.cvut.cz", # short@k332.feld.cvut.cz
155 # Override DNS blacklists:
156 our @dnsbl_whitelist=(
157 "195.250.128.83", # smtp3.vol.cz; vol.cz.multistage.blackholes.five-ten-sg.com.
158 "64.49.222.22", # mail.pm.org: rackspace.com.spam-support.blackholes.five-ten-sg.com.
159 "208.147.243.5", # gambit.liquidcomm.net: cw.net.spam-support.blackholes.five-ten-sg.com.
160 "213.235.135.70", # smtp.tiscali.cz: tiscali.cz.multistage.blackholes.five-ten-sg.com.
161 "205.139.198.11", # eniac.disaster.com: cw.net.spam-support.blackholes.five-ten-sg.com.
162 "127.0.0.2", # 2.0.0.127.relays.ordb.org.
163 "65.113.40.131", # bozo.vmware.com: qwest.net.spam-support.blackholes.five-ten-sg.com.
164 "66.218.85.33", # mta2.wss.scd.yahoo.com: yahoo.com.spam.blackholes.five-ten-sg.com.
165 "212.80.76.42", # mx2.seznam.cz: seznam.cz.free.blackholes.five-ten-sg.com.
166 "64.110.204.63", # hsdbrg64-110-204-63.sasknet.sk.ca: 64.110.202.181.sasknet.sk.ca.misc.spam.blackholes.five-ten-sg.com.
167 "212.80.76.44", # mx1.seznam.cz: 44.76.80.212.blackholes.five-ten-sg.com.
168 "212.80.76.29", # prace.seznam.cz: 212.80.76.42.seznam.cz.free.blackholes.five-ten-sg.com
169 "193.252.22.30", # smtp1.wanadoo.fr: 30.22.252.193.blackholes.five-ten-sg.com
170 "213.151.87.16", # posta.dobnet.cz: 16.87.151.213.relays.ordb.org
171 "70.71.0.212", # Red Hat
174 our $Audit; # imported
175 our $procmailFROM_MAILER; # imported
176 our $store_ignorenewmail; # imported
177 our $store_profile; # imported
178 our $store_ignore; # imported
181 $store_profile=undef();
183 # never spawn new mail if FROM_MAILER
184 # $isFROM_MAILER postponed after maillists as they may look as FROM_MAILER
186 my $isFROM_MAILER=$Audit->header()=~/$procmailFROM_MAILER/mio;
187 $store_ignorenewmail=(0
189 || headerhas "From",'<Regexp:^owner->'
195 # Do not local $store_file as it is our-imported
196 $store_profile="silent";
197 store "=spam" if grep /^\Qshort\@k332.feld.cvut.cz\E/i,Received_for();
198 # TODO: foreign violation of RFC 822 section 4.4.4, Subject:.*Automatick.+odpov.+v.+nep.+tomnosti
199 store "=spam" if headeris "From",'<ghandchi@hotmail.com>';
200 store "=spam" if headeris "From",'<newsletter@levnapc.cz>';
201 store "=spam" if headeris "From",'<Tomas@dtpstudio.cz>';
202 store "=spam" if headeris "From",'<BNcom@email.bn.com>';
203 store "=spam" if headeris "From",'<e4luck@lists.opt4email.com>';
204 store "=spam" if headeris "From",'<mailcontests@lists.servitall.com>';
205 store "=spam" if headeris "From",'<canda@lica.cz>';
206 store "=spam" if headeris "From",'<newsletter@thecareernews.com>';
207 store "=spam" if headeris "From",'<newsletter@jobseekerweekly.com>';
208 store "=spam" if headeris "From",'<newsletter@jobmarketweekly.com>';
209 store "=spam" if headeris "From",'<newsletter@career-digest.com>';
210 for my $header (qw(To Cc)) {
211 store "=spam" if headerhas $header,'<st@jankratochvil.net>';
212 store "=spam" if headerhas $header,'<est@jankratochvil.net>';
213 store "=spam" if headerhas $header,'<uest@jankratochvil.net>';
214 store "=spam" if headerhas $header,'<kratochvil.net@jankratochvil.net>';
217 # weak detection: files with text/html w/o text/plain are usually a spam
218 my @types_linear=map({ mime_type($_); } parts_linear());
219 store "=spamhtml" if grep({ $_ eq "text/html"; } @types_linear) && !grep({ $_ eq "text/plain"; } @types_linear);
221 ### store "=spambig5" if ($_=mimehead(body_first())->mime_attr("Content-Type.charset")) && /^big5/i;
223 $store_profile=undef();
226 for ($Audit->get("Received")) {
227 $nonrh=1 if /\sby\s+mx\d+\Q.redhat.com\E\s/s;
229 $nonrh=1 if !headeris("From",qr/[@]redhat.com/i);
232 # Internal RH mails are never spam.
234 # It is too expensive to scan the huge =caperr announcements by spamassassin(1).
235 return if headeris("From",qr/^captive-[a-z]*@/);
236 # Do not local $store_file as it is our-imported
237 $store_profile="log";
239 ### store "=spam".";virus=$_" if $_=clamscan();
240 store "=spam".";spamassassin".($_ eq 1 ? "" : "=$_") if $_=spamassassin();
242 ### store "=spam".";$_" if $_=dnsbl '.relays.ordb.org.' ,1; # all hosts
244 store "=spam".";$_" if $_=dnsbl '.blackholes.mail-abuse.org.' ,1; # all hosts
245 # we don't check all hosts as they can be "dialup" category, FIXME: check for it
246 # store "=spam".";$_" if $_=dnsbl '.blackholes.five-ten-sg.com.',0; # just first
247 # I don't send viruses but viruses propagate mails of mine
249 store "=spam".";ravmd" if headeris "X-Mailer",'ravmd/8.3.2';
250 store "=spam".';short@ucw.cz+MAILER' if $isFROM_MAILER && headeris("To",'<short@ucw.cz>');
251 if (!is_multipart()) {
252 local $_=mimebody(body_first());
253 my %sites=map(($_=>1),qw(
254 brandenburg.rz.fhtw-berlin.de
257 www.aufenthaltstitel.de
259 www.deutschlandchronik.de
261 www.leverkusener-aufbruch.com
263 www.mjoelnirsseite.de
273 while (m{http://([^/]+)/}g) {
274 do { $found=1; next; } if $sites{$1};
278 $found=1 if /^\s*Lese selbst:\n/s;
279 store "=spam".';german-news' if $found;
282 $store_profile=undef();
285 store "=err","bell" and return if headerhas \&Received_for,'<short+err@>';
286 store "=host1","bell" and return if headerhas \&Received_for,qr/\Qjan.kratochvil+\E\S*\Q.at.host1.dyn.jankratochvil.net\E@/;
288 # if (headeris "X-Calendar-Attachment",qr/./) {
289 # store "=zimbra","btw";
290 # my $headless=$::Message;
291 # $headless=~s{^From .*?\n}{} or cluck "No From header for Zimbra";
294 # open CHILD,q{|sendmail jkratoch@calendar.corp.redhat.com}
295 # or cluck "Cannot forward to Zimbra";
296 # print CHILD $headless or cluck;
297 # close CHILD or cluck;
302 store "=mozillabug","log" if headeris "From" ,'<bugzilla-daemon@mozilla.org>';
303 store "=9ku","log" if headeris "List-Id" ,'<9000.listman.net>';
304 store "=9kd","log" if headeris "Sender" ,'<owner-9000-developers@geekstuff.co.uk>';
305 store "=spong","log" if headeris "List-Id" ,'<spong-users.lists.sourceforge.net>';
306 store "=gtkd","silent" if headeris "List-Id" ,'<gtk-devel-list.gnome.org>';
307 store "=gnomevfs","log" if headeris "List-Id" ,'<gnome-vfs-list.gnome.org>';
308 store "=hw","log" if headeris "List-Post",'<hw-news@list.gin.cz>';
309 store "=gnokii","log" if headeris "List-Id" ,'<gnokii-users.mail.freesoftware.fsf.org>';
310 store "=winelic","silent" if headeris "List-Id" ,'<wine-license.winehq.org>';
311 store "=wined","silent" if headeris "List-Id" ,'<wine-devel.winehq.org>';
312 store "=winepat","silent" if headeris "List-Id" ,'<wine-patches.winehq.org>';
313 store "=winecvs","silent" if headeris "List-Id" ,'<wine-cvs.winehq.org>';
314 store "=wineann","silent" if headeris "List-Id" ,'<wine-announce.winehq.org>';
315 store "=wineconf","silent" if headeris "List-Id" ,'<wineconf.winehq.org>';
316 store "=ros","silent" if headeris "List-Id" ,'<ros-general.reactos.com>';
317 store "=roskernel","silent" if headeris "List-Id" ,'<ros-kernel.reactos.com>';
318 store "=rosd","silent" if headeris "List-Id" ,'<ros-dev.reactos.com>';
319 store "=roscvs","silent" if headeris "List-Id" ,'<ros-cvs.reactos.com>';
320 store "=rossvn","silent" if headeris "List-Id" ,'<ros-svn.reactos.com>';
321 store "=rosbug","silent" if headeris "Reply-To" ,'<scarab@reactos.wox.org>';
322 store "=fsd","silent" if headeris "X-Mailing-List",'<linux-fsdevel@vger.kernel.org>';
323 store "=kernel","silent" if headeris "X-Mailing-List",'<linux-kernel@vger.kernel.org>';
324 store "=kernelnet","silent" if headeris "X-Mailing-List",'<linux-net@vger.kernel.org>';
325 store "=ia64","silent" if headeris "X-Mailing-List",'<linux-ia64@vger.kernel.org>';
326 store "=linuxjap","silent" if headeris "X-Mailing-List",'<linux-japanese@vger.kernel.org>';
327 store "=kernelann","silent" if headeris "X-Mailing-List",'<linux-kernel-announce@vger.kernel.org>';
328 store "=sparse","silent" if headeris "X-Mailing-List",'<linux-sparse@vger.kernel.org>';
329 store "=smp","silent" if headeris "X-Mailing-List",'<linux-smp@vger.kernel.org>';
330 store "=tacacs","silent" if headeris "Sender" ,'<tacplus-l@disaster.com>';
331 store "=tacacs","silent" if headeris "Sender" ,'<owner-tacplus-l@disaster.com>';
332 store "=tacacs","silent" if headeris "List-Id" ,'<devel.lists.tacplus.org>';
333 store "=pm","log" if headeris "List-Id" ,'<prague-pm.pm.org>';
334 store "=radary","log" if headeris "Reply-To" ,'<pha@radary.cz>';
335 store "=dnet","log" if headeris "Sender" ,'<@lists.distributed.net>';
336 store "=netinfo","log" if headeris "Sender" ,'<owner-netinfo-l@vol.cz>';
337 store "=slashdot","bell" if headeris "From" ,'<slashdot@slashdot.org>';
338 store "=freshmeat","bell" if headeris "From" ,'<noreply@freshmeat.net>';
339 store "=sourceforge","bell" if headeris "From" ,'<noreply@sourceforge.net>';
340 store "=gsmperlcvs","silent" if headeris("From" ,'<johan@intra.tektonica.com>')
341 && $Audit->subject()=~/^'.*' has been updated!$/;
342 store "=libtoold","silent" if headeris "List-Id" ,'<libtool.gnu.org>';
343 store "=libtoolpat","silent" if headeris "List-Id" ,'<libtool-patches.gnu.org>';
344 store "=automake","silent" if headeris "List-Id" ,'<automake.gnu.org>';
345 store "=autoconf","log" if headeris "List-Id" ,'<autoconf.gnu.org>';
346 store "=autoconfpat","log" if headeris "List-Id" ,'<autoconf-patches.gnu.org>';
347 store "=hurd","log" if headeris "List-Id" ,'<l4-hurd.gnu.org>';
348 store "=gccbug","silent" if headeris "List-Post",'<gcc-bugs@gcc.gnu.org>';
349 store "=gccann","log" if headeris "List-Post",'<gcc-announce@gcc.gnu.org>';
350 store "=gcc","silent" if headeris "List-Post",'<gcc@gcc.gnu.org>';
351 store "=gccpat","silent" if headeris "List-Post",'<gcc-patches@gcc.gnu.org>';
352 store "=ntfsann","silent" if headeris "List-Id" ,'<linux-ntfs-announce.lists.sourceforge.net>';
353 store "=ntfsd","silent" if headeris "List-Id" ,'<linux-ntfs-dev.lists.sourceforge.net>';
354 store "=orbit","silent" if headeris "List-Id" ,'<orbit-list.gnome.org>';
355 store "=kannel","log" if headeris "List-Id" ,'<users.kannel.org>';
356 store "=kanneld","log" if headeris "List-Id" ,'<devel.kannel.org>';
357 store "=mailmand","silent" if headeris "List-Id" ,'<mailman-developers.python.org>';
358 store "=asterisk-perl","log" if headeris "List-Post",'<asterisk-perl@lists.gnuinter.net>';
359 store "=i4l","silent" if headeris "List-Id" ,'<isdn4linux.listserv.isdn4linux.de>';
360 store "=glibc","silent" if headeris "List-Post",'<libc-alpha@sourceware.org>';
361 store "=fedann","bell" if headeris("List-Id" ,'<announce.lists.fedoraproject.org>')
362 || headeris("List-Id" ,'<fedora-announce-list.redhat.com>');
363 store "=fedpkg","bell" if headeris "List-Id" ,'<fedora-package-announce.redhat.com>';
364 store "=federrata","log" if headeris "Return-Path",'<root@app5.fedora.phx.redhat.com>';
365 store "=fedtools","log" if headeris "List-Id" ,'<fedora-tools-list.post-office.corp.redhat.com>';
366 store "=freleng","log" if headeris "List-Id" ,'<rel-eng.lists.fedoraproject.org>';
367 if (headeris("List-Id" ,'<fedora-devel-list.redhat.com>')
368 || headeris("List-Id" ,'<devel.lists.fedoraproject.org>')) {
370 store "=feddgdb","log" if body_simple()=~/\bgdb\b/i;
371 store "=feddlibunwind","log" if body_simple()=~/libunwind/i;
373 store "=bashbug","log" if headeris "List-Id" ,'<bug-bash.gnu.org>';
374 store "=zaurus","silent" if headeris "List-Id" ,'<openzaurus-users.lists.sourceforge.net>';
375 store "=zaurusann","log" if headeris "List-Id" ,'<openzaurus-announce.lists.sourceforge.net>';
376 store "=zaurusd","silent" if headeris "List-Id" ,'<openzaurus-devel.lists.sourceforge.net>';
377 store "=zaurussoft","silent" if headeris "List-Id" ,'<openzaurus-software.lists.sourceforge.net>';
378 store "=iptperl","silent" if headeris "List-Id" ,'<iptperl-general.lists.sourceforge.net>';
379 store "=www-sms","log" if headeris "List-Id" ,'<www-sms-developers.lists.sourceforge.net>';
380 store "=httpdd","log" if headeris "list-post",'<dev@httpd.apache.org>';
381 store "=imja","log" if headeris "List-Id" ,'<im-ja-devel.lists.sourceforge.net>';
382 store "=wince","log" if headeris "List-Post",'<wince@pandora.cz>';
383 store "=mysqlperl","log" if headeris "List-Id" ,'<perl.mysql.com>';
384 store "=whiteann","log" if headeris "List-Id" ,'<whitebox-announce.beau.org>';
385 store "=white","log" if headeris "List-Id" ,'<whitebox-users.beau.org>';
386 store "=centos","log" if headeris "List-Id" ,'<centos.centos.org>';
387 store "=centann","log" if headeris "List-Id" ,'<centos-announce.centos.org>';
388 store "=modperldoc","log" if headeris "List-Id" ,'<docs-dev.perl.apache.org>';
389 store "=qemud","log" if headeris "List-Id" ,'<qemu-devel.nongnu.org>';
390 store "=diamond","log" if headeris "X-Replicator-Inst",'"www.diamondcard.us"';
391 store "=soap","log" if headeris "Sender" ,'<owner-soap@DISCUSS.DEVELOP.COM>';
392 store "=nagiosd","log" if headeris "List-Id" ,'<nagios-devel.lists.sourceforge.net>';
393 store "=nagios","log" if headeris "List-Id" ,'<nagios-users.lists.sourceforge.net>';
394 store "=grub","log" if headeris "List-Id" ,'<grub-devel.gnu.org>';
395 store "=gdb","log" if headeris "Mailing-List",'contact gdb-help@sourceware.org; run by ezmlm';
396 store "=gdbia64","log" if headeris("Mailing-List",'contact gdb-help@sourceware.org; run by ezmlm')
397 && body_simple()=~/\b(?:ia64|itanium)\b/i;
398 store "=gdbpr","log" if headeris "Mailing-List",'contact gdb-prs-help@sourceware.org; run by ezmlm';
399 store "=gdbpria64","log" if headeris("Mailing-List",'contact gdb-prs-help@sourceware.org; run by ezmlm')
400 && body_simple()=~/\b(?:ia64|itanium)\b/i;
401 store "=gdbpat","log" if headeris "Mailing-List",'contact gdb-patches-help@sourceware.org; run by ezmlm';
402 store "=gdbpatia64","log" if headeris("Mailing-List",'contact gdb-patches-help@sourceware.org; run by ezmlm')
403 && body_simple()=~/\b(?:ia64|itanium)\b/i;
404 store "=gdbann","log" if headeris "Mailing-List",'contact gdb-announce-help@sourceware.org; run by ezmlm';
405 store "=gdbcvs","log" if headeris "Mailing-List",'contact gdb-cvs-help@sourceware.org; run by ezmlm';
406 store "=gdbcvsall","log" if headeris "Mailing-List",'contact src-cvs-help@sourceware.org; run by ezmlm';
407 store "=binutils","log" if headeris "Mailing-List",'contact binutils-help@sourceware.org; run by ezmlm';
408 store "=binutilsbug","log" if headeris "List-Id" ,'<bug-binutils.gnu.org>';
409 store "=buggnome","log" if headeris "From" ,'<bugzilla@gnome.org>';
410 store "=bugdesktop","log" if headeris "From" ,'<bugzilla-daemon@freedesktop.org>';
413 store "=wslog","log" if headeris("From" ,'<logwatch@jankratochvil.net>')
414 && headeris("Return-Path",'<root@lace.redhat.com>');
415 store "=rhos","log" if headeris "List-Id" ,'<os-dept-list.redhat.com>';
416 store "=rhosd","log" if headeris "List-Id" ,'<os-devel-list.redhat.com>';
417 store "=rhmemo","silent" if headeris "List-Id" ,'<memo-list.redhat.com>';
418 store "=rhann","log" if headeris "List-Id" ,'<announce-list.redhat.com>';
419 store "=rheng","log" if headeris "List-Id" ,'<eng-list.redhat.com>';
420 store "=rheurope","log" if headeris("List-Id" ,'<brno-list.redhat.com>')
421 && headeris("X-loop" ,'<europe-list@redhat.com>');
422 store "=rhbrno","log" if headeris("List-Id" ,'<brno-list.redhat.com>')
423 &&!headeris("X-loop" ,'<europe-list@redhat.com>');
424 store "=rhbrnomemo","log" if headeris "List-Id" ,'<brno-memo-list.redhat.com>';
425 store "=rhbrnopto","log" if headeris "List-Id" ,'<brno-pto-list.redhat.com>';
426 store "=rhbase","log" if headeris "List-Id" ,'<base-os-dept-list.redhat.com>';
428 store "=rhrhel","log" if headeris "X-BeenThere",'<rhel-product-org@post-office.corp.redhat.com>';
429 store "=rhrhel","log" if headeris "X-BeenThere",'<prod-dept@post-office.corp.redhat.com>';
430 store "=rheng","log" if headeris "X-BeenThere",'<eng-dept@post-office.corp.redhat.com>';
432 store "=rhtoolsteam","log" if headeris "List-Id" ,'<tools-team.redhat.com>';
434 store "=rhtools","log" if headeris "List-Id" ,'<tools.redhat.com>';
435 store "=rhosteam","log" if headeris "List-Id" ,'<tools-dept-list.redhat.com>';
436 store "=rhbug","log" if headeris "X-BeenThere",'<bugzilla@redhat.com>';
437 store "=rhgdb","log" if headeris "List-Id" ,'<tools-gdb.post-office.corp.redhat.com>';
438 store "=rhit","log" if headeris "Return-Path",'<tao@redhat.com>';
439 store "=rhcommit","log" if headeris("List-Id" ,'<cvs-commits-list.redhat.com>')
440 || headeris("X-CVS-Server",'<cvs-int.fedora.redhat.com>');
441 store "=rhcommitgdb","log" if headeris "X-CVS-Directory",qr{^rpms/gdb(?:/.*)?$};
442 store "=rhcommitgcc","log" if headeris "X-CVS-Directory",qr{^rpms/gcc(?:/.*)?$};
443 store "=rhcommitlibunwind","log" if headeris "X-CVS-Directory",qr{^rpms/libunwind(?:/.*)?$};
444 store "=rhcommitstrace","log" if headeris "X-CVS-Directory",qr{^rpms/strace(?:/.*)?$};
445 store "=rhcommitbinutils","log" if headeris "X-CVS-Directory",qr{^rpms/binutils(?:/.*)?$};
446 store "=rhcommitinsight","log" if headeris "X-CVS-Directory",qr{^rpms/insight(?:/.*)?$};
447 store "=rhcommitptrace","log" if headeris "X-CVS-Directory",qr{^tests/kernel/syscalls/ptrace(?:/.*)? };
448 store "=rhcommitgdbtest","log" if headeris "X-CVS-Directory",qr{^tests/gdb/gdb-any(?:/.*)? };
449 store "=rhbrnowiki","log" if headeris("Return-Path",'<noreply@redhat.com>')
450 && headeris("From" ,'<noreply@redhat.com>')
451 && headeris("To" ,'<noreply@redhat.com>')
452 # `\Q=?' causes: Can't modify constant item in concatenation (.) or string
453 && headeris("Subject" ,qr{^(?:\Q[Red Hat Czech] \E(?:Trivial )?Update of |=\Q?utf-8?q?=5BRed_Hat_Czech=5D_\E(?:Trivial_)?Update_of_)});
454 store "=rhts","log" if headeris "List-Id" ,'<test-auto.redhat.com>';
455 store "=rhts","log" if headeris("List-Id" ,'<rhts-dev-list.post-office.corp.redhat.com>')
456 || headeris("List-Id" ,'<beaker-dev-list.post-office.corp.redhat.com>');
457 store "=rhwiki","log" if headeris "Return-Path",'<interch@redhat.com>';
458 store "=rhinet","log" if headeris "List-id" ,'<intranet-taskforce.redhat.com>';
459 if (headeris "Return-Path",'<test-auto@redhat.com>') {
460 if (body_simple()=~/(?:jkratoch|jan.kratochvil)[@]\Qredhat.com\E/s) {
461 store "=rhtsme","log";
464 store "=rhtsbogus","log";
467 store "=rherrata","log" if $Audit->get("X-Erratatool-Component")
468 || (headeris("Return-Path",'<bugzilla@redhat.com>')
469 && headeris("Subject",qr{^Changed Errata Request }));
470 if (headeris "Subject" ,qr{^\Q[rpmdiff] INSPECTION: Erratum \E\d{4}:\d{4} .*\btest results\b}) {
471 store "=rherrata","log";
472 # `[rpmdiff] INSPECTION:' came from `root@rpmdiff3.test.redhat.com'.
473 } elsif ((headeris("To",'<jan.kratochvil@redhat.com>') || !$Audit->get("To") || $Audit->get("To") eq "undisclosed-recipients:;")
474 && headeris("Return-Path",qr{^\Qroot@\E.*[.](?:(?:lab|rhts|eng).(?:bos|boston)|z900|test|englab.brq|nay)\Q.redhat.com\E$})) {
475 store "=rhtsme","log";
477 store "=rhtsme","log" if headeris "Subject" ,qr{^\Q[Beaker Job Completion] \E};
478 store "=buggcc","log" if headeris("Return-Path",'<bugzilla-noreply@gcc.gnu.org>')
479 || headeris("Return-Path",'<gcc-bugzilla@gcc.gnu.org>');
480 store "=frysk","log" if headeris "Mailing-List",'contact frysk-help@sourceware.org; run by ezmlm';
481 store "=fryskcvs","log" if headeris "List-Id" ,'<frysk-cvs.sourceware.org>';
482 store "=bugsrc","log" if headeris "Return-Path",'<bugzilla-noreply@sourceware.org>';
483 store "=rhwc","log" if headeris "Subject" ,'Cron <jkratoch@host0> $HOME/redhat/bin/rhwc';
484 store "=dwarf","log" if headeris "List-Id" ,'<dwarf-discuss.lists.freestandards.org>';
485 store "=dwarf","log" if headeris "List-Id" ,'<dwarf-discuss-dwarfstd.org>';
486 store "=libunwind","log" if headeris "List-Id" ,'<libunwind.linux.hpl.hp.com>';
487 store "=libunwindd","log" if headeris "List-Id" ,'<libunwind-devel.nongnu.org>';
488 store "=rhsip","log" if headeris "List-Id" ,'<sip-test.redhat.com>';
489 store "=fedaccount","log" if headeris("Return-Path",'<root@redhat.com>')
490 && headeris("To", '<jkratoch@redhat.com>')
491 && headeris("From", '<accounts@fedora.redhat.com>')
492 && headeris("Subject" ,'You need to create a bugzilla account for jkratoch@redhat.com');
493 store "=straced","log" if headeris "List-Id" ,'<strace-devel.lists.sourceforge.net>';
494 if (headeris "Return-Path",'<buildsys@fedoraproject.org>') {
495 if ($Audit->subject()=~/^\d+ builds? marked for deletion$/) {
496 store "=fkojidel","log";
498 store "=fkoji","log";
501 if (headeris "Return-Path",'<buildsys@redhat.com>') {
502 if ($Audit->subject()=~/^\d+ builds? marked for deletion$/) {
503 store "=rhbrewdel","log";
505 store "=rhbrew","log";
508 store "=utrace","log" if headeris "List-Id" ,'<utrace-devel.redhat.com>';
509 store "=eud","log" if headeris "List-Id" ,'<elfutils-devel.post-office.corp.redhat.com>';
510 store "=eud","log" if headeris "List-Id" ,'<elfutils-devel.lists.fedorahosted.org>';
511 store "=dup","log" if headeris "List-Id" ,'<duplicity-talk.nongnu.org>';
512 store "=dupbug","log" if headeris "List-Id" ,'<duplicity-tracker.nongnu.org>';
513 store "=rheclipse","log" if headeris "List-Id" ,'<eclipse-list.redhat.com>';
514 store "=rhtech","log" if headeris "List-Id" ,'<tech-list.redhat.com>';
515 store "=rhgdb","log" if headeris "List-Id" ,'<gdb-local.redhat.com>';
516 store "=rhperf","log" if headeris "List-Id" ,'<perftools-list.redhat.com>';
517 store "=rhdebug","log" if headeris "List-Id" ,'<debug-list.redhat.com>';
518 store "=rhsip","log" if headeris "List-Id" ,'<sip-users.redhat.com>';
519 store "=fupdate","log" if headeris "Return-Path",'<updates@fedoraproject.org>';
520 store "=rhmedia","log" if headerhas "List-Id",'<media-monitor.redhat.com>';
521 store "=fia64","log" if headeris "List-Id" ,'<fedora-ia64-list.redhat.com>';
522 store "=archer","log" if headeris "List-Id" ,'<archer.sourceware.org>';
523 store "=archergit","log" if headeris "List-Post" ,'<archer-commits@sourceware.org>';
524 store "=flive","log" if headeris("List-Id" ,'<livecd.lists.fedoraproject.org>')
525 || headeris("List-Id" ,'<fedora-livecd-list.redhat.com>');
526 store "=fspin","log" if headeris "List-Id" ,'<spins.lists.fedoraproject.org>';
527 store "=rhstatus","log" if headeris "List-Id" ,'<rhel-people-status.post-office.corp.redhat.com>';
528 store "=rhstatusteam","log" if headeris "List-Id" ,'<rhel-team-status-list.post-office.corp.redhat.com>';
529 store "=fcrash","log" if headeris "List-Id" ,'<crash-catcher.lists.fedorahosted.org>';
530 store "=gabi","log" if headeris "List-Id" ,'<generic-abi.googlegroups.com>';
531 store "=fupload","log" if headeris("X-Fedora-Upload",qr//)
532 && headeris("Subject" ,qr/^File\s\S+\suploaded\sto\slookaside\scache\sby\s/);
533 store "=rhpkg","log" if headeris "Return-Path",'<pkwrangler-list@redhat.com>';
534 store "=gdbmail","log" if headeris "From" ,qr{^\Qdiffgdbdaymail by Jan Kratochvil <jan.kratochvil\E@\Qredhat.com>\E$};
535 store "=vpx","log" if headeris("List-Id" ,'<codec-devel.webmproject.org>')
536 || headeris("List-Id" ,'<gerrit-libvpx.review.webmproject.org>');
537 # store "=errm","bell" if $isFROM_MAILER && !did();
541 spamassassin "sa-learn --ham";
545 sub audit_sms_address
549 my $address=$obj->address();
550 if (my $alternates=muttrc_get("alternates")) {
551 return "I" if $address=~/$alternates/si;
553 my %aliases=muttrc_aliases();
554 if (my $alias=$aliases{lc $address}) {
556 s/\b(Bus)siness$/$1/i;
572 my $from=(@{$args{"from"}} ? join(",",map({ audit_sms_address($_); } @{$args{"from"}})) : "?");
577 s/(?:Re|Aw|Odp|Fw|Fwd|OT)(?:\[\d+\])?://ig;
580 s/\[\s*WAS:.*\]\s*$//i;
587 # max. 9 lines of .sig
588 s/\n-- (?:\n[^\n]*){0,9}$//gs;
589 # "Original Message"/"Puvodni zprava" etc. up to empty line
590 # "- - - Original message: - - -" is by "Lotus Notes Release 5.0.5 September 22, 2000"
591 s/(^|\n)[\s^\n]*(?:-----[\w\s]*-----|- - - Original message: - - -)[\s^\n]*(?:\n[^\n]+)*\n{2,}(?:\s*[^>\s].*$)?/\n/gs;
592 # Remove "..." lines (is it used by anyone except me?)
595 s/^(?:\s*[[:upper:]]{0,3}>)+.*$/*/gm;
596 s/(?:^|\n)(?:\*\n+)+/\n*\n/gs;
598 s/^.*\b(?:wrote|writes|napsal jste):\s*$//gm;
601 return [$from,"($subject)$body"];