in reply to File::Temp::tempfile() fails under taint mode

Is $ENV{TMPDIR} set? Most likely, that is considered tainted and causes the tests to fail?

Replies are listed 'Best First'.
Re^2: File::Temp::tempfile() fails under taint mode
by Athanasius (Archbishop) on Apr 08, 2015 at 16:51 UTC

    Thanks Corion, that’s a good idea, but it turns out it’s not set:

    2:44 >perl -wE "say $ENV{TMPDIR};" Use of uninitialized value in say at -e line 1. 2:48 >

    Following your lead, I also tried unsetting (deleting) $ENV{TEMP} and $ENV{TMP}, but this made no difference either.

    Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

      Did you try setting $ENV{TEMP} in your test?

        Yes, this works! but only if I set $ENV{TEMP} within the Perl script that calls File::Temp::tempfile():

        12:25 >set TEMP=. 12:25 >set TEMP TEMP=. 12:26 >perl -T -MFile::Temp=tempfile -wE "say $ENV{TEMP}; tempfile();" . Error in tempfile() using template \XXXXXXXXXX: Could not create temp +file \JFwYM0_6Kz: Permission denied at -e line 1. 12:26 >perl -T -MFile::Temp=tempfile -wE "$ENV{TEMP} = '.'; say $ENV{T +EMP}; tempfile();" . 12:26 >

        So, I can get the tests for MooseX::App::Cmd to pass by hacking t/basic.t like this:

        SKIP: { my $have_TO = eval { require Test::Output; 1; }; print STDERR $@; skip 'these tests require Test::Output', 5 unless $have_TO; local @ARGV = qw(commands); my $temp = $ENV{TEMP}; # ADDED $ENV{TEMP} = '.'; # ADDED my ($output) = Test::Output::output_from( sub { $cmd->run } ); $ENV{TEMP} = $temp; # ADDED for my $name (qw(commands frobulate justusage stock bark)) { like( $output, qr/^\s+\Q$name\E/sm, "$name plugin in listing" +); } }

        But I still don’t have a way to tweak the environment so that MooseX::App::Cmd installs “out of the box.”

        Thanks for the help,

        Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,