From: Heiko Schlittermann (HS12-RIPE) Date: Mon, 1 Feb 2016 12:13:27 +0000 (+0100) Subject: Add perl_taintmode option X-Git-Url: https://git.exim.org/users/jgh/exim.git/commitdiff_plain/38d85dd18239ac5951fae2c61dcf7c037c666f00?ds=inline Add perl_taintmode option --- diff --git a/doc/doc-docbook/spec.xfpt b/doc/doc-docbook/spec.xfpt index cdca6c4b3..8a0c96753 100644 --- a/doc/doc-docbook/spec.xfpt +++ b/doc/doc-docbook/spec.xfpt @@ -12967,6 +12967,14 @@ overriding the setting of &%perl_at_start%&. There is also a command line option &%-pd%& (for delay) which suppresses the initial startup, even if &%perl_at_start%& is set. +.ilist +.oindex "&%perl_taintmode%&" +To provide more security executing Perl code via the embedded Perl +interpeter, the &%perl_taintmode%& option can be set. This enables the +taint mode of the Perl interpreter. You are encouraged to set this +option to a true value. To avoid breaking existing installations, it +defaults to false. + .section "Calling Perl subroutines" "SECID86" When the configuration file includes a &%perl_startup%& option you can make use @@ -13495,6 +13503,7 @@ listed in more than one group. .table2 .row &%perl_at_start%& "always start the interpreter" .row &%perl_startup%& "code to obey when starting Perl" +.row &%perl_taintmode%& "enable taint mode in Perl" .endtable @@ -15582,14 +15591,20 @@ local parts. Exim's default configuration does this. .option perl_at_start main boolean false +.cindex "Perl" This option is available only when Exim is built with an embedded Perl interpreter. See chapter &<>& for details of its use. .option perl_startup main string unset +.cindex "Perl" This option is available only when Exim is built with an embedded Perl interpreter. See chapter &<>& for details of its use. +.option perl_startup main boolean false +.cindex "Perl" +This Option enables the taint mode of the embedded Perl interpreter. + .option pgsql_servers main "string list" unset .cindex "PostgreSQL lookup type" "server list" diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index b48b7b988..1d1a5d9f5 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -287,6 +287,8 @@ JH/35 Bug 1642: Fix support of $spam_ variables at delivery time. Was JH/36 Bug 1659: Guard checking of input smtp commands again pseudo-command added for tls authenticator. +HS/03 Add perl_taintmode main config option + Exim version 4.85 ----------------- diff --git a/src/conf b/src/conf new file mode 100644 index 000000000..1619c0da8 --- /dev/null +++ b/src/conf @@ -0,0 +1,2 @@ +perl_startup = $| = 1; print "<${^TAINT}>\n"; +perl_taintmode = yes diff --git a/src/src/globals.c b/src/src/globals.c index 69f217642..adf87380e 100644 --- a/src/src/globals.c +++ b/src/src/globals.c @@ -49,6 +49,7 @@ duplicate them here... */ uschar *opt_perl_startup = NULL; BOOL opt_perl_at_start = FALSE; BOOL opt_perl_started = FALSE; +BOOL opt_perl_taintmode = FALSE; #endif #ifdef EXPAND_DLFUNC diff --git a/src/src/globals.h b/src/src/globals.h index 787de41f0..7f6537a9a 100644 --- a/src/src/globals.h +++ b/src/src/globals.h @@ -28,6 +28,7 @@ typedef volatile sig_atomic_t SIGNAL_BOOL; extern uschar *opt_perl_startup; /* Startup code for Perl interpreter */ extern BOOL opt_perl_at_start; /* Start Perl interpreter at start */ extern BOOL opt_perl_started; /* Set once interpreter started */ +extern BOOL opt_perl_taintmode; /* Enable taint mode in Perl */ #endif #ifdef EXPAND_DLFUNC diff --git a/src/src/perl.c b/src/src/perl.c index 543b5d27d..fbe9ee842 100644 --- a/src/src/perl.c +++ b/src/src/perl.c @@ -13,6 +13,7 @@ /* 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 #include "exim.h" #define EXIM_TRUE TRUE @@ -95,11 +96,17 @@ static void xs_init(pTHX) 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); diff --git a/src/src/readconf.c b/src/src/readconf.c index 9de064d95..2dfc9af8e 100644 --- a/src/src/readconf.c +++ b/src/src/readconf.c @@ -344,6 +344,7 @@ static optionlist optionlist_config[] = { #ifdef EXIM_PERL { "perl_at_start", opt_bool, &opt_perl_at_start }, { "perl_startup", opt_stringptr, &opt_perl_startup }, + { "perl_taintmode", opt_bool, &opt_perl_taintmode }, #endif #ifdef LOOKUP_PGSQL { "pgsql_servers", opt_stringptr, &pgsql_servers },