LDAP/Secret.pm

filter: Statementstmt 52.1% 12 / 23 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 3 / 5 Podpod 0.0% 0 / 2 totaltotal 41.6% 15 / 36 CC 4 SCAR 18.5
CC
4
Cov
41%
read
12.0
read_secret
6.0
BEGIN
1.0
CRAP 6.4
« LDAP/Command/Add/Host.pm ↑ Summary LDAP/Command/Del/Sudoer.pm »
1 package App::LDAP::Secret;
2  
3 13 ▶use Modern::Perl;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 13 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 13 ▶use MooseX::Singleton;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 13 our @locations = qw(
8 /etc/ldap.secret
9 /etc/libnss-ldap.secret
10 /etc/pam_ldap.secret
11 );
12  
13 13 has secret => (
14 is => "rw",
15 isa => "Str",
16 );
17  
18 0 ▶sub read {
Subroutine read: not called CC=3 SCAR=24.8
Pod undocumented
19 0 my ($class, ) = @_;
20 0 my $self = $class->new;
21  
22 my $secret = read_secret(
23 grep {
24 0 ▶ -f $_
Branch: 1 branch
BranchTrueFalseTotal
$< == 0 ? : 0 0 0
25 } (
26 $< == 0 ?
27 @locations :
28 "$ENV{HOME}/.ldap.secret"
29 )
30 );
31  
32 0 ▶ $self->secret($secret) if $secret;
Branch: 1 branch
BranchTrueFalseTotal
if $secret 0 0 0
33 }
34  
35 0 ▶sub read_secret {
Subroutine read_secret: not called CC=2 SCAR=17.9
Pod undocumented
36 0 my $file = shift;
37 0 ▶ return undef unless $file;
Branch: 1 branch
BranchTrueFalseTotal
unless $file 0 0 0
38  
39 0 open FILE, " < $file";
40 0 my $secret = <FILE>;
41 0 chomp $secret;
42 0 return $secret;
43 }
44  
45 13 1;
46  
47 =pod
48  
49 =head1 NAME
50  
51 App::LDAP::Secret - loader of secret file
52  
53 =head1 DESCRIPTION
54  
55 this module would be called automatically in App::LDAP::run() to load the password for binding
56  
57 =cut
58  
« LDAP/Command/Add/Host.pm ↑ Summary LDAP/Command/Del/Sudoer.pm »