blib/lib/Unix/SavedIDs.pm

filter: Statementstmt 58.3% 28 / 48 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 72.7% 8 / 11 Podpod 100% 2 / 2 totaltotal 50.0% 38 / 76 CC 8 SCAR 27.6
CC
8
Cov
46%
_clean_args
42.0
setresuid
6.0
setresgid
6.0
CRAP 15.8
« blib/lib/Unix/SetUser.pm ↑ Summary lib/Unix/SavedIDs.xs »
1 package Unix::SavedIDs;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 TYPE_UID => 0,
9 TYPE_GID => 1,
10 4 };
11  
12 4 our $DEBUG = 0;
13  
14 4 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 4 ▶ use Exporter ();
Subroutine BEGIN: called CC=1 SCAR=0.0
17 4 our ($VERSION,@ISA,@EXPORT);
18 4 @ISA = qw(Exporter);
19 4 @EXPORT = qw(getresuid getresgid setresuid setresgid
20 );
21 4 $VERSION = 0.004003;
22 4 ▶ use XSLoader;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 4 XSLoader::load('Unix::SavedIDs',$VERSION);
24 }
25  
26 0 ▶sub setresuid {
Subroutine setresuid: not called CC=2 SCAR=17.9
Pod documented
27 0 my @args = eval {_clean_args(@_) };
28 0 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
29 0 croak "setresuid(): $@";
30 }
31 0 _setresuid(@args);
32 }
33  
34 0 ▶sub setresgid {
Subroutine setresgid: not called CC=2 SCAR=17.9
Pod documented
35 0 my @args = eval {_clean_args(@_) };
36 0 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
37 0 croak "setresgid(): $@";
38 }
39 0 _setresgid(@args);
40 }
41  
42 0 ▶sub _clean_args {
Subroutine _clean_args: not called CC=6 SCAR=37.4
43 0 my @args = @_;
44 0 my $is_int = qr/^-?\d+$/o;
45 0 for my $num ( 0 .. 2 ) {
46 0 ▶ if ( !exists($args[$num]) || !defined($args[$num]) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $args[$num] && defined $args[$num]) { } 0 0 0
Condition0%0/3
exists $args[$num] && defined $args[$num]
!ll&&!rl&&r
000
MC/DC0%0/2
exists $args[$num] && defined $args[$num]
exists $args[$num] defined $args[$num]
Truth table0%0/3
A && B
A= exists $args[$num]B= defined $args[$num]
ABresult
0X0
100
111
47 0 $args[$num] = -1;
48 }
49 else {
50 0 ▶ if ( $args[$num] !~ $is_int ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($args[$num] =~ /$is_int/) 0 0 0
51 0 croak 'bad arg \''.$args[$num].'\'. Must be int.'."\n";
52 }
53 }
54 }
55 0 ▶ if (@args != 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args != 3) 0 0 0
56 0 die "_clean_args should always produce 3 args. THIS IS A BUG!";
57 }
58 0 return @args;
59 }
60  
61 4 1;
62  
63 __END__
« blib/lib/Unix/SetUser.pm ↑ Summary lib/Unix/SavedIDs.xs »