Thiago Henrique,

> > The problem occurs when the Amavis execute /usr/bin/uptime to validate
> > the pid file. It tries access the /proc of the uptime, but the user
> > "amavis" don't have permission to this.
> >
> > I guess this is a noted error, but it's hidden in /etc/init.d/amavisd:
> > [...] Anyway, I don't know how I solve this :(

See if the patch below provides a workaround
(the patch is larger then necessary due to indentation change):


--- amavisd.orig        2008-12-15 01:50:09.000000000 +0100
+++ amavisd     2009-02-17 20:38:01.000000000 +0100
@@ -13472,31 +13472,38 @@
         { @progs = ('/sbin/sysctl','sysctl'); @prog_args = 'kern.boottime' }
       my($prog) = find_program_path(\...@progs, [split(/:/,$path,-1)] );
-      if (!defined($prog)) { do_log(1,'No programs: %s',join(", ",@progs)) }
-      else {  # obtain system uptime
-        my($proc_fh,$uppid) = run_command(undef,'/dev/null',$prog,@prog_args);
-        for ($! = 0; defined($ln=$proc_fh->getline); $! = 0) {
-          local($1,$2,$3,$4); chomp($ln);
-          if (defined $uptime) {}
-          elsif ($ln =~ /{[^}]*\bsec\s*=\s*(\d+)[^}]*}/) { $uptime = $now-$1 }
-          # amazing how broken reports from uptime(1) soon after boot can be!
-          elsif ($ln =~ /\b up \s+ (?: (\d{1,4}) \s* days? )? [,\s]*
-                         (\d{1,2}) : (\d{1,2}) (?: : (\d{1,2}))? (?! \d ) /ix
-              || $ln =~ /\b up (?:   \s*  \b (\d{1,4}) \s* days? )?
-                               (?: [,\s]* \b (\d{1,2}) \s* hrs?  )?
-                               (?: [,\s]* \b (\d{1,2}) \s* mins? )?
-                               (?: [,\s]* \b (\d{1,2}) \s* secs? )? /ix )
-            { $uptime = (($1*24 + $2)*60 + $3)*60 + $4 }
-          elsif ($ln =~ /\b (\d{1,2}) \s* secs?/ix) { $uptime = $1 }  # OpenBSD
-          $uptime_fmt = format_time_interval($uptime);
-          do_log(5,"system uptime %s: %s",$uptime_fmt,$ln);
-        }
-        defined $ln || $!==0 || $!==EAGAIN  or do_log(1,"Read uptime: %s",$!);
-        do_log(-1,"unexpected(uptime): %s",$!)  if !defined($ln) && $!==EAGAIN;
-        my($err)=0; $proc_fh->close or $err = $!;
-        my($child_stat) = defined $uppid && waitpid($uppid,0) > 0 ? $? : undef;
-        undef $proc_fh; undef $uppid;
-        proc_status_ok($child_stat,$err)
-          or do_log(1,'Error running %s: %s',
-                      $prog, exit_status_str($child_stat,$err));
+      if (!defined($prog)) {
+        do_log(1,'No programs: %s',join(", ",@progs));
+      } else {  # obtain system uptime
+        my($proc_fh,$uppid);
+        eval {
+          ($proc_fh,$uppid) = run_command(undef,'/dev/null',$prog,@prog_args);
+          for ($! = 0; defined($ln=$proc_fh->getline); $! = 0) {
+            local($1,$2,$3,$4); chomp($ln);
+            if (defined $uptime) {}
+            elsif ($ln =~ /{[^}]*\bsec\s*=\s*(\d+)[^}]*}/) { $uptime= $now-$1 }
+            # amazing how broken reports from uptime(1) soon after boot can be!
+            elsif ($ln =~ /\b up \s+ (?: (\d{1,4}) \s* days? )? [,\s]*
+                           (\d{1,2}) : (\d{1,2}) (?: : (\d{1,2}))? (?! \d ) /ix
+                || $ln =~ /\b up (?:   \s*  \b (\d{1,4}) \s* days? )?
+                                 (?: [,\s]* \b (\d{1,2}) \s* hrs?  )?
+                                 (?: [,\s]* \b (\d{1,2}) \s* mins? )?
+                                 (?: [,\s]* \b (\d{1,2}) \s* secs? )? /ix )
+              { $uptime = (($1*24 + $2)*60 + $3)*60 + $4 }
+            elsif ($ln =~ /\b (\d{1,2}) \s* secs?/ix) { $uptime = $1 } #OpenBSD
+            $uptime_fmt = format_time_interval($uptime);
+            do_log(5,"system uptime %s: %s", $uptime_fmt,$ln);
+          }
+          defined $ln || $!==0  or die "Reading uptime: $!";
+          my($err)=0; $proc_fh->close or $err = $!;
+          my($child_stat) = defined $uppid && waitpid($uppid,0)>0 ? $? : undef;
+          undef $proc_fh; undef $uppid;
+          proc_status_ok($child_stat,$err) or die "Error running $prog: " .
+                                      exit_status_str($child_stat,$err) . "\n";
+        } or do {
+          my($eval_stat) = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+          do_log(1,"uptime: %s", $eval_stat);
+        };
+        if (defined $proc_fh) { $proc_fh->close }  # ignoring status
+        if (defined $uppid) { waitpid($uppid,0) }  # ignoring status
       }
       if (!defined($uptime)) {



Mark

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
AMaViS-user mailing list
AMaViS-user@lists.sourceforge.net 
https://lists.sourceforge.net/lists/listinfo/amavis-user 
 AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3 
 AMaViS-HowTos:http://www.amavis.org/howto/ 

Reply via email to