BATsh
view release on metacpan or search on metacpan
t/0019-tempfile-security.t view on Meta::CPAN
# internal helper directly and check the mode of what it created.
sub {
if (!$POSIX_SEMANTICS) {
_ok(1, "TS02: skipped (POSIX mode bits not meaningful on $^O)");
return;
}
no strict 'refs';
my $path = &{"BATsh::SH::_subst_tempfile"}();
my $ok = 0;
if (defined $path && -f $path) {
my @st = stat($path);
$ok = (($st[2] & 07777) == 0600) ? 1 : 0;
}
close(*BATsh::SH::_SUBST_CAPFH) if defined fileno(*BATsh::SH::_SUBST_CAPFH);
unlink $path if defined $path;
_ok($ok, 'TS02: subst capture file created with mode 0600');
},
##################################################################
# 3. SH pipeline: symlink race
##################################################################
t/0019-tempfile-security.t view on Meta::CPAN
sub {
if (!$POSIX_SEMANTICS) {
_ok(1, "TS04: skipped (POSIX mode bits not meaningful on $^O)");
return;
}
no strict 'refs';
my $stub = File::Spec->catfile($TMPDIR, "batsh_shp19_$$");
my $path = &{"BATsh::SH::_shp_tempfile"}($stub);
my $ok = 0;
if (defined $path && -f $path) {
my @st = stat($path);
$ok = (($st[2] & 07777) == 0600) ? 1 : 0;
}
close(*BATsh::SH::_SH_PIPE_WFH) if defined fileno(*BATsh::SH::_SH_PIPE_WFH);
unlink $path if defined $path;
_ok($ok, 'TS04: pipe stage file created with mode 0600');
},
##################################################################
# 5. No leftover temp files after a normal run
##################################################################
( run in 3.377 seconds using v1.01-cache-2.11-cpan-14f38c9f855 )