line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Protocol::DBus::Authn::Mechanism::DBUS_COOKIE_SHA1::Pieces; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
707098
|
use strict; |
|
5
|
|
|
|
|
36
|
|
|
5
|
|
|
|
|
148
|
|
4
|
5
|
|
|
5
|
|
61
|
use warnings; |
|
5
|
|
|
|
|
15
|
|
|
5
|
|
|
|
|
140
|
|
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
29
|
use File::Spec (); |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
234
|
|
7
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
37
|
use constant KEYRINGS_DIR => '.dbus-keyrings'; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
2201
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $sha1_module; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub _sha1_module { |
13
|
3
|
|
66
|
3
|
|
25
|
return $sha1_module ||= do { |
14
|
2
|
50
|
|
|
|
5
|
if ( eval { require Digest::SHA1; 1 } ) { |
|
2
|
50
|
|
|
|
323
|
|
|
0
|
|
|
|
|
0
|
|
15
|
0
|
|
|
|
|
0
|
'Digest::SHA1'; |
16
|
|
|
|
|
|
|
} |
17
|
2
|
|
|
|
|
496
|
elsif ( eval { require Digest::SHA; 1 } ) { |
|
2
|
|
|
|
|
3019
|
|
18
|
2
|
|
|
|
|
68
|
'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
|
934
|
my $cl_challenge = join(',', map { rand } 1 .. 4 ); |
|
4
|
|
|
|
|
60
|
|
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
|
3
|
|
|
3
|
0
|
22
|
return _sha1_module()->can('sha1_hex')->(@_); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub get_cookie { |
40
|
5
|
|
|
5
|
0
|
10741
|
my ($homedir, $ck_ctx, $ck_id) = @_; |
41
|
|
|
|
|
|
|
|
42
|
5
|
|
|
|
|
69
|
my $path = File::Spec->catfile( |
43
|
|
|
|
|
|
|
$homedir, |
44
|
|
|
|
|
|
|
KEYRINGS_DIR(), |
45
|
|
|
|
|
|
|
$ck_ctx, |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
5
|
100
|
|
|
|
233
|
open my $rfh, '<', $path or die "open(< $path): $!"; |
49
|
|
|
|
|
|
|
|
50
|
4
|
|
|
|
|
85
|
while ( my $line = <$rfh> ) { |
51
|
6
|
|
|
|
|
20
|
chomp $line; |
52
|
|
|
|
|
|
|
|
53
|
6
|
100
|
|
|
|
40
|
next if 0 != index( $line, "$ck_id " ); |
54
|
|
|
|
|
|
|
|
55
|
3
|
|
|
|
|
63
|
return substr( $line, 1 + index($line, q< >, 2 + length($ck_id)) ); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
1
|
50
|
|
|
|
15
|
warn "readline: $!" if $!; |
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
28
|
die "Failed to find cookie “$ck_id” in “$path”!"; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |