-/* $Cambridge: exim/src/src/perl.c,v 1.2 2004/12/20 11:46:21 ph10 Exp $ */
-
/*************************************************
* Exim - an Internet mail transport agent *
*************************************************/
/* This Perl add-on can be distributed under the same terms as Exim itself. */
/* See the file NOTICE for conditions of use and distribution. */
+#include <assert.h>
#include "exim.h"
#define EXIM_TRUE TRUE
uschar *
init_perl(uschar *startup_code)
{
- static int argc = 2;
- static char *argv[3] = { "exim-perl", "/dev/null", 0 };
+ static int argc = 1;
+ static char *argv[4] = { "exim-perl" };
SV *sv;
STRLEN len;
+ if (opt_perl_taintmode) argv[argc++] = "-T";
+ argv[argc++] = "/dev/null";
+ argv[argc] = 0;
+
+ assert(sizeof(argv)/sizeof(argv[0]) > argc);
+
if (interp_perl) return 0;
interp_perl = perl_alloc();
perl_construct(interp_perl);
perl_run(interp_perl);
{
dSP;
+
+ /*********************************************************************/
+ /* These lines by PH added to make "warn" output go to the Exim log; I
+ hope this doesn't break anything. */
+
+ sv = newSVpv(
+ "$SIG{__WARN__} = sub { my($s) = $_[0];"
+ "$s =~ s/\\n$//;"
+ "Exim::log_write($s) };", 0);
+ PUSHMARK(SP);
+ perl_eval_sv(sv, G_SCALAR|G_DISCARD|G_KEEPERR);
+ SvREFCNT_dec(sv);
+ if (SvTRUE(ERRSV)) return US SvPV(ERRSV, len);
+ /*********************************************************************/
+
sv = newSVpv(CS startup_code, 0);
PUSHMARK(SP);
perl_eval_sv(sv, G_SCALAR|G_DISCARD|G_KEEPERR);
SvREFCNT_dec(sv);
if (SvTRUE(ERRSV)) return US SvPV(ERRSV, len);
+
+ setlocale(LC_ALL, "C"); /* In case it got changed */
return NULL;
}
}
return NULL;
}
str = US SvPV(sv, len);
- yield = string_cat(yield, sizep, ptrp, str, (int)len);
+ yield = string_catn(yield, sizep, ptrp, str, (int)len);
FREETMPS;
LEAVE;
-
+
setlocale(LC_ALL, "C"); /* In case it got changed */
return yield;
}