| 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
| |||||||||||
| 25 | } ( | ||||||||||
| 26 | $< == 0 ? | ||||||||||
| 27 | @locations : | ||||||||||
| 28 | "$ENV{HOME}/.ldap.secret" | ||||||||||
| 29 | ) | ||||||||||
| 30 | ); | ||||||||||
| 31 | |||||||||||
| 32 | 0 | ▶ | $self->secret($secret) if $secret; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 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 | |||||||||||