line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Protocol::DBus::Authn::Mechanism::DBUS_COOKIE_SHA1::Pieces; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
851683
|
use strict; |
|
6
|
|
|
|
|
35
|
|
|
6
|
|
|
|
|
144
|
|
4
|
6
|
|
|
6
|
|
30
|
use warnings; |
|
6
|
|
|
|
|
6
|
|
|
6
|
|
|
|
|
120
|
|
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
24
|
use File::Spec (); |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
94
|
|
7
|
|
|
|
|
|
|
|
8
|
6
|
|
|
6
|
|
25
|
use constant KEYRINGS_DIR => '.dbus-keyrings'; |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
2595
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $sha1_module; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub _sha1_module { |
13
|
4
|
|
66
|
4
|
|
29
|
return $sha1_module ||= do { |
14
|
3
|
50
|
|
|
|
6
|
if ( eval { require Digest::SHA1; 1 } ) { |
|
3
|
50
|
|
|
|
395
|
|
|
0
|
|
|
|
|
0
|
|
15
|
0
|
|
|
|
|
0
|
'Digest::SHA1'; |
16
|
|
|
|
|
|
|
} |
17
|
3
|
|
|
|
|
433
|
elsif ( eval { require Digest::SHA; 1 } ) { |
|
3
|
|
|
|
|
2701
|
|
18
|
3
|
|
|
|
|
83
|
'Digest::SHA'; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
else { |
21
|
0
|
|
|
|
|
0
|
die "No SHA module available!"; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub create_challenge { |
27
|
1
|
|
|
1
|
0
|
841
|
my $cl_challenge = join(',', map { rand } 1 .. 4 ); |
|
4
|
|
|
|
|
48
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# Ensure that we use only hex characters for the challenge, |
30
|
|
|
|
|
|
|
# or else the challenge might have a colon, space, or something else |
31
|
|
|
|
|
|
|
# problematic. |
32
|
1
|
|
|
|
|
5
|
return sha1_hex($cl_challenge); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub sha1_hex { |
36
|
4
|
|
|
4
|
0
|
26
|
return _sha1_module()->can('sha1_hex')->(@_); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub get_cookie { |
40
|
6
|
|
|
6
|
0
|
9122
|
my ($homedir, $ck_ctx, $ck_id) = @_; |
41
|
|
|
|
|
|
|
|
42
|
6
|
|
|
|
|
85
|
my $path = File::Spec->catfile( |
43
|
|
|
|
|
|
|
$homedir, |
44
|
|
|
|
|
|
|
KEYRINGS_DIR(), |
45
|
|
|
|
|
|
|
$ck_ctx, |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
6
|
100
|
|
|
|
244
|
open my $rfh, '<', $path or die "open(< $path): $!"; |
49
|
|
|
|
|
|
|
|
50
|
5
|
|
|
|
|
117
|
while ( my $line = <$rfh> ) { |
51
|
7
|
|
|
|
|
20
|
chomp $line; |
52
|
|
|
|
|
|
|
|
53
|
7
|
100
|
|
|
|
48
|
next if 0 != index( $line, "$ck_id " ); |
54
|
|
|
|
|
|
|
|
55
|
4
|
|
|
|
|
114
|
return substr( $line, 1 + index($line, q< >, 2 + length($ck_id)) ); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
1
|
50
|
|
|
|
11
|
warn "readline: $!" if $!; |
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
38
|
die "Failed to find cookie “$ck_id” in “$path”!"; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |