From: <Gin...@us...> - 2008-07-09 12:13:35
|
Revision: 400 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=400&view=rev Author: GingerDog Date: 2008-07-09 05:13:43 -0700 (Wed, 09 Jul 2008) Log Message: ----------- patch from Fabio Bonelli; as per https://sourceforge.net/tracker/?func=detail&atid=937966&aid=2014010&group_id=191583 - thank you! Modified Paths: -------------- branches/postfixadmin-2.2.1/VIRTUAL_VACATION/vacation.pl Modified: branches/postfixadmin-2.2.1/VIRTUAL_VACATION/vacation.pl =================================================================== --- branches/postfixadmin-2.2.1/VIRTUAL_VACATION/vacation.pl 2008-07-02 19:51:41 UTC (rev 399) +++ branches/postfixadmin-2.2.1/VIRTUAL_VACATION/vacation.pl 2008-07-09 12:13:43 UTC (rev 400) @@ -36,6 +36,9 @@ # 2007-08-20 Martin Ambroz <am...@tr...> # Added initial Unicode support # +# 2008-05-09 Fabio Bonelli <fab...@li...> +# 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 @@ 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 @@ # 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 @@ 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 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); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |