#!/usr/bin/perl # # logpopauth-pre # smtp-poplock package by David Harris # use strict; BEGIN: { require "/etc/smtp-poplock.conf" }; BEGIN: { require POSIX; POSIX->import( qw (F_SETFD) ); } &main; sub main { # Determine the outfile my $outfile = $Conf::logpopauth_where; # Print an error when missing the ipaddress if ( $ENV{'TCPREMOTEIP'} eq "" ) { print STDERR "logpopauth-pre: ERROR: the TCPREMOTEIP environment variable is blank\n"; } # Open the outfile and record it in the env if ( defined $outfile and open FH, "$outfile" ) { fcntl FH, &F_SETFD(), 0; # un-set the close-on-exec bit $ENV{'LOGPOPAUTH_FILENUM'} = fileno(FH); } # Run our friend exec @ARGV; die "exec failed"; }