From cd7172dcea4e39868eee94be55015b1f1cc6ba38 Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Wed, 21 Oct 2009 08:00:07 +0000 Subject: [PATCH] vacation.pl: see email conversation with stevan@bajic.ch and #2835877 (https://sourceforge.net/tracker/?func=detail&aid=2835877&group_id=191583&atid=937964); thanks to stevan for taking the time to explain why he was right :) - this change makes the vacation script look for user#domain@vacation.domain in the alias table, rather than user@domain, which is a better check (as it implies they also have vacation turned on) git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@734 a1433add-5e2c-0410-b055-b7f2511e0802 --- VIRTUAL_VACATION/vacation.pl | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/VIRTUAL_VACATION/vacation.pl b/VIRTUAL_VACATION/vacation.pl index eefbab57..9f0f34f0 100644 --- a/VIRTUAL_VACATION/vacation.pl +++ b/VIRTUAL_VACATION/vacation.pl @@ -17,7 +17,7 @@ # Slightly better logging which includes messageid # Avoid infinite loops with domain aliases # -# 2005-01-19 Troels Arvin +# 2005-01-19 Troels Arvin # PostgreSQL-version. # Normalized DB schema from one vacation table ("vacation") # to two ("vacation", "vacation_notification"). Uses @@ -27,18 +27,18 @@ # to try to avoid SQL injection. # International characters are now handled well. # -# 2005-01-21 Troels Arvin +# 2005-01-21 Troels Arvin # Uses the Email::Valid package to avoid sending notices # to obviously invalid addresses. # -# 2007-08-15 David Goodwin +# 2007-08-15 David Goodwin # Use the Perl Mail::Sendmail module for sending mail # Check for headers that start with blank lines (patch from forum) # -# 2007-08-20 Martin Ambroz +# 2007-08-20 Martin Ambroz # Added initial Unicode support # -# 2008-05-09 Fabio Bonelli +# 2008-05-09 Fabio Bonelli # Properly handle failed queries to vacation_notification. # Fixed log reporting. # @@ -326,10 +326,13 @@ sub find_real_address { $realemail = $email; $logger->debug("Found '\$email'\ has vacation active"); } else { + my $vemail = $email; + $vemail =~ s/\@/#/g; + $vemail = $vemail . "\@" . $vacation_domain; $logger->debug("Looking for alias records that \'$email\' resolves to with vacation turned on"); - $query = qq{SELECT goto FROM alias WHERE address=? AND (goto LIKE ? OR goto LIKE ? OR goto LIKE ?)}; + $query = qq{SELECT goto FROM alias WHERE address=? AND (goto LIKE ? OR goto LIKE ? OR goto LIKE ? OR goto = ?)}; $stm = $dbh->prepare($query) or panic_prepare($query); - $stm->execute($email,"$email,%","%,$email","%,$email,%") or panic_execute($query,"address='$email'"); + $stm->execute($email,"$vemail,%","%,$vemail","%,$vemail,%", "$vemail") or panic_execute($query,"address='$email'"); $rv = $stm->rows; # Recipient is an alias, check if mailbox has vacation