| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Copyright (c) 2004-2006 Graham Barr . All rights reserved. |
|
2
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or |
|
3
|
|
|
|
|
|
|
# modify it under the same terms as Perl itself. |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Authen::SASL 2.2000; |
|
6
|
|
|
|
|
|
|
|
|
7
|
16
|
|
|
16
|
|
2055290
|
use strict; |
|
|
16
|
|
|
|
|
30
|
|
|
|
16
|
|
|
|
|
603
|
|
|
8
|
16
|
|
|
16
|
|
152
|
use warnings; |
|
|
16
|
|
|
|
|
26
|
|
|
|
16
|
|
|
|
|
971
|
|
|
9
|
16
|
|
|
16
|
|
88
|
use vars qw(@Plugins); |
|
|
16
|
|
|
|
|
43
|
|
|
|
16
|
|
|
|
|
995
|
|
|
10
|
16
|
|
|
16
|
|
79
|
use Carp; |
|
|
16
|
|
|
|
|
49
|
|
|
|
16
|
|
|
|
|
17355
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
@Plugins = qw( |
|
14
|
|
|
|
|
|
|
Authen::SASL::XS |
|
15
|
|
|
|
|
|
|
Authen::SASL::Perl |
|
16
|
|
|
|
|
|
|
); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub import { |
|
20
|
18
|
|
|
18
|
|
455976
|
shift; |
|
21
|
18
|
100
|
|
|
|
1380
|
return unless @_; |
|
22
|
|
|
|
|
|
|
|
|
23
|
17
|
|
|
|
|
80
|
local $SIG{__DIE__}; |
|
24
|
17
|
50
|
|
|
|
41
|
@Plugins = grep { /^[:\w]+$/ and eval "require $_" } map { /::/ ? $_ : "Authen::SASL::$_" } @_ |
|
|
17
|
50
|
|
|
|
1195
|
|
|
|
17
|
50
|
|
|
|
159
|
|
|
25
|
|
|
|
|
|
|
or croak "no valid Authen::SASL plugins found"; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub new { |
|
30
|
53
|
|
|
53
|
1
|
1946210
|
my $pkg = shift; |
|
31
|
53
|
100
|
|
|
|
292
|
my %opt = ((@_ % 2 ? 'mechanism' : ()), @_); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $self = bless { |
|
34
|
|
|
|
|
|
|
mechanism => $opt{mechanism} || $opt{mech}, |
|
35
|
|
|
|
|
|
|
callback => {}, |
|
36
|
|
|
|
|
|
|
debug => $opt{debug}, |
|
37
|
53
|
|
100
|
|
|
348
|
}, $pkg; |
|
38
|
|
|
|
|
|
|
|
|
39
|
53
|
100
|
|
|
|
241
|
$self->callback(%{$opt{callback}}) if ref($opt{callback}) eq 'HASH'; |
|
|
49
|
|
|
|
|
233
|
|
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Compat |
|
42
|
53
|
50
|
|
|
|
172
|
$self->callback(user => ($self->{user} = $opt{user})) if exists $opt{user}; |
|
43
|
53
|
100
|
|
|
|
137
|
$self->callback(pass => $opt{password}) if exists $opt{password}; |
|
44
|
53
|
50
|
|
|
|
145
|
$self->callback(pass => $opt{response}) if exists $opt{response}; |
|
45
|
|
|
|
|
|
|
|
|
46
|
53
|
|
|
|
|
193
|
$self; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub mechanism { |
|
51
|
80
|
|
|
80
|
1
|
10224
|
my $self = shift; |
|
52
|
|
|
|
|
|
|
@_ ? $self->{mechanism} = shift |
|
53
|
80
|
50
|
|
|
|
496
|
: $self->{mechanism}; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub callback { |
|
57
|
198
|
|
|
198
|
1
|
312
|
my $self = shift; |
|
58
|
|
|
|
|
|
|
|
|
59
|
198
|
50
|
|
|
|
501
|
return $self->{callback}{$_[0]} if @_ == 1; |
|
60
|
|
|
|
|
|
|
|
|
61
|
198
|
|
|
|
|
375
|
my %new = @_; |
|
62
|
198
|
|
|
|
|
363
|
@{$self->{callback}}{keys %new} = values %new; |
|
|
198
|
|
|
|
|
529
|
|
|
63
|
|
|
|
|
|
|
|
|
64
|
198
|
|
|
|
|
1439
|
$self->{callback}; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# The list of packages should not really be hardcoded here |
|
68
|
|
|
|
|
|
|
# We need some way to discover what plugins are installed |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub client_new { # $self, $service, $host, $secflags |
|
71
|
36
|
|
|
36
|
1
|
104
|
my $self = shift; |
|
72
|
|
|
|
|
|
|
|
|
73
|
36
|
|
|
|
|
66
|
my $err; |
|
74
|
36
|
|
|
|
|
87
|
foreach my $pkg (@Plugins) { |
|
75
|
37
|
100
|
66
|
|
|
2634
|
if (eval "require $pkg" and $pkg->can("client_new")) { |
|
76
|
36
|
50
|
|
|
|
82
|
if ($self->{conn} = eval { $pkg->client_new($self, @_) }) { |
|
|
36
|
|
|
|
|
207
|
|
|
77
|
36
|
|
|
|
|
210
|
return $self->{conn}; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
0
|
|
|
|
|
0
|
$err = $@; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
0
|
|
0
|
|
|
0
|
croak $err || "Cannot find a SASL Connection library"; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub server_new { # $self, $service, $host, $secflags |
|
87
|
18
|
|
|
18
|
1
|
6744
|
my $self = shift; |
|
88
|
|
|
|
|
|
|
|
|
89
|
18
|
|
|
|
|
29
|
my $err; |
|
90
|
18
|
|
|
|
|
46
|
foreach my $pkg (@Plugins) { |
|
91
|
18
|
50
|
33
|
|
|
1162
|
if (eval "require $pkg" and $pkg->can("server_new")) { |
|
92
|
18
|
50
|
|
|
|
41
|
if ($self->{conn} = eval { $pkg->server_new($self, @_) } ) { |
|
|
18
|
|
|
|
|
73
|
|
|
93
|
18
|
|
|
|
|
156
|
return $self->{conn}; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
0
|
|
|
|
|
0
|
$err = $@; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
} |
|
98
|
0
|
|
0
|
|
|
0
|
croak $err || "Cannot find a SASL Connection library for server-side authentication"; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub error { |
|
102
|
1
|
|
|
1
|
1
|
283
|
my $self = shift; |
|
103
|
1
|
50
|
|
|
|
4
|
$self->{conn} && $self->{conn}->error; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# Compat. |
|
107
|
|
|
|
|
|
|
sub user { |
|
108
|
3
|
|
|
3
|
0
|
7
|
my $self = shift; |
|
109
|
3
|
|
|
|
|
6
|
my $user = $self->{callback}{user}; |
|
110
|
3
|
100
|
|
|
|
6
|
$self->{callback}{user} = shift if @_; |
|
111
|
3
|
|
|
|
|
10
|
$user; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub challenge { |
|
115
|
1
|
|
|
1
|
0
|
522
|
my $self = shift; |
|
116
|
1
|
|
|
|
|
4
|
$self->{conn}->client_step(@_); |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub initial { |
|
120
|
1
|
|
|
1
|
0
|
3
|
my $self = shift; |
|
121
|
1
|
|
|
|
|
4
|
$self->client_new($self)->client_start; |
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub name { |
|
125
|
3
|
|
|
3
|
0
|
774
|
my $self = shift; |
|
126
|
3
|
100
|
100
|
|
|
20
|
$self->{conn} ? $self->{conn}->mechanism : (($self->{mechanism} || '') =~ /(\S+)/)[0]; |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
1; |