Ignore previous.
The new version 1.1.1.2.c is stable
ps: debug bit is set by default,
to turn off set 'my ($opt_d)=(0)'
--- /usr/local/sbin/vacation.pl.bak.2006.07.25 2006-07-25
20:02:25.000000000 +0800
+++ /usr/local/sbin/vacation.pl 2006-07-26 02:20:21.000000000 +0800
@@ -4,6 +4,9 @@
# usage: vacation.pl [message] [from-address]
+# Version 1.1.1.2.c
+# 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 = (
+ 'mailer-daemon',
+ 'mailer',
+ 'daemon',
+ 'postmaster',
+ '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,27 @@
elsif ($returnpath) { $sendto = $returnpath; }
else { exit; }
+
+### Add by patricko (at mark) staff.singnet.com.sg 20060725
+
+ for (@ignores)
+ {
+ log_debug("log $_ compared with $sendto\n") if ($opt_d);
+ if ($sendto =~ /^$_/i )
+ {
+ log_debug("Message from ignored user $_, autoreply canceled\n") if ($opt_d);
+ exit 0;
+ }
+ }
+
+ if ($sendto !~ /@/i )
+ {
+ log_debug("Missing @ in from:, $sendto, 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 +213,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
####### Send a test mail, with auto-reply set, expect write to mailbox and
generate auto-reply #########
Jul 26 02:29:24 raqbox sendmail[4535]: k6PISaP6004535:
from=<patricko (at mark) staff.singnet.com.sg>, size=29, class=0, nrcpts=1,
msgid=<200607251829.k6PISaP6004535 (at mark) someraq.com.sg>, proto=SMTP,
daemon=MTA, relay= []
Jul 26 02:29:24 raqbox sendmail[4580]: k6PISaP6004535:
to="|/usr/local/sbin/vacation.pl
/home/.sites/58/site43/.users/125/user_1/.vacation_msg user_1",
ctladdr=<user_1 (at mark) band-it.com.sg> (1109/100), delay=00:00:13,
xdelay=00:00:00, mailer=prog, pri=60376, dsn=2.0.0, stat=Sent
Jul 26 02:29:24 raqbox sendmail[4580]: k6PISaP6004535: to=\\user_1,
delay=00:00:13, xdelay=00:00:00, mailer=local, pri=60376, dsn=2.0.0,
stat=Sent
####### MSP - clientmqueue to mqueue delivery ########
Jul 26 02:29:24 raqbox sendmail[4584]: k6PITOTo004584: from=user_1,
size=431, class=0, nrcpts=1,
msgid=<200607251829.k6PITOTo004584 (at mark) someraq.com.sg>, relay=user_1 (at mark) localhost
Jul 26 02:29:24 raqbox sendmail[4584]: k6PITOTo004584:
to=patricko (at mark) staff.singnet.com.sg, ctladdr=user_1 (1109/100),
delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30431,
relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (k6PITO8O004586
Message accepted for delivery)
####### Auto-reply from user_1 back to patricko (at mark) staff.singnet.com.sg
############
Jul 26 02:29:24 raqbox sendmail[4586]: k6PITO8O004586:
from=<user_1 (at mark) someraq.com.sg>, size=631, class=0, nrcpts=1,
msgid=<200607251829.k6PITOTo004584 (at mark) someraq.com.sg>, proto=ESMTP,
daemon=MTA, relay=localhost [127.0.0.1]
Jul 26 02:29:30 raqbox sendmail[4588]: k6PITO8O004586:
to=<patricko (at mark) staff.singnet.com.sg>, ctladdr=<user_1 (at mark) someraq.com.sg>
(1109/100), delay=00:00:06, xdelay=00:00:06, mailer=relay, pri=120631,
relay=smarthost-out.com.sg. [], dsn=2.0.0, stat=Sent (k6PITPV7017985
Message accepted for delivery)
On Wed, 26 Jul 2006 patricko (at mark) staff.singnet.com.sg wrote:
>
> 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
> >
>
>