quarantine to a pipe ?

Mark Martinec Mark.Martinec+amavis at ijs.si
Tue Dec 20 19:12:49 CET 2011


Andreas,

> I put the content in /etc/amavis/000-custom.conf
> but it work not out of the box:
> 
> # amavisd start
> Subroutine new redefined at /etc/amavis//000-custom.conf line 5.
> Subroutine after_send redefined at /etc/amavis//000-custom.conf line 10.

This is fine, just a warning. 

> and a passing mail triggers an error:
> Dec 20 13:33:49 amavishost amavis[30538]: (30538) (!)custom after_send
> error: Undefined subroutine &Amavis::Custom::do_log called at
> /etc/amavis//000-custom.conf line 83, <GEN27> line 65.
> 
> the logfile is created, but empty.
> 
> I tried to insert
> BEGIN {
>   import Amavis::Util (qw(do_log);
> }
> but that throws other ugly errors. Understanding your perl is not easy
> sometimes :-)

You forgot a closing parenthesis.

> some mails later I also found that:
> Dec 20 13:43:28 amavishost amavis[30538]: (30538) _WARN: Use of
> uninitialized value $t_stat_dev in numeric ne (!=) at
> /etc/amavis//000-custom.conf line 28, <GEN61> line 65.

You may adjust the lines:

$stat_filename = '/var/db/opendkim/amavis-dkim-stats.log';

and:
  my $anon = 0;
  my $prefix = '';

Make sure the directory for $stat_filename exists and is writable
for uid running amavisd.

The open-dkim stats permits some anonymizations. If desired change
the $anon to 1.


This patch should fix the warning, the missing do_log and c,
and uninitialized value $t_stat_dev :

--- amavisd-custom.conf~	2011-12-20 14:29:56.000000000 +0100
+++ amavisd-custom.conf	2011-12-20 19:03:36.000000000 +0100
@@ -3,4 +3,6 @@
 use re 'taint';
 use warnings;
+no warnings 'redefine';
+
 sub new {
   my($class,$conn,$msginfo) = @_;
@@ -17,4 +19,10 @@
 use Fcntl qw(LOCK_SH LOCK_EX LOCK_UN);
 use IO::File qw(O_RDONLY O_WRONLY O_RDWR O_APPEND O_CREAT O_EXCL);
+
+BEGIN {
+  import Amavis::Conf qw(:platform :confvars c cr ca);
+  import Amavis::Util qw(do_log untaint);
+}
+
 our($stat_filename, $stat_fh, $stat_open_attempted, $stat_dev, $stat_ino);
 $stat_filename = '/var/db/opendkim/amavis-dkim-stats.log';
@@ -26,5 +34,6 @@
     my @status_list = stat($stat_filename);
     my($t_stat_dev, $t_stat_ino) = @status_list;
-    if ($t_stat_dev != $stat_dev || $t_stat_ino != $stat_ino) {
+    if (!@status_list ||
+        $t_stat_dev != $stat_dev || $t_stat_ino != $stat_ino) {
       do_log(2, "opendkim_stats: reopening file %s", $stat_filename);
       $stat_fh->close or do_log(-1,"opendkim_stats: error closing: %s", $!);
@@ -106,5 +115,5 @@
       if (!$atps_seen{$_}++) { do_log(2,"HERE ATPS: %d, %s", $atps_y, $_) }
     }
-    last  if $eval_stat =~ /^timed out\b/;
+    last  if defined $eval_stat && $eval_stat =~ /^timed out\b/;
     last;  # currently opendkim stats reflect only the first author
   }



Mark


More information about the amavis-users mailing list