Index: [Article Count Order] [Thread]

Date:  Wed, 26 Jul 2006 01:34:50 +0800 (SGT)
From:  patricko (at mark) staff.singnet.com.sg
Subject:  [coba-e:06097] Re: Revision 2: Patched vacation.pl looping on local users based on openwebmail code
To:  coba-e (at mark) bluequartz.org
Message-Id:  <Pine.LNX.4.44.0607260133450.13106-100000 (at mark) staff.singnet.com.sg>
In-Reply-To:  <20060725205833.0f22d045 (at mark) localhost.localdomain>
X-Mail-Count: 06097


oops... correction

>   After you run the new vacation.pl
>   there will be a debug file in /tmp/vacation.debug
>
>   There are HTML tags in 'from:' field (FIXME)
>   Add this line in cron will workaround the problem:
>     (qtool.pl -s 300 -e '$msg{num_delivery_attempts} >= 0' -d /var/spool/clientmqueue)




On Tue, 25 Jul 2006, patricko wrote:

> Hi Blues,
> 
> 
>   After you run the new vacation.pl
>   there will be a debug file in /tmp/vacation.debug
> 
>   There is HTML tags in from: field (FIXME)
>   this line in cron will around the problem:
>     (qtool.pl -s 300 -e '$msg{num_delivery_attempts} >= 0' -d /var/spool/clientmqueue)
> 
> 
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> 
> 20060725 204309 log daemon compared with </SPAN></B>=20
> 
> 20060725 204309 log postmaster compared with </SPAN></B>=20
> 
> 20060725 204309 log mailer-daemon compared with </SPAN></B>=20
> 
> 20060725 204309 log mailer compared with </SPAN></B>=20
> 
> 20060725 204309 log root compared with </SPAN></B>=20
> 
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> 
> 
> 
> 
> Cheers
> patrick
> 
> 
> 
> On Tue, 25 Jul 2006 20:48:49 +0800
> patricko <patricko (at mark) staff.singnet.com.sg> wrote:
> 
> > Hi blues,
> > 
> > 
> >  Used this version, ignore previous!
> > 
> >  Tested working!!!
> > 
> > 
> > >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> > 
> > --- /usr/local/sbin/vacation.pl.bak.2006.07.25  2006-07-25 20:02:25.000000000 +0800
> > +++ /usr/local/sbin/vacation.pl 2006-07-25 20:47:11.000000000 +0800
> > @@ -4,6 +4,9 @@
> >  
> >  # usage: vacation.pl [message] [from-address]
> >  
> > +# Version 1.1.1.2.b
> > +# modified by patricko (at mark) staff.singnet.com.sg 20060725
> > +# Changelog: Try 1: fixed local loop. eg: auto-reply to mailer-daemon
> >  
> >  use strict;
> >  use lib qw( /usr/sausalito/perl );
> > @@ -16,6 +19,19 @@
> >  use FileHandle;
> >  use I18nMail;
> >  
> > +### Add by patricko (at mark) staff.singnet.com.sg 20060725
> > +my @ignores = (
> > +           'daemon',
> > +           'postmaster',
> > +           'mailer-daemon',
> > +           'mailer',
> > +           'root',
> > +           );
> > +
> > +my ($opt_d)=(1);
> > +
> > +### End Add by patricko (at mark) staff.singnet.com.sg 20060725
> > +
> >  my ($message_file,$user_from) = @ARGV;
> >  
> >  my $Sendmail = Sauce::Config::bin_sendmail;
> > @@ -100,6 +116,19 @@
> >  elsif ($returnpath)  { $sendto = $returnpath;  }
> >  else                 { exit;                   }
> >  
> > +
> > +### Add by patricko (at mark) staff.singnet.com.sg 20060725
> > +
> > +   for (@ignores) {
> > +         log_debug("log $_ compared with $from\n") if ($opt_d);
> > +      if ($from =~ /^$_$/i ) {
> > +         log_debug("Message from ignored user $_, autoreply canceled\n") if ($opt_d);
> > +         exit 0;
> > +      }
> > +   }
> > +
> > +### End Add by patricko (at mark) staff.singnet.com.sg 20060725
> > +
> >  my %vacadb;
> > 
> >  
> >  my $vacadb = tie(%vacadb,'DB_File',"$Vaca_dir/.$username.db",O_RDWR|O_CREAT,0666) @@
> > -176,3 +205,27 @@ 
> >         undef $db;
> >  }
> > +
> > +### Add by patricko (at mark) staff.singnet.com.sg 20060725
> > +### From OPENWEBMAIL
> > +sub log_debug {
> > +   my @msg=@_;
> > +   my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst);
> > +   my ($today, $time);
> > +
> > +   ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime;
> > +   $today=sprintf("%4d%02d%02d", $year+1900, $mon+1, $mday);
> > +   $time=sprintf("%02d%02d%02d",$hour,$min, $sec);
> > +
> > +   open(Z, ">> /tmp/vacation.debug");
> > +
> > +   # unbuffer mode
> > +   select(Z); local $| = 1;
> > +   select(STDOUT);
> > +
> > +   print Z "$today $time ", join(" ",@msg), "\n";
> > +   close(Z);
> > +
> > +   chmod(0666, "/tmp/vacation.debug");
> > +}
> > +### End Add by patricko (at mark) staff.singnet.com.sg 20060725
> > 
> >      
> > 
> > 
> > >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > On Tue, 25 Jul 2006 20:10:27 +0800
> > patricko <patricko (at mark) staff.singnet.com.sg> wrote:
> > 
> > > Hi Blues,
> > > 
> > > 
> > >   *** Warning - for testing only ***
> > >   Included openwebmail codes into BQ code base to fix
> > >   auto-reply to local users that will cause infinite looping.
> > >  
> > >   ie: mailer-daemon, etc
> > > 
> > > 
> > > 
> > > 
> > > --- /usr/local/sbin/vacation.pl 2006-07-25 20:02:25.000000000 +0800
> > > +++ /usr/local/sbin/vacation.pl.testing.patricko 2006-07-25 20:01:44.000000000
> > > +0800 @@ -16,6 +16,18 @@
> > >  use FileHandle;
> > >  use I18nMail;
> > >  
> > > +my @ignores = (
> > > +           'daemon',
> > > +           'postmaster',
> > > +           'mailer-daemon',
> > > +           'mailer',
> > > +           'root',
> > > +           );
> > > +
> > > +my ($opt_d)=(1);
> > > +
> > > +my @aliases = ();
> > > +
> > >  my ($message_file,$user_from) = @ARGV;
> > >  
> > >  my $Sendmail = Sauce::Config::bin_sendmail;
> > > @@ -85,7 +97,7 @@
> > >  
> > >  while (<STDIN>)
> > >  {
> > > -    if    (/From:\s*(.+)/)        { $from = $1;       }
> > > +    if    (/^From:\s*(\S+)/)        { $from = $1;       }
> > >      elsif (/Reply-To:\s*(.+)/)    { $replyto = $1;    }
> > >      elsif (/Sender:\s*(.+)/)      { $sender = $1;     }
> > >      elsif (/Return-path:\s*(.+)/) { $returnpath = $1; }
> > > @@ -100,6 +112,17 @@
> > >  elsif ($returnpath)  { $sendto = $returnpath;  }
> > >  else                 { exit;                   }
> > >  
> > > +
> > > +
> > > +   for (@ignores) {
> > > +      if ($from =~ /^$_$/i ) {
> > > +         log_debug("Message from ignored user $_, autoreply canceled\n") if ($opt_d);
> > > +         exit 0;
> > > +      }
> > > +   }
> > > +
> > > +
> > > +
> > >  my %vacadb;
> > >  
> > >  my $vacadb = tie(%vacadb,'DB_File',"$Vaca_dir/.$username.db",O_RDWR|O_CREAT,0666) 
> > > @@ -176,3 +199,25 @@ 
> > >         undef $db;
> > >  }
> > > +
> > > +########### THIS FUNCTION FROM OPENWEBMAIL ###############
> > > +sub log_debug {
> > > +   my @msg=@_;
> > > +   my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst);
> > > +   my ($today, $time);
> > > +
> > > +   ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime;
> > > +   $today=sprintf("%4d%02d%02d", $year+1900, $mon+1, $mday);
> > > +   $time=sprintf("%02d%02d%02d",$hour,$min, $sec);
> > > +
> > > +   open(Z, ">> /tmp/vacation.debug");
> > > +
> > > +   # unbuffer mode
> > > +   select(Z); local $| = 1;
> > > +   select(STDOUT);
> > > +
> > > +   print Z "$today $time ", join(" ",@msg), "\n";
> > > +   close(Z);
> > > +
> > > +   chmod(0666, "/tmp/vacation.debug");
> > > +}
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > On Mon, 24 Jul 2006 21:20:42 +0200
> > > Michael Stauber <bq (at mark) solarspeed.net> wrote:
> > > 
> > > > Hi patricko,
> > > > 
> > > > > I thought of alterating the vacation.pl to write as root for .db
> > > > > But after reading up on sendmail clientmqueue, I know this is not
> > > > > possible.
> > > > >
> > > > > Why?
> > > > > The design of clientmqueue, prevented root access to .forward
> > > > > So have to drop 'chown permission on .db in /home/sites to root.'
> > > > 
> > > > At the worst change the line ...
> > > > 
> > > > O DontBlameSendmail=forwardfileingroupwritabledirpath
> > > > 
> > > > ... in /etc/mail/sendmail.cf to this:
> > > > 
> > > > O DontBlameSendmail=forwardfileingroupwritabledirpath, 
> > > > ForwardFileInUnsafeDirPath, ForwardFileInUnsafeDirPathSafe
> > > > 
> > > > (all on one line, of course)
> > > > 
> > > > It relaxes sendmails strictness on .forward files.
> > > > 
> > > > -- 
> > > > 
> > > > With best regards,
> > > > 
> > > > Michael Stauber
>