From 40b8c19e2779d429dad30b3e8efe3ddce8bf15e3 Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Wed, 9 Jul 2008 12:14:06 +0000 Subject: [PATCH] patch from Fabio Bonelli; as per https://sourceforge.net/tracker/?func=detail&atid=937966&aid=2014010&group_id=191583 - thank you! git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@401 a1433add-5e2c-0410-b055-b7f2511e0802 --- VIRTUAL_VACATION/vacation.pl | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/VIRTUAL_VACATION/vacation.pl b/VIRTUAL_VACATION/vacation.pl index 4fa2e363..723c9e3d 100644 --- a/VIRTUAL_VACATION/vacation.pl +++ b/VIRTUAL_VACATION/vacation.pl @@ -36,6 +36,9 @@ # 2007-08-20 Martin Ambroz # Added initial Unicode support # +# 2008-05-09 Fabio Bonelli +# Properly handle failed queries to vacation_notification. +# Fixed log reporting. # # Requirements: # You need to have the DBD::Pg or DBD::mysql perl-module installed. @@ -151,7 +154,7 @@ sub already_notified { my $query = qq{INSERT into vacation_notification (on_vacation,notified) values (?,?)}; my $stm = $dbh->prepare($query); if (!$stm) { - do_log('',$to,$from,'','',"Could not prepare query $query"); + do_log('',$to,$from,'',"Could not prepare query $query"); return 1; } $stm->{'PrintError'} = 0; @@ -161,8 +164,11 @@ sub already_notified { # Violation of a primay key constraint may happen here, and that's # fine. All other error conditions are not fine, however. - if (!$e =~ /_pkey/) { - do_log('',$to,$from,'','',"Unexpected error: '$e' from query '$query'"); + if ($e !~ /_pkey/) { + do_log('',$to,$from,'',"Unexpected error: '$e' from query '$query'"); + + # Let's play safe and notify anyway + return 0; } return 1; } @@ -176,7 +182,7 @@ sub do_log { open (SYSLOG, "|/usr/bin/logger -p mail.info -t Vacation") or die ("Unable to open logger"); binmode(SYSLOG, ':utf8'); if ($logmessage) { - printf SYSLOG "Orig-To: %s From: %s MessageID: %s Subject: %s. Log message: $%s", $to, $from, $messageid, $subject, $logmessage; + printf SYSLOG "Orig-To: %s From: %s MessageID: %s Subject: %s. Log message: %s", $to, $from, $messageid, $subject, $logmessage; } else { printf SYSLOG "Orig-To: %s From: %s MessageID: %s Subject: %s", $to, $from, $messageid, $subject; } @@ -218,19 +224,19 @@ sub do_mail { sub panic { my ($arg) = @_; - do_log('','','','','',"$arg"); + do_log('','','','',"$arg"); exit(0); } sub panic_prepare { my ($arg) = @_; - do_log('','','','','',"Could not prepare '$arg'"); + do_log('','','','',"Could not prepare '$arg'"); exit(0); } sub panic_execute { my ($arg,$param) = @_; - do_log('','','','','',"Could not execute '$arg' with parameters $param"); + do_log('','','','',"Could not execute '$arg' with parameters $param"); exit(0); } @@ -319,6 +325,7 @@ sub send_vacation_email { my ($from, $to, $cc, $subject, $messageid, $lastheader); $subject=''; +$spam = 0; # Take headers apart while () {