| 1 | package PAR::SetupTemp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 4 | $PAR::SetupTemp::VERSION = '1.002'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use 5.008009; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use Fcntl ':mode'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use PAR::SetupProgname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | PAR::SetupTemp - Setup $ENV{PAR_TEMP} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | PAR guts, beware. Check L<PAR> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | Routines to setup the C<PAR_TEMP> environment variable. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | The documentation of how the temporary directories are handled | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | is currently scattered across the C<PAR> manual and the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | C<PAR::Environment> manual. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | The C<set_par_temp_env()> subroutine sets up the C<PAR_TEMP> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | environment variable. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # for PAR internal use only! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 4 | our $PARTemp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # name of the canary file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 4 | our $Canary = "_CANARY_.txt"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | # how much to "date back" the canary file (in seconds) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 4 | our $CanaryDateBack = 24 * 3600; # 1 day | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # The C version of this code appears in myldr/mktmpdir.c | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | # This code also lives in PAR::Packer's par.pl as _set_par_temp! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 7 | ▶ | sub set_par_temp_env { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_par_temp_env: called CC=12 SCAR=38.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | PAR::SetupProgname::set_progname() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_par_temp_env: not called CC=12 SCAR=38.3
Pod
undocumented
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | unless defined $PAR::SetupProgname::Progname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | if (defined $ENV{PAR_TEMP} and $ENV{PAR_TEMP} =~ /(.+)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%2/6
defined $ENV{"PAR_TEMP"} and $ENV{"PAR_TEMP"} =~ /(.+)/
defined $ENV{"PAR_TEMP"} and $ENV{"PAR_TEMP"} =~ /(.+)/
MC/DC0%0/2
defined $ENV{"PAR_TEMP"} and $ENV{"PAR_TEMP"} =~ /(.+)/
defined $ENV{"PAR_TEMP"}
$ENV{"PAR_TEMP"} =~ /(.+)/
MC/DC50%1/2
defined $ENV{"PAR_TEMP"} and $ENV{"PAR_TEMP"} =~ /(.+)/
defined $ENV{"PAR_TEMP"}
$ENV{"PAR_TEMP"} =~ /(.+)/
Truth table0%0/3
A and B
A= defined $ENV{"PAR_TEMP"}B= $ENV{"PAR_TEMP"} =~ /(.+)/
Truth table66%2/3
A and B
A= defined $ENV{"PAR_TEMP"}B= $ENV{"PAR_TEMP"} =~ /(.+)/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | $PARTemp = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | my $stmpdir = _get_par_user_tempdir(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | die "unable to create cache directory" unless $stmpdir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | require File::Spec; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | if (!$ENV{PAR_CLEAN} and my $mtime = (stat($PAR::SetupProgname::Progname))[9]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%2/6
not $ENV{"PAR_CLEAN"} and my $mtime = (stat $PAR::SetupProgname::Progname)[9]
not $ENV{"PAR_CLEAN"} and my $mtime = (stat $PAR::SetupProgname::Progname)[9]
MC/DC0%0/2
not $ENV{"PAR_CLEAN"} and my $mtime = (stat $PAR::SetupProgname::Progname)[9]
not $ENV{"PAR_CLEAN"}
my $mtime = (stat $PAR::SetupProgname::Progname)[9]
MC/DC50%1/2
not $ENV{"PAR_CLEAN"} and my $mtime = (stat $PAR::SetupProgname::Progname)[9]
not $ENV{"PAR_CLEAN"}
my $mtime = (stat $PAR::SetupProgname::Progname)[9]
Truth table0%0/3
not(A) and B
A= not $ENV{"PAR_CLEAN"}B= my $mtime = (stat $PAR::SetupProgname::Progname)[9]
Truth table66%2/3
not(A) and B
A= not $ENV{"PAR_CLEAN"}B= my $mtime = (stat $PAR::SetupProgname::Progname)[9]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | require Digest::SHA; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | my $ctx = Digest::SHA->new(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | if ($ctx and open(my $fh, "<", $PAR::SetupProgname::Progname)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition16%1/6
$ctx and open my $fh, "<", $PAR::SetupProgname::Progname
$ctx and open my $fh, "<", $PAR::SetupProgname::Progname
MC/DC0%0/2
$ctx and open my $fh, "<", $PAR::SetupProgname::Progname
$ctx
open my $fh, "<", $PAR::SetupProgname::Progname
MC/DC0%0/2
$ctx and open my $fh, "<", $PAR::SetupProgname::Progname
$ctx
open my $fh, "<", $PAR::SetupProgname::Progname
Truth table0%0/3
A and B
A= $ctxB= open my $fh, "<", $PAR::SetupProgname::Progname
Truth table33%1/3
A and B
A= $ctxB= open my $fh, "<", $PAR::SetupProgname::Progname
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | binmode($fh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | $ctx->addfile($fh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | close($fh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | $stmpdir = File::Spec->catdir( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | $stmpdir, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | "cache-" . ( $ctx ? $ctx->hexdigest : $mtime ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | $ENV{PAR_CLEAN} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | $stmpdir = File::Spec->catdir($stmpdir, "temp-$$"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | $ENV{PAR_TEMP} = $stmpdir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | mkdir $stmpdir, 0700; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | $PARTemp = $1 if defined $ENV{PAR_TEMP} and $ENV{PAR_TEMP} =~ /(.+)/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition16%1/6
defined $ENV{"PAR_TEMP"} and $ENV{"PAR_TEMP"} =~ /(.+)/
defined $ENV{"PAR_TEMP"} and $ENV{"PAR_TEMP"} =~ /(.+)/
MC/DC0%0/2
defined $ENV{"PAR_TEMP"} and $ENV{"PAR_TEMP"} =~ /(.+)/
defined $ENV{"PAR_TEMP"}
$ENV{"PAR_TEMP"} =~ /(.+)/
MC/DC0%0/2
defined $ENV{"PAR_TEMP"} and $ENV{"PAR_TEMP"} =~ /(.+)/
defined $ENV{"PAR_TEMP"}
$ENV{"PAR_TEMP"} =~ /(.+)/
Truth table0%0/3
A and B
A= defined $ENV{"PAR_TEMP"}B= $ENV{"PAR_TEMP"} =~ /(.+)/
Truth table33%1/3
A and B
A= defined $ENV{"PAR_TEMP"}B= $ENV{"PAR_TEMP"} =~ /(.+)/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | # Find any digester | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | # Used in PAR::Repository::Client! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | sub _get_digester { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_digester: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | my $ctx = eval { require Digest::SHA; Digest::SHA->new(1) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | || eval { require Digest::SHA1; Digest::SHA1->new } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | || eval { require Digest::MD5; Digest::MD5->new }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_digester: not called CC=3 SCAR=24.8
Condition0%0/12
eval {
do {
require Digest::SHA;
'Digest::SHA'->new(1)
}
} || eval {
do {
require Digest::SHA1;
'Digest::SHA1'->new
}
} || eval {
do {
require Digest::MD5;
'Digest::MD5'->new
}
}
eval {
do {
require Digest::SHA;
"Digest::SHA"->new(1)
}
} or eval {
do {
require Digest::SHA1;
"Digest::SHA1"->new
}
}
eval {
do {
require Digest::SHA;
'Digest::SHA'->new(1)
}
} || eval {
do {
require Digest::SHA1;
'Digest::SHA1'->new
}
} || eval {
do {
require Digest::MD5;
'Digest::MD5'->new
}
}
eval {
do {
require Digest::SHA;
"Digest::SHA"->new(1)
}
} or eval {
do {
require Digest::SHA1;
"Digest::SHA1"->new
}
}
MC/DC0%0/3
eval {
do {
require Digest::SHA;
'Digest::SHA'->new(1)
}
} || eval {
do {
require Digest::SHA1;
'Digest::SHA1'->new
}
} || eval {
do {
require Digest::MD5;
'Digest::MD5'->new
}
}
eval {
do {
require Digest::SHA;
"Digest::SHA"->new(1)
}
}
eval {
do {
require Digest::SHA1;
"Digest::SHA1"->new
}
}
eval {
do {
require Digest::MD5;
'Digest::MD5'->new
}
}
MC/DC0%0/3
eval {
do {
require Digest::SHA;
'Digest::SHA'->new(1)
}
} || eval {
do {
require Digest::SHA1;
'Digest::SHA1'->new
}
} || eval {
do {
require Digest::MD5;
'Digest::MD5'->new
}
}
eval {
do {
require Digest::SHA;
"Digest::SHA"->new(1)
}
}
eval {
do {
require Digest::SHA1;
"Digest::SHA1"->new
}
}
eval {
do {
require Digest::MD5;
'Digest::MD5'->new
}
}
Truth table0%0/4
A or B || C
A= eval {
do {
require Digest::SHA;
"Digest::SHA"->new(1)
}
}B= eval {
do {
require Digest::SHA1;
"Digest::SHA1"->new
}
}C= eval {
do {
require Digest::MD5;
'Digest::MD5'->new
}
}
Truth table0%0/4
A or B || C
A= eval {
do {
require Digest::SHA;
"Digest::SHA"->new(1)
}
}B= eval {
do {
require Digest::SHA1;
"Digest::SHA1"->new
}
}C= eval {
do {
require Digest::MD5;
'Digest::MD5'->new
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | return $ctx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # find the per-user temporary directory (eg /tmp/par-$USER) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # Used in PAR::Repository::Client! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 4 | ▶ | sub _get_par_user_tempdir { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_par_user_tempdir: called CC=12 SCAR=42.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | my $username = _find_username(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_par_user_tempdir: not called CC=12 SCAR=42.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | my $temp_path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | foreach my $path ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | (map $ENV{$_}, qw( PAR_TMPDIR TMPDIR TEMPDIR TEMP TMP )), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | qw( C:\\TEMP /tmp . ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | next unless defined $path and -d $path and -w $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition16%2/12
defined $path and -d $path and -w $path
defined $path and -d $path
defined $path and -d $path and -w $path
defined $path and -d $path
MC/DC0%0/3
defined $path and -d $path and -w $path
defined $path
-d $path
-w $path
MC/DC0%0/3
defined $path and -d $path and -w $path
defined $path
-d $path
-w $path
Truth table0%0/4
A and B and C
A= defined $pathB= -d $pathC= -w $path
Truth table25%1/4
A and B and C
A= defined $pathB= -d $pathC= -w $path
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | # create a temp directory that is unique per user | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | # NOTE: $username may be in an unspecified charset/encoding; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # use a name that hopefully works for all of them; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | # also avoid problems with platform-specific meta characters in the name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | $temp_path = File::Spec->catdir($path, "par-".unpack("H*", $username)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ($temp_path) = $temp_path =~ /^(.*)$/s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | unless (mkdir($temp_path, 0700) || $!{EEXIST}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%2/6
mkdir $temp_path, 448 or $!{"EEXIST"}
mkdir $temp_path, 448 or $!{"EEXIST"}
MC/DC0%0/2
mkdir $temp_path, 448 or $!{"EEXIST"}
mkdir $temp_path, 448
$!{"EEXIST"}
MC/DC0%0/2
mkdir $temp_path, 448 or $!{"EEXIST"}
mkdir $temp_path, 448
$!{"EEXIST"}
Truth table0%0/3
A or B
A= mkdir $temp_path, 448B= $!{"EEXIST"}
Truth table66%2/3
A or B
A= mkdir $temp_path, 448B= $!{"EEXIST"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | warn "creation of private subdirectory $temp_path failed (errno=$!)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | unless ($^O eq 'MSWin32') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | my @st; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | unless (@st = lstat($temp_path)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | warn "stat of private subdirectory $temp_path failed (errno=$!)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | if (!S_ISDIR($st[2]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition16%2/12
not S_ISDIR($st[2]) or $st[4] != $< or ($st[2] & 511) != 448
not S_ISDIR($st[2]) or $st[4] != $<
not S_ISDIR($st[2]) or $st[4] != $< or ($st[2] & 511) != 448
not S_ISDIR($st[2]) or $st[4] != $<
MC/DC0%0/3
not S_ISDIR($st[2]) or $st[4] != $< or ($st[2] & 511) != 448
not S_ISDIR($st[2])
$st[4] != $<
($st[2] & 511) != 448
MC/DC0%0/3
not S_ISDIR($st[2]) or $st[4] != $< or ($st[2] & 511) != 448
not S_ISDIR($st[2])
$st[4] != $<
($st[2] & 511) != 448
Truth table0%0/4
not(A) or B or C
A= not S_ISDIR($st[2])B= $st[4] != $<C= ($st[2] & 511) != 448
Truth table25%1/4
not(A) or B or C
A= not S_ISDIR($st[2])B= $st[4] != $<C= ($st[2] & 511) != 448
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | || $st[4] != $< | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | || ($st[2] & 0777) != 0700 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | warn "private subdirectory $temp_path is unsafe (please remove it and retry your operation)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | return $temp_path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | # tries hard to find out the name of the current user | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 4 | ▶ | sub _find_username { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_find_username: called CC=6 SCAR=30.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | my $username; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_find_username: not called CC=6 SCAR=30.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | my $pwuid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | # does not work everywhere: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | eval {($pwuid) = getpwuid($>) if defined $>;}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | if ( defined(&Win32::LoginName) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | $username = &Win32::LoginName; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | elsif (defined $pwuid) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | $username = $pwuid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | $username = $ENV{USERNAME} || $ENV{USER} || 'SYSTEM'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/10
$ENV{'USERNAME'} || $ENV{'USER'} || 'SYSTEM'
$ENV{"USERNAME"} or $ENV{"USER"}
$ENV{'USERNAME'} || $ENV{'USER'} || 'SYSTEM'
$ENV{"USERNAME"} or $ENV{"USER"}
MC/DC0%0/2
$ENV{'USERNAME'} || $ENV{'USER'} || 'SYSTEM'
$ENV{"USERNAME"}
$ENV{"USER"}
MC/DC0%0/2
$ENV{'USERNAME'} || $ENV{'USER'} || 'SYSTEM'
$ENV{"USERNAME"}
$ENV{"USER"}
Truth table0%0/3
A or B
A= $ENV{"USERNAME"}B= $ENV{"USER"}
Truth table0%0/3
A or B
A= $ENV{"USERNAME"}B= $ENV{"USER"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | return $username; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||