[PATCH] Bugfix: Avoid non-constant LOG_* macros from Unix::Syslog

Dave O'Neill dmo at roaringpenguin.com
Wed Sep 29 14:18:02 EDT 2010


This addresses an issue where _make_fac_map can throw errors like:

	Usage: Unix::Syslog::LOG_FAC(p) at (eval 119) line 1.

when trying to use macros that take arguments as constant macros.

This is also now fixed in Log::Syslog::Abstract -- which we would
be using here if we didn't want to avoid forcing MIMEDefang users
to fetch another CPAN dependency :(
---
 mimedefang.pl.in |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/mimedefang.pl.in b/mimedefang.pl.in
index 91af076..4ac7b45 100755
--- a/mimedefang.pl.in
+++ b/mimedefang.pl.in
@@ -695,6 +695,16 @@ sub time_str () {
 		error => 'err',
 		panic => 'emerg',
 	);
+
+	# Some of the Unix::Syslog 'macros' tag exports aren't
+	# constants, so we need to ignore them if found.
+	my %blacklisted = map { $_ => 1 } qw(
+		LOG_MASK
+		LOG_UPTO
+		LOG_PRI
+		LOG_MAKEPRI
+		LOG_FAC
+	);
 	sub _make_fac_map
 	{
 		my %map;
@@ -702,7 +712,7 @@ sub time_str () {
 		# Ugh.  Make sure we map only the available constants
 		# on this platform.  Some are not defined properly on
 		# all platforms.
-		foreach my $constant ( @{ $Unix::Syslog::EXPORT_TAGS{macros} } ) {
+		foreach my $constant ( grep { /^LOG_/ && !exists $blacklisted{$_} } @{ $Unix::Syslog::EXPORT_TAGS{macros}} ) {
 			my $name = lc $constant;
 			$name =~ s/^log_//;
 
-- 
1.6.5


--zhXaljGHf11kAtnf--


More information about the MIMEDefang mailing list