On Thu, 17 Feb 2011 17:21:42 +0100
Jan-Pieter Cornet <[email protected]> wrote:

> You removed the check against $EXPORT_TAGS{macros}.

Oops, that's bad.  Here's a better patch.

Regards,

David.

diff --git a/mimedefang.pl.in b/mimedefang.pl.in
index 4489c0c..c863d6d 100755
--- a/mimedefang.pl.in
+++ b/mimedefang.pl.in
@@ -669,17 +669,16 @@ sub time_str () {
        {
                my($facility) = @_;
 
-               if( ! defined $_fac_map ) {
-                       $_fac_map = _make_fac_map();
-               }
-
                my $num = 0;
                foreach my $thing (split(/\|/, $facility)) {
-                       next unless exists $_fac_map->{$thing};
+                       if (!defined($_fac_map) ||
+                           !exists($_fac_map->{$thing})) {
+                               $_fac_map->{$thing} = _fac_to_num($thing);
+                       }
+                       next unless defined $_fac_map->{$thing};
                        $num |= $_fac_map->{$thing};
                }
                return $num;
-
        }
 
        my %special = (
@@ -689,37 +688,16 @@ sub time_str () {
 
        # 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;
-
-               # Ugh.  Make sure we map only the available constants
-               # on this platform.  Some are not defined properly on
-               # all platforms.
-               foreach my $constant ( grep { /^LOG_/ && !exists 
$blacklisted{$_} } @{ $Unix::Syslog::EXPORT_TAGS{macros}} ) {
-                       my $name = lc $constant;
-                       $name =~ s/^log_//;
-
-                       my $value = eval "Unix::Syslog::$constant()";
-                       if( defined $value ) {
-                               $map{$name} = $value;
-                       }
-               }
+       my %blacklisted = map { $_ => 1 } qw(mask upto pri makepri fac);
 
-               # Some strings supported by Sys::Syslog don't
-               # correspond to a Unix::Syslog LOG_XXXX constant.
-               while( my($new_key, $existing_key) = each %special ) {
-                       $map{$new_key} = $map{$existing_key};
-               }
-
-               return \%map;
+        sub _fac_to_num
+       {
+               my ($thing) = @_;
+               return undef if exists $blacklisted{$thing};
+               $thing = $special{$thing} if exists $special{$thing};
+               $thing = 'LOG_' . uc($thing);
+               return undef unless grep { $_ eq $thing } @ 
{$Unix::Syslog::EXPORT_TAGS{macros} };
+               return eval "Unix::Syslog::$thing()";
        }
 }
 
@@ -7450,6 +7428,6 @@ sub md_check_against_smtp_server ($$$$;$) {
     return ($retval, $text, $code, $dsn);
 }
 
-exit(&main);
+exit(&main) unless caller;
 #------------------------------------------------------------
 1;
_______________________________________________
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID.  You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list [email protected]
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang

Reply via email to