Merge from vendor branch TNF:
[pkgsrc.git] / security / f-prot-antivirus6-ms-bin / patches / patch-aa
1 $NetBSD: patch-aa,v 1.1.1.1 2009/09/22 17:41:07 taca Exp $
2
3 --- mailtools/scan-mail.pl.orig 2010-04-12 14:18:39.000000000 +0000
4 +++ mailtools/scan-mail.pl
5 @@ -81,11 +81,6 @@
6  
7  use strict;
8  
9 -# scan-mail.pl is in mailtools/scan-mail.pl, add mailtools/Anomy/bin
10 -# to @INC to find Anomy::
11 -use FindBin '$Bin';
12 -use lib "$Bin/../perl/lib";
13 -
14  use Socket;
15  use Anomy::Sanitizer ();
16  use Anomy::Sanitizer::FProt::Client ();
17 @@ -130,7 +125,7 @@ my @CONFIG_HARD = (
18  
19  my %CONFIG_SOFT = (
20         # unknown=='check next rule'
21 -       SCANMAIL_SCANLIST => ['file_list_1=.*','file_list_1_policy=unknown:unknown:drop:drop', 'file_list_1_scanner = 0:1:2:builtin/fpscand %FILENAME'],
22 +       SCANMAIL_SCANLIST => ['file_list_1=.*','file_list_1_policy=unknown:unknown:drop:unknown', 'file_list_1_scanner = 0:1:2:builtin/fpscand %FILENAME'],
23         SCANMAIL_BANLIST  => ['file_list_2 =','file_list_2_policy=drop', 'file_list_2_scanner=0'],
24         SCANMAIL_STOPLIST => ['file_list_3 =','file_list_3_policy=save', 'file_list_3_scanner=0']
25  );
26 @@ -201,6 +196,7 @@ if (my $val = $conf->{SCANMAIL_LOGLEVEL}
27  # script, this is fugly
28  #
29  
30 +my $datadir = "@VARDIR@";
31  my $debug           = 0;
32  my $verbose         = 0;
33  my $quarantine      = 0;
34 @@ -210,7 +206,7 @@ my $milter_cf       = '/etc/mail/sendmai
35  my $milter_conn     = undef;
36  my $milter_name     = 'fp-milter';
37  my $milter_pid      = undef;
38 -my $fprot_milter    = "$Bin/../mailtools/fp-milter";
39 +my $fprot_milter    = "@FPROTDIR@/fp-milter";
40  my $postfix         = 0;
41  my $postfix_ret     = undef;
42  my $server          = 0;
43 @@ -219,7 +215,8 @@ my $proxy           = 0;
44  my $proxy_addr      = '0.0.0.0:25';
45  my $smtp_addr       = '127.0.0.1:26';
46  my $backup          = 0;
47 -my $backup_location = "$Bin/../backup/";
48 +my $backup_location = "$datadir/backup/";
49 +my $pid_file       = "$datadir/run/scan-mail.pid";
50  
51  # use this for really complex configuration of
52  # scan-mail. /etc/f-prot.conf should take care of the simple things
53 @@ -441,9 +438,11 @@ if ($daemon)
54      defined(my $pid = fork)    or die "Can't fork: $!";
55      exit if $pid;
56      setsid                     or die "Can't start a new session: $!";
57 -    open PID_FILE, '>/var/run/scan-mail.pid' or die "Can't open pid file: $!";
58 +    open PID_FILE, ">$pid_file" or die "Can't open pid file: $!";
59 +    print PID_FILE "$$\n";
60      print PID_FILE $$;
61      close PID_FILE;
62 +    $SIG{'TERM'} = $SIG{'HUP'} = \&clean_up;
63      open STDERR, '>&STDOUT'    or die "Can't dup stdout: $!";
64  }
65  
66 @@ -602,6 +601,12 @@ else
67  
68  ##[ Subroutines ]##############################################################
69  
70 +sub clean_up
71 +{
72 +    unlink($pid_file);
73 +    exit(0);
74 +}
75 +
76  # proxy address, smtp address
77  sub run_smtp_proxy
78  {
79 @@ -1020,7 +1025,7 @@ sub do_scan
80          my $subdir = "/".$m.$d."/";
81          unless (-d $backup_location)
82          {
83 -            unless (mkdir($backup_location,1777))
84 +            unless (mkdir($backup_location,1777) or $!{'EEXIST'})
85              {
86                  my $err = "Unable to create backup basedir $backup_location: $!";
87                  syslog err => $err;
88 @@ -1032,7 +1037,7 @@ sub do_scan
89  
90          unless(-d $pathto)
91          {
92 -              unless (mkdir($pathto,1777))
93 +           unless (mkdir($pathto,1777) or $!{'EEXIST'})
94              {
95                  my $err = "Unable to create backup subdir $pathto: $!";
96                  syslog err => $err;
97 @@ -1080,7 +1085,16 @@ sub do_scan
98         }
99  
100          # Try to delete the directory. Will fail unless it's empty.
101 -        rmdir($pathto);
102 +       # rmdir($pathto);
103 +       #
104 +       # But it cause some race, keep the directory and remove it by
105 +       # another script using find command or execute same functionality
106 +       # in this script.
107 +       #
108 +       # #!/bin/sh
109 +       # cd $backup_location
110 +       # find . -type d -name '[0-1]*' -mtime +7 rmdir {} \; >/dev/null 2>&1
111 +       #
112      }
113      else
114      {