line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 2012 by [Mark Overmeer]. |
2
|
|
|
|
|
|
|
# For other contributors see ChangeLog. |
3
|
|
|
|
|
|
|
# See the manual pages for details on the licensing terms. |
4
|
|
|
|
|
|
|
# Pod stripped from pm file by OODoc 2.00. |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
1190
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
7
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package Mozilla::Persona::Validate::Htpasswd; |
10
|
1
|
|
|
1
|
|
6
|
use vars '$VERSION'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
58
|
|
11
|
|
|
|
|
|
|
$VERSION = '0.12'; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
5
|
use base 'Mozilla::Persona::Validate'; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
80
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
5
|
use Log::Report qw/persona/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
12
|
|
16
|
1
|
|
|
1
|
|
268
|
use Apache::Htpasswd (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
335
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub init($) |
20
|
0
|
|
|
0
|
0
|
|
{ my ($self, $args) = @_; |
21
|
|
|
|
|
|
|
|
22
|
0
|
0
|
|
|
|
|
my $fn = $args->{pwfile} or panic; |
23
|
0
|
|
|
|
|
|
$self->openFile($fn); # pre-load |
24
|
0
|
|
|
|
|
|
$self; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
#------------ |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
0
|
1
|
|
sub pwfile() {shift->{MPVH_fn}} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub openFile(;$) |
32
|
0
|
|
|
0
|
0
|
|
{ my ($self, $fn) = @_; |
33
|
|
|
|
|
|
|
|
34
|
0
|
0
|
|
|
|
|
if($fn) { $self->{MPVH_fn} = $fn } |
|
0
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
else { $fn = $self->{MPVH_fn} } |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my $mtime = (stat $fn)[9]; |
38
|
0
|
0
|
|
|
|
|
defined $mtime |
39
|
|
|
|
|
|
|
or fault __x"htpasswd file {fn}"; |
40
|
|
|
|
|
|
|
|
41
|
0
|
0
|
|
|
|
|
if(my $last_mtime = $self->{MPVH_mtime}) |
42
|
0
|
0
|
|
|
|
|
{ return $self->{MPVH_info} if $mtime eq $last_mtime; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
my $info = $self->{MPVH_info} = Apache::Htpasswd |
46
|
|
|
|
|
|
|
->new({passwdFile => $fn, ReadOnly => 1}); |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
$self->{MPVH_mtime} = $mtime; |
49
|
0
|
|
|
|
|
|
$info; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub isValid($$) |
53
|
0
|
|
|
0
|
1
|
|
{ my ($self, $user, $password) = @_; |
54
|
0
|
|
|
|
|
|
$self->openFile->htCheckPassword($user, $password); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |