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 store "=spam" if headeris "From",'<ceniky@oxyshop.czechcomputer.cz>';
211 for my $header (qw(To Cc)) {
212 store "=spam" if headerhas $header,'<st@jankratochvil.net>';
213 store "=spam" if headerhas $header,'<est@jankratochvil.net>';
214 store "=spam" if headerhas $header,'<uest@jankratochvil.net>';
215 store "=spam" if headerhas $header,'<kratochvil.net@jankratochvil.net>';
218 # weak detection: files with text/html w/o text/plain are usually a spam
219 my @types_linear=map({ mime_type($_); } parts_linear());
220 store "=spamhtml" if grep({ $_ eq "text/html"; } @types_linear) && !grep({ $_ eq "text/plain"; } @types_linear);
222 ### store "=spambig5" if ($_=mimehead(body_first())->mime_attr("Content-Type.charset")) && /^big5/i;
224 $store_profile=undef();
227 for ($Audit->get("Received")) {
228 $nonrh=1 if /\sby\s+mx\d+\Q.redhat.com\E\s/s;
230 $nonrh=1 if !headeris("From",qr/[@]redhat.com/i);
233 # Internal RH mails are never spam.
235 # It is too expensive to scan the huge =caperr announcements by spamassassin(1).
236 return if headeris("From",qr/^captive-[a-z]*@/);
237 # Do not local $store_file as it is our-imported
238 $store_profile="log";
240 ### store "=spam".";virus=$_" if $_=clamscan();
241 store "=spam".";spamassassin".($_ eq 1 ? "" : "=$_") if $_=spamassassin();
243 ### store "=spam".";$_" if $_=dnsbl '.relays.ordb.org.' ,1; # all hosts
245 store "=spam".";$_" if $_=dnsbl '.blackholes.mail-abuse.org.' ,1; # all hosts
246 # we don't check all hosts as they can be "dialup" category, FIXME: check for it
247 # store "=spam".";$_" if $_=dnsbl '.blackholes.five-ten-sg.com.',0; # just first
248 # I don't send viruses but viruses propagate mails of mine
250 store "=spam".";ravmd" if headeris "X-Mailer",'ravmd/8.3.2';
251 store "=spam".';short@ucw.cz+MAILER' if $isFROM_MAILER && headeris("To",'<short@ucw.cz>');
252 if (!is_multipart()) {
253 local $_=mimebody(body_first());
254 my %sites=map(($_=>1),qw(
255 brandenburg.rz.fhtw-berlin.de
258 www.aufenthaltstitel.de
260 www.deutschlandchronik.de
262 www.leverkusener-aufbruch.com
264 www.mjoelnirsseite.de
274 while (m{http://([^/]+)/}g) {
275 do { $found=1; next; } if $sites{$1};
279 $found=1 if /^\s*Lese selbst:\n/s;
280 store "=spam".';german-news' if $found;
283 $store_profile=undef();
286 store "=err","bell" and return if headerhas \&Received_for,'<short+err@>';
287 store "=host1","bell" and return if headerhas \&Received_for,qr/\Qjan.kratochvil+\E\S*\Q.at.host1.dyn.jankratochvil.net\E@/;
289 # if (headeris "X-Calendar-Attachment",qr/./) {
290 # store "=zimbra","btw";
291 # my $headless=$::Message;
292 # $headless=~s{^From .*?\n}{} or cluck "No From header for Zimbra";
295 # open CHILD,q{|sendmail jkratoch@calendar.corp.redhat.com}
296 # or cluck "Cannot forward to Zimbra";
297 # print CHILD $headless or cluck;
298 # close CHILD or cluck;
303 store "=mozillabug","log" if headeris "From" ,'<bugzilla-daemon@mozilla.org>';
304 store "=9ku","log" if headeris "List-Id" ,'<9000.listman.net>';
305 store "=9kd","log" if headeris "Sender" ,'<owner-9000-developers@geekstuff.co.uk>';
306 store "=spong","log" if headeris "List-Id" ,'<spong-users.lists.sourceforge.net>';
307 store "=gtkd","silent" if headeris "List-Id" ,'<gtk-devel-list.gnome.org>';
308 store "=gnomevfs","log" if headeris "List-Id" ,'<gnome-vfs-list.gnome.org>';
309 store "=hw","log" if headeris "List-Post",'<hw-news@list.gin.cz>';
310 store "=gnokii","log" if headeris "List-Id" ,'<gnokii-users.mail.freesoftware.fsf.org>';
311 store "=winelic","silent" if headeris "List-Id" ,'<wine-license.winehq.org>';
312 store "=wined","silent" if headeris "List-Id" ,'<wine-devel.winehq.org>';
313 store "=winepat","silent" if headeris "List-Id" ,'<wine-patches.winehq.org>';
314 store "=winecvs","silent" if headeris "List-Id" ,'<wine-cvs.winehq.org>';
315 store "=wineann","silent" if headeris "List-Id" ,'<wine-announce.winehq.org>';
316 store "=wineconf","silent" if headeris "List-Id" ,'<wineconf.winehq.org>';
317 store "=ros","silent" if headeris "List-Id" ,'<ros-general.reactos.com>';
318 store "=roskernel","silent" if headeris "List-Id" ,'<ros-kernel.reactos.com>';
319 store "=rosd","silent" if headeris "List-Id" ,'<ros-dev.reactos.com>';
320 store "=roscvs","silent" if headeris "List-Id" ,'<ros-cvs.reactos.com>';
321 store "=rossvn","silent" if headeris "List-Id" ,'<ros-svn.reactos.com>';
322 store "=rosbug","silent" if headeris "Reply-To" ,'<scarab@reactos.wox.org>';
323 store "=fsd","silent" if headeris "X-Mailing-List",'<linux-fsdevel@vger.kernel.org>';
324 store "=kernel","silent" if headeris "X-Mailing-List",'<linux-kernel@vger.kernel.org>';
325 store "=kernelnet","silent" if headeris "X-Mailing-List",'<linux-net@vger.kernel.org>';
326 store "=ia64","silent" if headeris "X-Mailing-List",'<linux-ia64@vger.kernel.org>';
327 store "=linuxjap","silent" if headeris "X-Mailing-List",'<linux-japanese@vger.kernel.org>';
328 store "=kernelann","silent" if headeris "X-Mailing-List",'<linux-kernel-announce@vger.kernel.org>';
329 store "=sparse","silent" if headeris "X-Mailing-List",'<linux-sparse@vger.kernel.org>';
330 store "=smp","silent" if headeris "X-Mailing-List",'<linux-smp@vger.kernel.org>';
331 store "=tacacs","silent" if headeris "Sender" ,'<tacplus-l@disaster.com>';
332 store "=tacacs","silent" if headeris "Sender" ,'<owner-tacplus-l@disaster.com>';
333 store "=tacacs","silent" if headeris "List-Id" ,'<devel.lists.tacplus.org>';
334 store "=pm","log" if headeris "List-Id" ,'<prague-pm.pm.org>';
335 store "=radary","log" if headeris "Reply-To" ,'<pha@radary.cz>';
336 store "=dnet","log" if headeris "Sender" ,'<@lists.distributed.net>';
337 store "=netinfo","log" if headeris "Sender" ,'<owner-netinfo-l@vol.cz>';
338 store "=slashdot","bell" if headeris "From" ,'<slashdot@slashdot.org>';
339 store "=freshmeat","bell" if headeris "From" ,'<noreply@freshmeat.net>';
340 store "=sourceforge","bell" if headeris "From" ,'<noreply@sourceforge.net>';
341 store "=gsmperlcvs","silent" if headeris("From" ,'<johan@intra.tektonica.com>')
342 && $Audit->subject()=~/^'.*' has been updated!$/;
343 store "=libtoold","silent" if headeris "List-Id" ,'<libtool.gnu.org>';
344 store "=libtoolpat","silent" if headeris "List-Id" ,'<libtool-patches.gnu.org>';
345 store "=automake","silent" if headeris "List-Id" ,'<automake.gnu.org>';
346 store "=autoconf","log" if headeris "List-Id" ,'<autoconf.gnu.org>';
347 store "=autoconfpat","log" if headeris "List-Id" ,'<autoconf-patches.gnu.org>';
348 store "=hurd","log" if headeris "List-Id" ,'<l4-hurd.gnu.org>';
349 store "=gccbug","silent" if headeris "List-Post",'<gcc-bugs@gcc.gnu.org>';
350 store "=gccann","log" if headeris "List-Post",'<gcc-announce@gcc.gnu.org>';
351 store "=gcc","silent" if headeris "List-Post",'<gcc@gcc.gnu.org>';
352 store "=gccpat","silent" if headeris "List-Post",'<gcc-patches@gcc.gnu.org>';
353 store "=ntfsann","silent" if headeris "List-Id" ,'<linux-ntfs-announce.lists.sourceforge.net>';
354 store "=ntfsd","silent" if headeris "List-Id" ,'<linux-ntfs-dev.lists.sourceforge.net>';
355 store "=orbit","silent" if headeris "List-Id" ,'<orbit-list.gnome.org>';
356 store "=kannel","log" if headeris "List-Id" ,'<users.kannel.org>';
357 store "=kanneld","log" if headeris "List-Id" ,'<devel.kannel.org>';
358 store "=mailmand","silent" if headeris "List-Id" ,'<mailman-developers.python.org>';
359 store "=asterisk-perl","log" if headeris "List-Post",'<asterisk-perl@lists.gnuinter.net>';
360 store "=i4l","silent" if headeris "List-Id" ,'<isdn4linux.listserv.isdn4linux.de>';
361 store "=glibc","silent" if headeris "List-Post",'<libc-alpha@sourceware.org>';
362 store "=fedann","bell" if headeris("List-Id" ,'<announce.lists.fedoraproject.org>')
363 || headeris("List-Id" ,'<fedora-announce-list.redhat.com>');
364 store "=fedpkg","bell" if headeris "List-Id" ,'<fedora-package-announce.redhat.com>';
365 store "=federrata","log" if headeris "Return-Path",'<root@app5.fedora.phx.redhat.com>';
366 store "=fedtools","log" if headeris "List-Id" ,'<fedora-tools-list.post-office.corp.redhat.com>';
367 store "=freleng","log" if headeris "List-Id" ,'<rel-eng.lists.fedoraproject.org>';
368 store "=ftest","log" if headeris "List-Id" ,'<test.lists.fedoraproject.org>';
369 if (headeris("List-Id" ,'<fedora-devel-list.redhat.com>')
370 || headeris("List-Id" ,'<devel.lists.fedoraproject.org>')) {
372 store "=feddgdb","log" if body_simple()=~/\bgdb\b/i;
373 store "=feddlibunwind","log" if body_simple()=~/libunwind/i;
375 store "=bashbug","log" if headeris "List-Id" ,'<bug-bash.gnu.org>';
376 store "=zaurus","silent" if headeris "List-Id" ,'<openzaurus-users.lists.sourceforge.net>';
377 store "=zaurusann","log" if headeris "List-Id" ,'<openzaurus-announce.lists.sourceforge.net>';
378 store "=zaurusd","silent" if headeris "List-Id" ,'<openzaurus-devel.lists.sourceforge.net>';
379 store "=zaurussoft","silent" if headeris "List-Id" ,'<openzaurus-software.lists.sourceforge.net>';
380 store "=iptperl","silent" if headeris "List-Id" ,'<iptperl-general.lists.sourceforge.net>';
381 store "=www-sms","log" if headeris "List-Id" ,'<www-sms-developers.lists.sourceforge.net>';
382 store "=httpdd","log" if headeris "list-post",'<dev@httpd.apache.org>';
383 store "=imja","log" if headeris "List-Id" ,'<im-ja-devel.lists.sourceforge.net>';
384 store "=wince","log" if headeris "List-Post",'<wince@pandora.cz>';
385 store "=mysqlperl","log" if headeris "List-Id" ,'<perl.mysql.com>';
386 store "=whiteann","log" if headeris "List-Id" ,'<whitebox-announce.beau.org>';
387 store "=white","log" if headeris "List-Id" ,'<whitebox-users.beau.org>';
388 store "=centos","log" if headeris "List-Id" ,'<centos.centos.org>';
389 store "=centann","log" if headeris "List-Id" ,'<centos-announce.centos.org>';
390 store "=modperldoc","log" if headeris "List-Id" ,'<docs-dev.perl.apache.org>';
391 store "=qemud","log" if headeris "List-Id" ,'<qemu-devel.nongnu.org>';
392 store "=diamond","log" if headeris "X-Replicator-Inst",'"www.diamondcard.us"';
393 store "=soap","log" if headeris "Sender" ,'<owner-soap@DISCUSS.DEVELOP.COM>';
394 store "=nagiosd","log" if headeris "List-Id" ,'<nagios-devel.lists.sourceforge.net>';
395 store "=nagios","log" if headeris "List-Id" ,'<nagios-users.lists.sourceforge.net>';
396 store "=grub","log" if headeris "List-Id" ,'<grub-devel.gnu.org>';
397 store "=gdb","log" if headeris "Mailing-List",'contact gdb-help@sourceware.org; run by ezmlm';
398 store "=gdbia64","log" if headeris("Mailing-List",'contact gdb-help@sourceware.org; run by ezmlm')
399 && body_simple()=~/\b(?:ia64|itanium)\b/i;
400 store "=gdbpr","log" if headeris "Mailing-List",'contact gdb-prs-help@sourceware.org; run by ezmlm';
401 store "=gdbpria64","log" if headeris("Mailing-List",'contact gdb-prs-help@sourceware.org; run by ezmlm')
402 && body_simple()=~/\b(?:ia64|itanium)\b/i;
403 store "=gdbpat","log" if headeris "Mailing-List",'contact gdb-patches-help@sourceware.org; run by ezmlm';
404 store "=gdbpatia64","log" if headeris("Mailing-List",'contact gdb-patches-help@sourceware.org; run by ezmlm')
405 && body_simple()=~/\b(?:ia64|itanium)\b/i;
406 store "=gdbann","log" if headeris "Mailing-List",'contact gdb-announce-help@sourceware.org; run by ezmlm';
407 store "=gdbcvs","log" if headeris "Mailing-List",'contact gdb-cvs-help@sourceware.org; run by ezmlm';
408 store "=gdbcvsall","log" if headeris "Mailing-List",'contact src-cvs-help@sourceware.org; run by ezmlm';
409 store "=binutils","log" if headeris "Mailing-List",'contact binutils-help@sourceware.org; run by ezmlm';
410 store "=binutilsbug","log" if headeris "List-Id" ,'<bug-binutils.gnu.org>';
411 store "=buggnome","log" if headeris "From" ,'<bugzilla@gnome.org>';
412 store "=bugdesktop","log" if headeris "From" ,'<bugzilla-daemon@freedesktop.org>';
415 store "=wslog","log" if headeris("From" ,'<logwatch@jankratochvil.net>')
416 && headeris("Return-Path",'<root@lace.redhat.com>');
417 store "=rhos","log" if headeris "List-Id" ,'<os-dept-list.redhat.com>';
418 store "=rhosd","log" if headeris "List-Id" ,'<os-devel-list.redhat.com>';
419 store "=rhmemo","silent" if headeris "List-Id" ,'<memo-list.redhat.com>';
420 store "=rhann","log" if headeris "List-Id" ,'<announce-list.redhat.com>';
421 store "=rheng","log" if headeris "List-Id" ,'<eng-list.redhat.com>';
422 store "=rheurope","log" if headeris("List-Id" ,'<brno-list.redhat.com>')
423 && headeris("X-loop" ,'<europe-list@redhat.com>');
424 store "=rhbrno","log" if headeris("List-Id" ,'<brno-list.redhat.com>')
425 &&!headeris("X-loop" ,'<europe-list@redhat.com>');
426 store "=rhbrnomemo","log" if headeris "List-Id" ,'<brno-memo-list.redhat.com>';
427 store "=rhbrnopto","log" if headeris "List-Id" ,'<brno-pto-list.redhat.com>';
428 store "=rhbase","log" if headeris "List-Id" ,'<base-os-dept-list.redhat.com>';
430 store "=rhrhel","log" if headeris "X-BeenThere",'<rhel-product-org@post-office.corp.redhat.com>';
431 store "=rhrhel","log" if headeris "X-BeenThere",'<prod-dept@post-office.corp.redhat.com>';
432 store "=rheng","log" if headeris "X-BeenThere",'<eng-dept@post-office.corp.redhat.com>';
434 store "=rhtoolsteam","log" if headeris "List-Id" ,'<tools-team.redhat.com>';
436 store "=rhtools","log" if headeris "List-Id" ,'<tools.redhat.com>';
437 store "=rhosteam","log" if headeris "List-Id" ,'<tools-dept-list.redhat.com>';
438 store "=rhbug","log" if headeris "X-BeenThere",'<bugzilla@redhat.com>';
439 store "=rhgdb","log" if headeris "List-Id" ,'<tools-gdb.post-office.corp.redhat.com>';
440 store "=rhit","log" if headeris "Return-Path",'<tao@redhat.com>';
441 if ($Audit->subject()!~/^Broken dependencies/) {
442 store "=rhcommit","log" if headeris("List-Id" ,'<cvs-commits-list.redhat.com>')
443 || headeris("X-CVS-Server",'<cvs-int.fedora.redhat.com>');
444 store "=rhcommitgdb","log" if headeris("X-CVS-Directory",qr{^rpms/gdb(?:/.*)?$})
445 || headeris("Delivered-To",'<gdb-owner@fedoraproject.org>');
446 store "=rhcommitgcc","log" if headeris("X-CVS-Directory",qr{^rpms/gcc(?:/.*)?$})
447 || headeris("Delivered-To",'<gcc-owner@fedoraproject.org>');
448 store "=rhcommitlibunwind","log" if headeris "X-CVS-Directory",qr{^rpms/libunwind(?:/.*)?$};
449 store "=rhcommitstrace","log" if headeris "X-CVS-Directory",qr{^rpms/strace(?:/.*)?$};
450 store "=rhcommitbinutils","log" if headeris "X-CVS-Directory",qr{^rpms/binutils(?:/.*)?$};
451 store "=rhcommitinsight","log" if headeris "X-CVS-Directory",qr{^rpms/insight(?:/.*)?$};
452 store "=rhcommitptrace","log" if headeris "X-CVS-Directory",qr{^tests/kernel/syscalls/ptrace(?:/.*)? };
453 store "=rhcommitgdbtest","log" if headeris "X-CVS-Directory",qr{^tests/gdb/gdb-any(?:/.*)? };
455 store "=rhbrnowiki","log" if headeris("Return-Path",'<noreply@redhat.com>')
456 && headeris("From" ,'<noreply@redhat.com>')
457 && headeris("To" ,'<noreply@redhat.com>')
458 # `\Q=?' causes: Can't modify constant item in concatenation (.) or string
459 && headeris("Subject" ,qr{^(?:\Q[Red Hat Czech] \E(?:Trivial )?Update of |=\Q?utf-8?q?=5BRed_Hat_Czech=5D_\E(?:Trivial_)?Update_of_)});
460 store "=rhts","log" if headeris "List-Id" ,'<test-auto.redhat.com>';
461 store "=rhts","log" if headeris("List-Id" ,'<rhts-dev-list.post-office.corp.redhat.com>')
462 || headeris("List-Id" ,'<beaker-dev-list.post-office.corp.redhat.com>');
463 store "=rhwiki","log" if headeris "Return-Path",'<interch@redhat.com>';
464 store "=rhinet","log" if headeris "List-id" ,'<intranet-taskforce.redhat.com>';
465 if (headeris "Return-Path",'<test-auto@redhat.com>') {
466 if (body_simple()=~/(?:jkratoch|jan.kratochvil)[@]\Qredhat.com\E/s) {
467 store "=rhtsme","log";
470 store "=rhtsbogus","log";
473 store "=rherrata","log" if $Audit->get("X-Erratatool-Component")
474 || (headeris("Return-Path",'<bugzilla@redhat.com>')
475 && headeris("Subject",qr{^Changed Errata Request }));
476 if (headeris "Subject" ,qr{^\Q[rpmdiff] INSPECTION: Erratum \E\d{4}:\d{4,5} .*\btest results\b}) {
477 store "=rherrata","log";
478 # `[rpmdiff] INSPECTION:' came from `root@rpmdiff3.test.redhat.com'.
479 } elsif ((headeris("To",'<jan.kratochvil@redhat.com>') || !$Audit->get("To") || $Audit->get("To") eq "undisclosed-recipients:;")
480 && headeris("Return-Path",qr{^\Qroot@\E.*[.](?:(?:lab|rhts|eng)[.](?:bos|boston)|z900|test|englab[.]brq|eng.brq|nay)\Q.redhat.com\E$})) {
481 store "=rhtsme","log";
483 store "=rhtsme","log" if headeris "Subject" ,qr{^\Q[Beaker Job Completion] \E};
484 store "=buggcc","log" if headeris("Return-Path",'<bugzilla-noreply@gcc.gnu.org>')
485 || headeris("Return-Path",'<gcc-bugzilla@gcc.gnu.org>');
486 store "=bugsav","log" if headeris "Return-Path",'<www-data@savannah.gnu.org>';
487 store "=frysk","log" if headeris "Mailing-List",'contact frysk-help@sourceware.org; run by ezmlm';
488 store "=fryskcvs","log" if headeris "List-Id" ,'<frysk-cvs.sourceware.org>';
489 store "=bugsrc","log" if headeris("Return-Path",'<bugzilla-noreply@sourceware.org>')
490 || headeris("Return-Path",'<sourceware-bugzilla@sourceware.org>');
491 store "=rhwc","log" if headeris "Subject" ,'Cron <jkratoch@host0> $HOME/redhat/bin/rhwc';
492 store "=dwarf","log" if headeris "List-Id" ,'<dwarf-discuss.lists.freestandards.org>';
493 store "=dwarf","log" if headeris "List-Id" ,'<dwarf-discuss-dwarfstd.org>';
494 store "=libunwind","log" if headeris "List-Id" ,'<libunwind.linux.hpl.hp.com>';
495 store "=libunwindd","log" if headeris "List-Id" ,'<libunwind-devel.nongnu.org>';
496 store "=rhsip","log" if headeris "List-Id" ,'<sip-test.redhat.com>';
497 store "=fedaccount","log" if headeris("Return-Path",'<root@redhat.com>')
498 && headeris("To", '<jkratoch@redhat.com>')
499 && headeris("From", '<accounts@fedora.redhat.com>')
500 && headeris("Subject" ,'You need to create a bugzilla account for jkratoch@redhat.com');
501 store "=straced","log" if headeris "List-Id" ,'<strace-devel.lists.sourceforge.net>';
502 if (headeris "Return-Path",'<buildsys@fedoraproject.org>') {
503 if ($Audit->subject()=~/^\d+ builds? marked for deletion$/) {
504 store "=fkojidel","log";
505 } elsif ($Audit->subject()=~/^Broken dependencies: /) {
506 store "=fkojidep","log";
507 } elsif ($Audit->from()=~/^S390 Koji Build System /) {
508 store "=fkojis390","log";
510 store "=fkoji","log";
513 store "=fkojidep","log" if (headeris("From" ,'<mschwendt@gmail.com>')
514 && $Audit->subject()=~/^Broken dependencies/);
515 store "=fkojiarm","log" if headeris "From" ,'<buildsys@arm.koji.fedoraproject.org>';
516 if (headeris "Return-Path",'<buildsys@redhat.com>') {
517 if ($Audit->subject()=~/^\d+ builds? marked for deletion$/) {
518 store "=rhbrewdel","log";
520 store "=rhbrew","log";
523 store "=utrace","log" if headeris "List-Id" ,'<utrace-devel.redhat.com>';
524 store "=eud","log" if headeris "List-Id" ,'<elfutils-devel.post-office.corp.redhat.com>';
525 store "=eud","log" if headeris "List-Id" ,'<elfutils-devel.lists.fedorahosted.org>';
526 store "=dup","log" if headeris "List-Id" ,'<duplicity-talk.nongnu.org>';
527 store "=dupbug","log" if headeris "List-Id" ,'<duplicity-tracker.nongnu.org>';
528 store "=rheclipse","log" if headeris "List-Id" ,'<eclipse-list.redhat.com>';
529 store "=rhtech","log" if headeris "List-Id" ,'<tech-list.redhat.com>';
530 store "=rhgdb","log" if headeris "List-Id" ,'<gdb-local.redhat.com>';
531 store "=rhperf","log" if headeris "List-Id" ,'<perftools-list.redhat.com>';
532 store "=rhdebug","log" if headeris "List-Id" ,'<debug-list.redhat.com>';
533 store "=rhsip","log" if headeris "List-Id" ,'<sip-users.redhat.com>';
534 store "=fupdate","log" if headeris "Return-Path",'<updates@fedoraproject.org>';
535 store "=rhmedia","log" if headerhas "List-Id",'<media-monitor.redhat.com>';
536 store "=fia64","log" if headeris "List-Id" ,'<fedora-ia64-list.redhat.com>';
537 store "=archer","log" if headeris "List-Id" ,'<archer.sourceware.org>';
538 store "=archergit","log" if headeris "List-Post" ,'<archer-commits@sourceware.org>';
539 store "=flive","log" if headeris("List-Id" ,'<livecd.lists.fedoraproject.org>')
540 || headeris("List-Id" ,'<fedora-livecd-list.redhat.com>');
541 store "=fspin","log" if headeris "List-Id" ,'<spins.lists.fedoraproject.org>';
542 store "=rhstatus","log" if headeris "List-Id" ,'<rhel-people-status.post-office.corp.redhat.com>';
543 store "=rhstatusteam","log" if headeris "List-Id" ,'<rhel-team-status-list.post-office.corp.redhat.com>';
544 store "=fcrash","log" if headeris "List-Id" ,'<crash-catcher.lists.fedorahosted.org>';
545 store "=gabi","log" if headeris "List-Id" ,'<generic-abi.googlegroups.com>';
546 store "=fupload","log" if headeris("X-Fedora-Upload",qr//)
547 && headeris("Subject" ,qr/^File\s\S+\suploaded\sto\slookaside\scache\sby\s/);
548 store "=rhpkg","log" if headeris "Return-Path",'<pkwrangler-list@redhat.com>';
549 store "=gdbmail","log" if headeris "From" ,qr{^\Qdiffgdbdaymail by Jan Kratochvil <jan.kratochvil\E@\Qredhat.com>\E$};
550 store "=vpx","log" if headeris("List-Id" ,'<codec-devel.webmproject.org>')
551 || headeris("List-Id" ,'<gerrit-libvpx.review.webmproject.org>');
552 # store "=errm","bell" if $isFROM_MAILER && !did();
556 spamassassin "sa-learn --ham";
560 sub audit_sms_address
564 my $address=$obj->address();
565 if (my $alternates=muttrc_get("alternates")) {
566 return "I" if $address=~/$alternates/si;
568 my %aliases=muttrc_aliases();
569 if (my $alias=$aliases{lc $address}) {
571 s/\b(Bus)siness$/$1/i;
587 my $from=(@{$args{"from"}} ? join(",",map({ audit_sms_address($_); } @{$args{"from"}})) : "?");
592 s/(?:Re|Aw|Odp|Fw|Fwd|OT)(?:\[\d+\])?://ig;
595 s/\[\s*WAS:.*\]\s*$//i;
602 # max. 9 lines of .sig
603 s/\n-- (?:\n[^\n]*){0,9}$//gs;
604 # "Original Message"/"Puvodni zprava" etc. up to empty line
605 # "- - - Original message: - - -" is by "Lotus Notes Release 5.0.5 September 22, 2000"
606 s/(^|\n)[\s^\n]*(?:-----[\w\s]*-----|- - - Original message: - - -)[\s^\n]*(?:\n[^\n]+)*\n{2,}(?:\s*[^>\s].*$)?/\n/gs;
607 # Remove "..." lines (is it used by anyone except me?)
610 s/^(?:\s*[[:upper:]]{0,3}>)+.*$/*/gm;
611 s/(?:^|\n)(?:\*\n+)+/\n*\n/gs;
613 s/^.*\b(?:wrote|writes|napsal jste):\s*$//gm;
616 return [$from,"($subject)$body"];