view release on metacpan or search on metacpan
Makefile.PL view on Meta::CPAN
# Supported options:
#
# SENDMAIL=/path/to/sendmail Path to sendmail binary [auto-detect]
# DEFANGUSER=login MIMEDefang run-as user [defang]
# MILTERINC=/path/to/milter/inc Milter header directory [auto-detect]
# MILTERLIB=/path/to/milter/lib Milter library directory [auto-detect]
# SPOOLDIR=/var/spool/MIMEDefang Spool directory
# QUARANTINEDIR=/var/spool/MD-Quarantine
# CONFSUBDIR=mail Subdirectory under sysconfdir
# SYSCONFDIR=/etc System configuration root
# ENABLE_EMBEDDED_PERL=1|0 Build embedded Perl interpreter [1]
# ENABLE_POLL=0|1 Use poll(2) instead of select(2) [0]
# ENABLE_DEBUGGING=0|1 Enable syslog debug messages [0]
# ENABLE_ANTI_VIRUS=1|0 Probe for AV scanners [1]
# ENABLE_CHECK_PERL_MODULES=1|0 Verify Perl deps at build time [1]
# ENABLE_PTHREAD_FLAG=0|1 Pass -pthread to the C compiler [0]
# IPHEADER=0|1 Install IP-header config file [0]
# =============================================================================
use strict;
use warnings;
Makefile.PL view on Meta::CPAN
$found or die <<END;
ERROR: Cannot find libmilter.
Install sendmail-devel / libmilter-dev, or pass MILTERLIB=/path
END
};
print "Milter include dir : $MILTERINC\n";
print "Milter library dir : $MILTERLIB\n";
# --- Feature flags ---------------------------------------------------------
my $ENABLE_EMBEDDED_PERL = opt('ENABLE_EMBEDDED_PERL', 1);
my $ENABLE_POLL = opt('ENABLE_POLL', 0);
my $ENABLE_DEBUGGING = opt('ENABLE_DEBUGGING', 0);
my $ENABLE_ANTI_VIRUS = opt('ENABLE_ANTI_VIRUS', 1);
my $ENABLE_CHECK_PERL_MODULES= opt('ENABLE_CHECK_PERL_MODULES',1);
my $ENABLE_PTHREAD_FLAG = opt('ENABLE_PTHREAD_FLAG', 0);
# --- Required Perl module check --------------------------------------------
if ($ENABLE_CHECK_PERL_MODULES) {
print "\nChecking required Perl modules:\n";
my $all_ok = 1;
Makefile.PL view on Meta::CPAN
# --- socklen probe --------------------------------------------------------
my $HAVE_SOCKLEN_T = probe_socklen();
print "socklen_t : " . ($HAVE_SOCKLEN_T ? 'yes' : 'no') . "\n";
# --- libresolv probe -------------------------------------------------------
my $HAVE_LIBRESOLV = probe_libresolv();
print "libresolv : " . ($HAVE_LIBRESOLV ? 'yes' : 'no (using libc)') . "\n";
# --- Embedded Perl C/LD flags ----------------------------------------------
my ($EMBPERL_CFLAGS, $EMBPERL_LDFLAGS) = ('', '');
if ($ENABLE_EMBEDDED_PERL) {
chomp($EMBPERL_CFLAGS = `$PERL -MExtUtils::Embed -e ccopts 2>/dev/null`);
chomp($EMBPERL_LDFLAGS = `$PERL -MExtUtils::Embed -e ldopts 2>/dev/null`);
print "Embedded Perl : enabled\n";
} else {
print "Embedded Perl : disabled\n";
}
# Base CFLAGS: use the compiler's defaults plus mandatory defines
my $CFLAGS = join(' ',
'-I.',
"-I$MILTERINC",
"-std=c89 -D_BSD_SOURCE -D_DEFAULT_SOURCE",
($ENABLE_DEBUGGING ? '-DENABLE_DEBUGGING' : ()),
($ENABLE_POLL ? '-DUSE_POLL' : ()),
($ENABLE_PTHREAD_FLAG ? '-pthread' : ()),
($HAVE_CLOCK_MONOTONIC ? '-DHAVE_CLOCK_MONOTONIC' : ()),
($ENABLE_EMBEDDED_PERL ? ('-DEMBED_PERL', $EMBPERL_CFLAGS) : ()),
);
my $LDFLAGS_MILTER = "-L$MILTERLIB -lmilter";
my $LDFLAGS_PTHREAD = $ENABLE_PTHREAD_FLAG ? '-lpthread' : '';
my $LDFLAGS_EMBPERL = $ENABLE_EMBEDDED_PERL ? $EMBPERL_LDFLAGS : '';
my $LDFLAGS_COMMON = join(' ', ($HAVE_LIBRESOLV ? '-lresolv' : ()),
$LDFLAGS_PTHREAD, $LDFLAGS_EMBPERL);
my $HAVE_MILTER = probe_milter($CC, $CFLAGS);
print "\nmilter.h: " . ($HAVE_MILTER ? 'found' : 'not found') . "\n";
print "\nCC : $CC\n";
print "CFLAGS (extra) : $CFLAGS\n\n";
# --- Write config.h --------------------------------------------------------
Makefile.PL view on Meta::CPAN
CONFDIR => $CONFDIR,
SENDMAILPROG => $SENDMAILPROG,
VERSION => $VERSION,
MIMEDEFANG_PL => $MIMEDEFANG_PL,
HAVE_CLOCK_MONOTONIC => $HAVE_CLOCK_MONOTONIC,
HAVE_INET_NTOP => $HAVE_INET_NTOP,
HAVE_SOCKLEN_T => $HAVE_SOCKLEN_T,
HAVE_MILTER => $HAVE_MILTER,
ENABLE_DEBUGGING => $ENABLE_DEBUGGING,
ENABLE_POLL => $ENABLE_POLL,
WITH_EMBEDDED_PERL=> $ENABLE_EMBEDDED_PERL,
);
# ---------------------------------------------------------------------------
# Substitution map for .in template files
# ---------------------------------------------------------------------------
my %SUBST = (
PERL => $PERL,
VERSION => $VERSION,
PACKAGE => 'mimedefang',
DEFANGUSER => $DEFANGUSER,
Makefile.PL view on Meta::CPAN
drop_privs.o
dynbuf.o
event.o
event_tcp.o
gen_id.o
notifier.o
rm_r.o
syslog-fac.o
utils.o
);
push @mux_obj_list, 'embperl.o', 'xs_init.o' if $ENABLE_EMBEDDED_PERL;
my $mux_objs = join(' ', @mux_obj_list);
my $mux_ldflags = '$(MD_LDFLAGS_COMMON)';
# md-mx-ctrl
my $ctrl_objs = join(' ', qw(
md-mx-ctrl.o
dynbuf.o
utils.o
));
my $ctrl_ldflags = '$(MD_LDFLAGS_COMMON)';
Makefile.PL view on Meta::CPAN
$content =~ s{\@([A-Z0-9_]+)\@}{ exists $subst{$1} ? $subst{$1} : '/bin/false' }ge;
(my $outf = $mdfile) =~ s/\.in$//;
open my $out, '>', $outf or do { warn "Cannot write $outf: $!\n"; next };
print $out $content;
close $out;
my $mode = (stat $mdfile)[2] & 0777;
chmod $mode, $outf;
}
# Generate xs_init.c for embedded Perl support
if ($ENABLE_EMBEDDED_PERL) {
print "Generating xs_init.c for embedded Perl...\n";
system($PERL, '-MExtUtils::Embed', '-e', 'xsinit', '--', '-o', 'xs_init.c') == 0
or warn "WARNING: Failed to generate xs_init.c\n";
}
# ----------------------------------------------------------------
# Extra install targets (spool dirs, config, man pages, scripts)
# ----------------------------------------------------------------
return <<MAKE;
Makefile.PL view on Meta::CPAN
print $fh '#define CONFDIR "' . $v{CONFDIR} . "\"\n";
print $fh '#define SENDMAIL_PROG "' . $v{SENDMAILPROG} . "\"\n";
print $fh "#ifndef HAVE_CLOCK_MONOTONIC\n#define HAVE_CLOCK_MONOTONIC\n#endif\n" if $v{HAVE_CLOCK_MONOTONIC};
print $fh '#define MIMEDEFANG_PL "' . $v{MIMEDEFANG_PL} . "\"\n";
print $fh "#define HAVE_UNISTD_H 1\n";
print $fh "#ifndef HAVE_INET_NTOP\n#define HAVE_INET_NTOP\n#endif\n" if $v{HAVE_INET_NTOP};
print $fh "#define HAVE_SOCKLEN_T\n" if not $v{HAVE_SOCKLEN_T};
print $fh "#define HAVE_MILTER\n" if $v{HAVE_MILTER};
print $fh "#ifndef ENABLE_DEBUGGING\n#define ENABLE_DEBUGGING\n#endif\n" if $v{ENABLE_DEBUGGING};
print $fh "#ifndef USE_POLL\n#define USE_POLL\n#endif\n" if $v{ENABLE_POLL};
print $fh "#ifndef EMBED_PERL\n#define EMBED_PERL\n#endif\n" if $v{WITH_EMBEDDED_PERL};
print $fh "#define STDC_HEADERS 1\n";
close $fh;
print "config.h written.\n";
}
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: *** Error: Could not find Sys::Syslog or Unix::Syslog" >&5
printf "%s\n" "$as_me: WARNING: *** Error: Could not find Sys::Syslog or Unix::Syslog" >&2;}
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: *** One of those Perl modules is required." >&5
printf "%s\n" "$as_me: WARNING: *** One of those Perl modules is required." >&2;};
exit 1
fi
fi
if test "$ac_cv_embedded_perl" = "no" ; then
echo "Check for embedded perl disabled by --disable-embedded-perl option"
HAVE_EXTUTILS_EMBED=no
else
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Perl module ExtUtils::Embed" >&5
printf %s "checking for Perl module ExtUtils::Embed... " >&6; }
(echo "use ExtUtils::Embed;" ; echo "exit(0);") | $PERL > /dev/null 2>&1
if test $? = 0 ; then
HAVE_EXTUTILS_EMBED=yes
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ok" >&5
printf "%s\n" "ok" >&6; }
else
HAVE_EXTUTILS_EMBED=no
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
fi
fi
ac_fn_c_check_header_compile "$LINENO" "getopt.h" "ac_cv_header_getopt_h" "$ac_includes_default"
if test "x$ac_cv_header_getopt_h" = xyes
then :
printf "%s\n" "#define HAVE_GETOPT_H 1" >>confdefs.h
PTHREAD_FLAG=""
ac_cv_prog_cc_pthread=no
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_pthread" >&5
printf "%s\n" "$ac_cv_prog_cc_pthread" >&6; }
rm -f conftest*
else
PTHREAD_FLAG=""
fi
if test "$HAVE_EXTUTILS_EMBED" = "yes" ; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we can embed a Perl interpreter in C" >&5
printf %s "checking if we can embed a Perl interpreter in C... " >&6; }
OLDCFLAGS="$CFLAGS"
OLDLDFLAGS="$LDFLAGS"
OLDLIBS="$LIBS"
LIBS="-lperl $LIBS"
EMBPERLLDFLAGS="`$PERL -MExtUtils::Embed -e ldopts`"
EMBPERLCFLAGS="`$PERL -MExtUtils::Embed -e ccopts`"
LDFLAGS="$EMBPERLLDFLAGS $LDFLAGS"
CFLAGS="$EMBPERLCFLAGS $CFLAGS"
static PerlInterpreter *my_perl;
int main(int argc, char **argv, char **env) {
my_perl = perl_alloc();
if (!my_perl) exit(1);
exit(0);
}
_ACEOF
if ac_fn_c_try_run "$LINENO"
then :
EMBED_PERL=yes
else case e in #(
e) EMBED_PERL=no ;;
esac
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext ;;
esac
fi
LIBS="$OLDLIBS"
CFLAGS="$OLDCFLAGS"
LDFLAGS="$OLDLDFLAGS"
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $EMBED_PERL" >&5
printf "%s\n" "$EMBED_PERL" >&6; }
else
EMBED_PERL=no
fi
if test "$EMBED_PERL" = "no" ; then
EMBPERLCFLAGS=""
EMBPERLLDFLAGS=""
EMBPERLLIBS=""
EMBPERLDEFS=""
EMBPERLOBJS=""
else
EMBPERLLIBS="-lperl"
EMBPERLDEFS="-DEMBED_PERL"
EMBPERLOBJS="embperl.o xs_init.o"
# Check for buggy perl interpreter
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if it is safe to destroy and recreate a Perl interpreter" >&5
printf %s "checking if it is safe to destroy and recreate a Perl interpreter... " >&6; }
LIBS="-lperl $LIBS"
LDFLAGS="$EMBPERLLDFLAGS $LDFLAGS"
CFLAGS="$EMBPERLCFLAGS $CFLAGS $PTHREAD_FLAG"
if test "$cross_compiling" = yes
then :
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5
main(int argc, char **argv, char **env)
{
make_embedded_interpreter(env);
make_embedded_interpreter(env);
return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"
then :
SAFE_EMBED_PERL=yes
else case e in #(
e) SAFE_EMBED_PERL=no ;;
esac
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext ;;
esac
fi
LIBS="$OLDLIBS"
CFLAGS="$OLDCFLAGS"
LDFLAGS="$OLDLDFLAGS"
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $SAFE_EMBED_PERL" >&5
printf "%s\n" "$SAFE_EMBED_PERL" >&6; }
if test "$SAFE_EMBED_PERL" = "yes" ; then
EMBPERLDEFS="$EMBPERLDEFS -DSAFE_EMBED_PERL"
fi
fi
if test "$ac_cv_use_poll" = "no" ; then
USEPOLL=""
else
if test "$ac_cv_header_poll_h" = "no" ; then
USEPOLL=""
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: *** You used --enable-poll, but I cannot find the" >&5
printf "%s\n" "$as_me: WARNING: *** You used --enable-poll, but I cannot find the" >&2;}
configure.ac view on Meta::CPAN
if test "$ac_cv_perlmodcheck" = "yes" ; then
AC_MSG_WARN([*** Error: Could not find Sys::Syslog or Unix::Syslog])
AC_MSG_WARN([*** One of those Perl modules is required.]);
exit 1
fi
fi
dnl Check for ExtUtils::Embed
if test "$ac_cv_embedded_perl" = "no" ; then
echo "Check for embedded perl disabled by --disable-embedded-perl option"
HAVE_EXTUTILS_EMBED=no
else
AC_MSG_CHECKING([for Perl module ExtUtils::Embed])
(echo "use ExtUtils::Embed;" ; echo "exit(0);") | $PERL > /dev/null 2>&1
if test $? = 0 ; then
HAVE_EXTUTILS_EMBED=yes
AC_MSG_RESULT(ok)
else
HAVE_EXTUTILS_EMBED=no
AC_MSG_RESULT(no)
fi
fi
AC_SUBST(HAVE_SPAM_ASSASSIN)
AC_CHECK_HEADERS(getopt.h unistd.h stdint.h poll.h stdint.h)
dnl Check if stdint.h defines uint32_t
AC_MSG_CHECKING(whether stdint.h defines uint32_t)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
configure.ac view on Meta::CPAN
else
PTHREAD_FLAG=""
ac_cv_prog_cc_pthread=no
fi
AC_MSG_RESULT($ac_cv_prog_cc_pthread)
rm -f conftest*
else
PTHREAD_FLAG=""
fi
if test "$HAVE_EXTUTILS_EMBED" = "yes" ; then
AC_MSG_CHECKING([if we can embed a Perl interpreter in C])
OLDCFLAGS="$CFLAGS"
OLDLDFLAGS="$LDFLAGS"
OLDLIBS="$LIBS"
LIBS="-lperl $LIBS"
EMBPERLLDFLAGS="`$PERL -MExtUtils::Embed -e ldopts`"
EMBPERLCFLAGS="`$PERL -MExtUtils::Embed -e ccopts`"
LDFLAGS="$EMBPERLLDFLAGS $LDFLAGS"
CFLAGS="$EMBPERLCFLAGS $CFLAGS"
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <EXTERN.h>
#include <perl.h>
#include <stdlib.h>
static PerlInterpreter *my_perl;
int main(int argc, char **argv, char **env) {
my_perl = perl_alloc();
if (!my_perl) exit(1);
exit(0);
}
]])],[EMBED_PERL=yes],[EMBED_PERL=no],[])
LIBS="$OLDLIBS"
CFLAGS="$OLDCFLAGS"
LDFLAGS="$OLDLDFLAGS"
AC_MSG_RESULT($EMBED_PERL)
else
EMBED_PERL=no
fi
if test "$EMBED_PERL" = "no" ; then
EMBPERLCFLAGS=""
EMBPERLLDFLAGS=""
EMBPERLLIBS=""
EMBPERLDEFS=""
EMBPERLOBJS=""
else
EMBPERLLIBS="-lperl"
EMBPERLDEFS="-DEMBED_PERL"
EMBPERLOBJS="embperl.o xs_init.o"
# Check for buggy perl interpreter
AC_MSG_CHECKING([if it is safe to destroy and recreate a Perl interpreter])
LIBS="-lperl $LIBS"
LDFLAGS="$EMBPERLLDFLAGS $LDFLAGS"
CFLAGS="$EMBPERLCFLAGS $CFLAGS $PTHREAD_FLAG"
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <EXTERN.h>
#include <perl.h>
configure.ac view on Meta::CPAN
return 0;
}
int
main(int argc, char **argv, char **env)
{
make_embedded_interpreter(env);
make_embedded_interpreter(env);
return 0;
}
]])],[SAFE_EMBED_PERL=yes],[SAFE_EMBED_PERL=no],[])
LIBS="$OLDLIBS"
CFLAGS="$OLDCFLAGS"
LDFLAGS="$OLDLDFLAGS"
AC_MSG_RESULT($SAFE_EMBED_PERL)
if test "$SAFE_EMBED_PERL" = "yes" ; then
EMBPERLDEFS="$EMBPERLDEFS -DSAFE_EMBED_PERL"
fi
fi
if test "$ac_cv_use_poll" = "no" ; then
USEPOLL=""
else
if test "$ac_cv_header_poll_h" = "no" ; then
USEPOLL=""
AC_MSG_WARN([*** You used --enable-poll, but I cannot find the])
AC_MSG_WARN([*** poll.h header. Turning OFF --enable-poll])
*
* Routines for manipulating embedded Perl interpreter
*
* Copyright (C) 2003 by Roaring Penguin Software Inc.
*
* This program may be distributed under the terms of the GNU General
* Public License, Version 2.
*
***********************************************************************/
#ifdef EMBED_PERL
#include <EXTERN.h>
#include <perl.h>
#include <errno.h>
#include <syslog.h>
#ifdef PERL_SET_CONTEXT
#define PSC(x) PERL_SET_CONTEXT(x)
#else
#define PSC(x) (void) 0
#endif
argv = (char **) malloc(PERLPARSE_NUM_ARGS * sizeof(char *));
if (!argv) {
fprintf(stderr, "Out of memory allocating argv[] array for embedded Perl!");
syslog(LOG_ERR, "Out of memory allocating argv[] array for embedded Perl!");
exit(EXIT_FAILURE);
}
}
memset(argv, 0, PERLPARSE_NUM_ARGS * sizeof(char *));
if (my_perl != NULL) {
#ifdef SAFE_EMBED_PERL
PSC(my_perl);
PERL_SET_INTERP(my_perl);
PL_perl_destruct_level = 1;
perl_destruct(my_perl);
perl_free(my_perl);
my_perl = NULL;
#else
syslog(LOG_WARNING, "Cannot destroy and recreate a Perl interpreter safely on this platform. Filter rules will NOT be reread.");
return 0;
#endif
examples/init-script.in view on Meta::CPAN
# MX_RECIPIENT_CHECK=no
# Set to yes if you want the multiplexor to log events to syslog
MX_LOG=yes
# Set to yes if you want the milter and multiplexor sockets to
# be group-writable and files created by mimedefang group-readable.
MD_ALLOW_GROUP_ACCESS=no
# Set to yes if you want to use an embedded Perl interpreter
# MX_EMBED_PERL=yes
# Set to full path of socket for Sendmail's SOCKETMAP map, if you
# want to use it with MIMEDefang
# MX_MAP_SOCKET=$SPOOLDIR/map.sock
# The multiplexor does not start all workers at the same time. Instead,
# it starts one worker every MX_WORKER_DELAY seconds when the system is idle.
# (If the system is busy, the multiplexor starts workers as incoming mail
# requires attention.)
# MX_WORKER_DELAY=3
examples/init-script.in view on Meta::CPAN
fi
if test -r $MXPID ; then
if kill -0 `cat $MXPID` > /dev/null 2>&1 ; then
echo "mimedefang-multiplexor (`cat $MXPID`) seems to be running."
return 1
fi
fi
printf "%-60s" "Starting $prog-multiplexor: "
rm -f $MX_SOCKET > /dev/null 2>&1
if [ "$MX_EMBED_PERL" = "yes" ] ; then
EMBEDFLAG=-E
else
EMBEDFLAG=""
fi
$PROGDIR/$prog-multiplexor -p $MXPID -o $MXLOCK \
$EMBEDFLAG \
`[ -n "$SPOOLDIR" ] && echo "-z $SPOOLDIR"` \
`[ -n "$FILTER" ] && echo "-f $FILTER"` \
`[ -n "$SYSLOG_FACILITY" ] && echo "-S $SYSLOG_FACILITY"` \
`[ -n "$SUBFILTER" ] && echo "-F $SUBFILTER"` \
`[ -n "$MX_MINIMUM" ] && echo "-m $MX_MINIMUM"` \
`[ -n "$MX_MAXIMUM" ] && echo "-x $MX_MAXIMUM"` \
`[ -n "$MX_MAP_SOCKET" ] && echo "-N $MX_MAP_SOCKET"` \
`[ -n "$MX_LOG_WORKER_STATUS_INTERVAL" ] && echo "-L $MX_LOG_WORKER_STATUS_INTERVAL"` \
`[ -n "$MX_USER" ] && echo "-U $MX_USER"` \
`[ -n "$MX_IDLE" ] && echo "-i $MX_IDLE"` \
mimedefang-multiplexor.8.in view on Meta::CPAN
\fB\-S \fIfacility\fR
Specifies the syslog facility for log messages. The default is
\fImail\fR. See \fBopenlog\fR(3) for a list of valid facilities.
You can use either the short name ("mail") or long name ("LOG_MAIL") for
the facility name.
.TP
\fB\-E\fR
Specifies that the multiplexor should create an embedded Perl interpreter.
This can improve performance dramatically. But see the section
"EMBEDDING PERL" for more information.
.TP
\fB\-X\fR \fIn\fR
Specifies that the multiplexor should initiate a "tick" request every
\fIn\fR seconds. This causes your \fIfilter_tick\fR function (if defined)
to be called. Note that you have no control over which worker executes
\fIfilter_tick\fR. If all workers are busy when a tick occurs,
that tick request is skipped and a warning message is logged.
.TP
mimedefang-multiplexor.8.in view on Meta::CPAN
Note that if you supply the \fB\-q\fR option to \fBmimedefang\fR, then
even new connections are allowed to queue. This may improve throughput by
keeping the worker utilization higher.
The \fB\-R\fR option to \fBmimedefang\fR can be used to reserve a
specified number of workers for connections from the loopback address. Using
the \fB\-R\fR option has the side-effect of permitting new connections
from the loopback address to queue.
.SH EMBEDDING PERL
Normally, when \fBmimedefang-multiplexor\fR activates a worker, it forks
and execs \fBmimedefang.pl\fR. However, if the multiplexor was compiled
with embedded Perl support, and you supply the \fB\-E\fR command-line
option, the multiplexor works like this:
.TP
1
It creates an embedded Perl interpreter, and sources \fBmimedefang.pl\fR
with a special command-line argument telling it to read the filter, but
mimedefang-multiplexor.c view on Meta::CPAN
fprintf(stderr, " -O sock -- Listen for notification requests on sock\n");
fprintf(stderr, " -q size -- Size of request queue (default 0)\n");
fprintf(stderr, " -Q timeout -- Timeout for queued requests\n");
fprintf(stderr, " -I backlog -- 'backlog' argument for listen on multiplexor socket\n");
fprintf(stderr, " -D -- Do not become a daemon (stay in foreground)\n");
fprintf(stderr, " -X interval -- Run a 'tick' request every interval seconds\n");
fprintf(stderr, " -P n -- Run 'n' parallel tick requests\n");
fprintf(stderr, " -Y label -- Set syslog label to 'label'\n");
fprintf(stderr, " -G -- Make sockets group-writable\n");
fprintf(stderr, " -k -- Enable adaptive autoscaling of the worker pool\n");
#ifdef EMBED_PERL
fprintf(stderr, " -E -- Use embedded Perl interpreter\n");
#endif
exit(EXIT_FAILURE);
}
static int
set_sigchld_handler(void)
{
struct sigaction act;
mimedefang-multiplexor.c view on Meta::CPAN
if (!Settings.unprivSockName) {
fprintf(stderr, "%s: Out of memory\n", argv[0]);
exit(EXIT_FAILURE);
}
break;
case 'v':
printf("mimedefang-multiplexor version %s\n", VERSION);
exit(EXIT_SUCCESS);
case 'E':
#ifdef EMBED_PERL
Settings.useEmbeddedPerl = 1;
#else
fprintf(stderr, "mimedefang-multiplexor compiled without support for embedded perl. Ignoring -E flag.\n");
#endif
break;
case 'D':
nodaemon = 1;
break;
case 'P':
if (sscanf(optarg, "%d", &n) != 1) usage();
mimedefang-multiplexor.c view on Meta::CPAN
Settings.minWorkers,
Settings.maxWorkers,
Settings.maxRequests,
Settings.maxLifetime,
Settings.maxIdleTime,
Settings.busyTimeout,
Settings.clientTimeout);
}
/* Init Perl interpreter */
#ifdef EMBED_PERL
if (Settings.useEmbeddedPerl) {
init_embedded_interpreter(argc, argv, env);
if (make_embedded_interpreter(Settings.progPath, Settings.subFilter,
Settings.wantStatusReports, Env) < 0) {
syslog(LOG_ERR, "Could not initialize embedded Perl interpreter -- falling back to old method.");
Settings.useEmbeddedPerl = 0;
} else {
if (DOLOG) {
syslog(LOG_INFO, "Initialized embedded Perl interpreter");
}
}
}
#endif
/* Set signal handler for SIGCHLD */
if (set_sigchld_handler() < 0) {
REPORT_FAILURE("sigaction failed - exiting.");
#ifdef EMBED_PERL
if (Settings.useEmbeddedPerl) {
term_embedded_interpreter();
deinit_embedded_interpreter();
}
#endif
if (pidfile) unlink(pidfile);
if (lockfile) unlink(lockfile);
exit(EXIT_FAILURE);
}
mimedefang-multiplexor.c view on Meta::CPAN
/* Remaining commands are privileged */
if (data) {
reply_to_mimedefang(es, fd, "error: Attempt to use privileged command on unprivileged socket\n");
return;
}
if (len == 6 && !strcmp(buf, "reread")) {
newGeneration();
notify_listeners(es, "R\n");
#ifndef SAFE_EMBED_PERL
if (Settings.useEmbeddedPerl) {
reply_to_mimedefang(es, fd, "Cannot destroy and recreate an embedded Perl interpreter safely on this platform. Filter rules will NOT be reread\n");
return;
}
#endif
reply_to_mimedefang(es, fd, "Forced reread of filter rules\n");
return;
}
if (len == 9 && !strcmp(buf, "autoscale")) {
mimedefang-multiplexor.c view on Meta::CPAN
(void) close(i);
}
pname = strrchr(Settings.progPath, '/');
if (pname) {
pname++;
} else {
pname = Settings.progPath;
}
#ifdef EMBED_PERL
if (Settings.useEmbeddedPerl) {
run_embedded_filter();
term_embedded_interpreter();
deinit_embedded_interpreter();
exit(EXIT_SUCCESS);
}
#endif
if (Settings.wantStatusReports) {
sarg = "-serveru";
} else {
mimedefang-multiplexor.c view on Meta::CPAN
for (j=0; j<10; j++) {
reapTerminatedWorkers(1);
oneleft = 0;
for (i=0; i<Settings.maxWorkers; i++) {
if (AllWorkers[i].pid != (pid_t) -1) {
oneleft = 1;
break;
}
}
if (!oneleft) {
#ifdef EMBED_PERL
if (Settings.useEmbeddedPerl) {
term_embedded_interpreter();
deinit_embedded_interpreter();
}
#endif
exit(EXIT_SUCCESS);
}
if (j != 9) {
sleep(1);
}
mimedefang-multiplexor.c view on Meta::CPAN
for (j=0; j<10; j++) {
reapTerminatedWorkers(1);
oneleft = 0;
for (i=0; i<Settings.maxWorkers; i++) {
if (AllWorkers[i].pid != (pid_t) -1) {
oneleft = 1;
break;
}
}
if (!oneleft) {
#ifdef EMBED_PERL
if (Settings.useEmbeddedPerl) {
term_embedded_interpreter();
deinit_embedded_interpreter();
}
#endif
exit(EXIT_SUCCESS);
}
if (j != 9) {
sleep(1);
}
}
syslog(LOG_INFO, "Still some workers alive: Sending SIGKILL");
/* Kill with SIGKILL */
for (i=0; i<Settings.maxWorkers; i++) {
if (AllWorkers[i].pid != (pid_t) -1) {
kill(AllWorkers[i].pid, SIGCONT);
kill(AllWorkers[i].pid, SIGKILL);
}
}
#ifdef EMBED_PERL
if (Settings.useEmbeddedPerl) {
term_embedded_interpreter();
deinit_embedded_interpreter();
}
#endif
exit(EXIT_SUCCESS);
}
/**********************************************************************
* %FUNCTION: statsReopenFile
mimedefang-multiplexor.c view on Meta::CPAN
* Nothing
* %DESCRIPTION:
* Kills all running-but-idle workers and increments Generation. This
* causes running-but-busy workers to terminate at the earliest opportunity.
* Use this if you change the filter file and want to restart the workers.
***********************************************************************/
static void
newGeneration(void)
{
Generation++;
#ifdef EMBED_PERL
if (Settings.useEmbeddedPerl) {
if (make_embedded_interpreter(Settings.progPath,
Settings.subFilter,
Settings.wantStatusReports, Env) < 0) {
syslog(LOG_ERR, "Error creating embedded Perl interpreter: Reverting to non-embedded interpreter!");
Settings.useEmbeddedPerl = 0;
} else {
if (DOLOG) {
syslog(LOG_INFO, "Re-initialized embedded Perl interpreter");
}
mimedefang.h view on Meta::CPAN
extern int readn(int fd, void *buf, size_t count);
extern int writestr(int fd, char const *buf);
extern int closefd(int fd);
extern int validate_smtp_code(char const *code, char const *first);
extern int validate_smtp_dsn(char const *dsn, char const *first);
extern int make_listening_socket(char const *str, int backlog, int must_be_unix);
extern void do_delay(char const *sleepstr);
extern int is_localhost(struct sockaddr *);
extern int remove_local_socket(char const *str);
extern int write_and_lock_pidfile(char const *pidfile, char **lockfile, int fd);
#ifdef EMBED_PERL
extern int make_embedded_interpreter(char const *progPath,
char const *subFilter,
int wantStatusReports,
char **env);
extern void init_embedded_interpreter(int, char **, char **);
extern void deinit_embedded_interpreter(void);
extern void term_embedded_interpreter(void);
extern void run_embedded_filter(void);
extern void dump_milter_buildlib_info(void);
redhat/mimedefang-init.in view on Meta::CPAN
$([ -n "$MX_QUEUE_SIZE" ] && echo "-q $MX_QUEUE_SIZE") \
$([ -n "$MX_QUEUE_TIMEOUT" ] && echo "-Q $MX_QUEUE_TIMEOUT") \
$([ -n "$MX_REQUESTS" ] && echo "-r $MX_REQUESTS") \
$([ -n "$MX_MAP_SOCKET" ] && echo "-N $MX_MAP_SOCKET") \
$([ -n "$MX_WORKER_DELAY" ] && echo "-w $MX_WORKER_DELAY") \
$([ -n "$MX_MIN_WORKER_DELAY" ] && echo "-W $MX_MIN_WORKER_DELAY") \
$([ -n "$MX_LOG_WORKER_STATUS_INTERVAL" ] && echo "-L $MX_LOG_WORKER_STATUS_INTERVAL") \
$([ -n "$MX_MAX_RSS" ] && echo "-R $MX_MAX_RSS") \
$([ -n "$MX_MAX_AS" ] && echo "-M $MX_MAX_AS") \
$([ -n "$MX_MAX_LIFETIME" ] && echo "-V $MX_MAX_LIFETIME") \
$([ "$MX_EMBED_PERL" = "yes" ] && (echo -n "-"; echo "E")) \
$([ "$MX_LOG" = "yes" ] && echo "-l") \
$([ "$MX_STATS" = "yes" ] && echo "-t /var/log/mimedefang/stats") \
$([ "$MX_STATUS_UPDATES" = "yes" ] && echo "-Z") \
$([ "$MX_STATS" = "yes" -a "$MX_FLUSH_STATS" = "yes" ] && echo "-u") \
$([ -n "$MX_TICK_REQUEST" ] && echo "-X $MX_TICK_REQUEST") \
$([ -n "$MX_TICK_PARALLEL" ] && echo "-P $MX_TICK_PARALLEL") \
$([ "$MX_STATS_SYSLOG" = "yes" ] && echo "-T") \
$([ "$MD_ALLOW_GROUP_ACCESS" = "yes" ] && echo "-G") \
$([ -n "$MX_NOTIFIER" ] && echo "-O $MX_NOTIFIER") \
$([ -n "$MX_AUTOSCALE" ] && echo "-k") \
redhat/mimedefang-sysconfig.in view on Meta::CPAN
# Revision 1.6 2004/10/28 20:31:21 dfs
# Add MX_STATUS_UPDATES variable to shell script.
#
# Revision 1.5 2004/06/21 18:46:03 dfs
# Add MX_MAP_SOCKET variable in init scripts.
#
# Revision 1.4 2004/02/23 16:43:23 dfs
# Added MX_NOTIFIER option in sysconfig and init script.
#
# Revision 1.3 2003/11/10 14:57:16 dfs
# Added MX_EMBED_PERL parameter.
#
# Revision 1.2 2003/08/06 02:09:58 dfs
# Increased timeouts.
#
# Revision 1.1 2003/07/23 18:27:35 dfs
# Made Red Hat files configurable.
#
# Revision 1.22 2003/07/23 18:13:52 dfs
# Added MD_EXTRA setting.
#
redhat/mimedefang-sysconfig.in view on Meta::CPAN
# Number of workers reserved for connections from loopback. Use -1
# for default behaviour, 0 to allow loopback connections to queue,
# or >0 to reserve workers for loopback connections
LOOPBACK_RESERVED_CONNECTIONS=-1
# Set to path name of UNIX-domain socket if you want to use MIMEDefang
# with Sendmail's SOCKETMAP map type
# MX_MAP_SOCKET=$SPOOLDIR/map.sock
# Set to yes if you want to use an embedded Perl interpreter
# MX_EMBED_PERL=yes
# Set to the syslog facility. Also set $SyslogFacility in your filter
# SYSLOG_FACILITY=mail
# The multiplexor does not start all workers at the same time. Instead,
# it starts one worker every MX_WORKER_DELAY seconds when the system is idle.
# (If the system is busy, the multiplexor starts workers as incoming mail
# requires attention.)
# MX_WORKER_DELAY=3
systemd-units/mimedefang-multiplexor.service view on Meta::CPAN
TimeoutStopSec=30s
KillMode=mixed
# Locale should be set to "C" for generating valid date headers
Environment=LC_ALL=C MX_BUSY=600 MX_LOG=yes MX_MAXIMUM=10 MX_MINIMUM=2 MX_SOCKET=/var/spool/MIMEDefang/mimedefang-multiplexor.sock MX_USER=defang
EnvironmentFile=-/etc/default/mimedefang
EnvironmentFile=-/etc/sysconfig/mimedefang
# This can be removed with MIMEDefang 2.82, but is required for older versions:
# SuccessExitStatus=1
ExecStart=/bin/sh -c 'HOME=${SPOOLDIR:=/var/spool/MIMEDefang} \
exec /usr/bin/mimedefang-multiplexor -D \
`[ "$MX_EMBED_PERL" = "yes" ] && echo "-E"` \
`[ -n "$SPOOLDIR" ] && echo "-z $SPOOLDIR"` \
`[ -n "$FILTER" ] && echo "-f $FILTER"` \
`[ -n "$SYSLOG_FACILITY" ] && echo "-S $SYSLOG_FACILITY"` \
`[ -n "$SUBFILTER" ] && echo "-F $SUBFILTER"` \
`[ -n "$MX_MAX_LIFETIME" ] && echo "-V $MX_MAX_LIFETIME"` \
`[ -n "$MX_MINIMUM" ] && echo "-m $MX_MINIMUM"` \
`[ -n "$MX_MAXIMUM" ] && echo "-x $MX_MAXIMUM"` \
`[ -n "$MX_MAP_SOCKET" ] && echo "-N $MX_MAP_SOCKET"` \
`[ -n "$MX_LOG_SLAVE_STATUS_INTERVAL" ] && echo "-L $MX_LOG_SLAVE_STATUS_INTERVAL"` \
`[ -n "$MX_USER" ] && echo "-U $MX_USER"` \