diff --git a/Changes b/Changes index 07dbd3b..83c8b98 100644 --- a/Changes +++ b/Changes @@ -1,4 +1,7 @@ 0.33 + New Qpsmtpd::Postfix::Constants to encapsulate all of the current return + codes from Postfix, plus script to generate it. (Hanno Hecker) + Add ability to specific socket for syslog (Peter Eisch) Do the right thing for unimplemented AUTH mechanisms (Brian Szymanski) diff --git a/lib/Qpsmtpd/Postfix/pf2qp.pl b/lib/Qpsmtpd/Postfix/pf2qp.pl new file mode 100755 index 0000000..0cd7894 --- /dev/null +++ b/lib/Qpsmtpd/Postfix/pf2qp.pl @@ -0,0 +1,115 @@ +#/usr/bin/perl -w +# +# +my $version = "0.1"; +$0 =~ s#.*/##; +my $path = $&; # sneaky way to get path back + +my $POSTFIX_SRC = shift || die <<"EOF"; +Usage: + $0 /path/to/postfix/source + +EOF + +my $header = "$POSTFIX_SRC/src/global/cleanup_user.h"; +my $src = "$POSTFIX_SRC/src/global/cleanup_strerror.c"; +my $pf_vers = "$POSTFIX_SRC/src/global/mail_version.h"; +my $postfix_version = ""; + +open VERS, $pf_vers + or die "Could not open $pf_vers: $!\n"; +while () { + next unless /^\s*#\s*define\s+MAIL_VERSION_NUMBER\s+"(.+)"\s*$/; + $postfix_version = $1; + last; +} +close VERS; +$postfix_version =~ s/^(\d+\.\d+).*/$1/; +if ($postfix_version < 2.3) { + die "Need at least postfix v2.3"; +} +my $start = <<'_END'; +# +# Qpsmtpd::Postfix::Constants +# +# This is a generated file, do not edit +# +_END +$start .= "# created by $0 v$version @ ".scalar(gmtime)."\n" + ."# postfix version $postfix_version\n" + ."#\n"; +$start .= <<'_END'; +package Qpsmtpd::Postfix::Constants; + +use Qpsmtpd::Constants; + +require Exporter; + +use vars qw(@ISA @EXPORT %cleanup_soft %cleanup_hard $postfix_version); +use strict; + +@ISA = qw(Exporter); +_END + +my @export = qw(%cleanup_soft %cleanup_hard $postfix_version); +my @out = (); + +open HEAD, $header + or die "Could not open $header: $!\n"; + +while () { + while (s/\\\n$//) { + $_ .= ; + } + chomp; + if (/^\s*#define\s/) { + s/^\s*#define\s*//; + next if /^_/; + s#(/\*.*\*/)##; + my $comment = $1 || ""; + my @words = split ' ', $_; + my $const = shift @words; + if ($const eq "CLEANUP_STAT_OK") { + push @out, ""; + } + push @export, $const; + push @out, "use constant $const => ". join(" ", @words). "; " + .($comment ? "# $comment ": ""); + } +} +close HEAD; + +open SRC, $src + or die "Could not open $src: $!\n"; +my $data; +{ + local $/ = undef; + $data = ; +} +close SRC; +$data =~ s/.*cleanup_stat_map\[\]\s*=\s*{\s*\n//s; +$data =~ s/};.*$//s; +my @array = split "\n", $data; +my (@denysoft,@denyhard); +foreach (@array) { + chomp; + s/,/ => /; + s/"(\d\.\d\.\d)",\s+"(.*)",/"$2 (#$1)",/; + s!(/\*.*\*/)!# $1!; + s/4\d\d,\s// && push @denysoft, $_; + s/5\d\d,\s// && push @denyhard, $_; +} + +open my $CONSTANTS, '>', "$path/Constants.pm"; + +print ${CONSTANTS} $start, '@EXPORT = qw(', "\n"; +while (@export) { + print ${CONSTANTS} "\t", shift @export, "\n"; +} +print ${CONSTANTS} ");\n\n", + "\$postfix_version = \"$postfix_version\";\n", + join("\n", @out),"\n\n"; +print ${CONSTANTS} "\%cleanup_soft = (\n", join("\n", @denysoft), "\n);\n\n"; +print ${CONSTANTS} "\%cleanup_hard = (\n", join("\n", @denyhard), "\n);\n\n1;\n"; + +close $CONSTANTS;