@@ -14,7 +14,7 @@ use Time::HiRes qw/time/;
14
14
use File::Spec();
15
15
use File::Temp();
16
16
17
- use Test2::Harness::Util qw/ fqmod clean_path write_file_atomic write_file mod2file open_file parse_exit process_includes chmod_tmp/ ;
17
+ use Test2::Harness::Util qw/ fqmod clean_path write_file_atomic write_file mod2file open_file parse_exit process_includes chmod_tmp untaint / ;
18
18
use Test2::Harness::IPC;
19
19
20
20
use parent ' Test2::Harness::IPC::Process' ;
@@ -354,7 +354,7 @@ sub job_dir {
354
354
my $self = shift ;
355
355
return $self -> {+JOB_DIR} if $self -> {+JOB_DIR};
356
356
357
- my $job_dir = File::Spec-> catdir($self -> run_dir, $self -> {+TASK}-> {job_id } . ' +' . $self -> is_try);
357
+ my $job_dir = untaint( File::Spec-> catdir($self -> run_dir, $self -> {+TASK}-> {job_id } . ' +' . $self -> is_try) );
358
358
mkdir ($job_dir ) or die " $$ $0 Could not create job directory '$job_dir ': $! " ;
359
359
chmod_tmp($job_dir );
360
360
$self -> {+JOB_DIR} = $job_dir ;
@@ -415,8 +415,24 @@ sub use_fork {
415
415
return $self -> {+USE_FORK} = 0 if defined ($task -> {use_fork }) && !$task -> {use_fork };
416
416
return $self -> {+USE_FORK} = 0 if defined ($task -> {use_preload }) && !$task -> {use_preload };
417
417
418
- # -w switch is ok, otherwise it is a no-go
419
- return $self -> {+USE_FORK} = 0 if grep { !m /\s *-w\s */ } $self -> switches;
418
+ use Data::Dumper;
419
+ warn Dumper [ $self -> switches ];
420
+
421
+ # Ugh I hate this logic!!!
422
+
423
+ # This approach won't scale if we allow even more swiches.
424
+ my @allowed_switches = ' -w' ;
425
+
426
+ # Allow taint and taint + warnings if we're a tainted runner.
427
+ push @allowed_switches => qw/ -T -wT -Tw/ if ${^TAINT};
428
+
429
+ my $allowed_switches = join ' |' , map { quotemeta } @allowed_switches ;
430
+ my $allowed_switches_re = qr /\s *(?:$allowed_switches )\s */ ;
431
+
432
+ return $self -> {+USE_FORK} = 0 if grep { $_ !~ $allowed_switches_re } $self -> switches;
433
+
434
+ # We're running under the taint but the test hasn't requested taint.
435
+ return $self -> {+USE_FORK} = 0 if ${^TAINT} && !grep { / \s *-w?Tw?\s */ } $self -> switches;
420
436
421
437
my $runner = $self -> {+RUNNER};
422
438
return $self -> {+USE_FORK} = 0 unless $runner -> use_fork;
0 commit comments