| 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; |
|
6
|
|
|
|
|
|
|
|
|
7
|
15
|
|
|
15
|
|
392002
|
use strict; |
|
|
15
|
|
|
|
|
37
|
|
|
|
15
|
|
|
|
|
599
|
|
|
8
|
15
|
|
|
15
|
|
79
|
use vars qw($VERSION @Plugins); |
|
|
15
|
|
|
|
|
26
|
|
|
|
15
|
|
|
|
|
850
|
|
|
9
|
15
|
|
|
15
|
|
74
|
use Carp; |
|
|
15
|
|
|
|
|
30
|
|
|
|
15
|
|
|
|
|
29352
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$VERSION = "2.16"; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
@Plugins = qw( |
|
14
|
|
|
|
|
|
|
Authen::SASL::XS |
|
15
|
|
|
|
|
|
|
Authen::SASL::Cyrus |
|
16
|
|
|
|
|
|
|
Authen::SASL::Perl |
|
17
|
|
|
|
|
|
|
); |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub import { |
|
21
|
17
|
|
|
17
|
|
13643
|
shift; |
|
22
|
17
|
50
|
|
|
|
107
|
return unless @_; |
|
23
|
|
|
|
|
|
|
|
|
24
|
17
|
|
|
|
|
79
|
local $SIG{__DIE__}; |
|
25
|
17
|
50
|
|
|
|
43
|
@Plugins = grep { /^[:\w]+$/ and eval "require $_" } map { /::/ ? $_ : "Authen::SASL::$_" } @_ |
|
|
17
|
50
|
|
|
|
1186
|
|
|
|
17
|
50
|
|
|
|
130
|
|
|
26
|
|
|
|
|
|
|
or croak "no valid Authen::SASL plugins found"; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub new { |
|
31
|
48
|
|
|
48
|
1
|
34033
|
my $pkg = shift; |
|
32
|
48
|
50
|
|
|
|
319
|
my %opt = ((@_ % 2 ? 'mechanism' : ()), @_); |
|
33
|
|
|
|
|
|
|
|
|
34
|
48
|
|
33
|
|
|
932
|
my $self = bless { |
|
35
|
|
|
|
|
|
|
mechanism => $opt{mechanism} || $opt{mech}, |
|
36
|
|
|
|
|
|
|
callback => {}, |
|
37
|
|
|
|
|
|
|
debug => $opt{debug}, |
|
38
|
|
|
|
|
|
|
}, $pkg; |
|
39
|
|
|
|
|
|
|
|
|
40
|
48
|
50
|
|
|
|
365
|
$self->callback(%{$opt{callback}}) if ref($opt{callback}) eq 'HASH'; |
|
|
48
|
|
|
|
|
234
|
|
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Compat |
|
43
|
48
|
50
|
|
|
|
155
|
$self->callback(user => ($self->{user} = $opt{user})) if exists $opt{user}; |
|
44
|
48
|
50
|
|
|
|
141
|
$self->callback(pass => $opt{password}) if exists $opt{password}; |
|
45
|
48
|
50
|
|
|
|
137
|
$self->callback(pass => $opt{response}) if exists $opt{response}; |
|
46
|
|
|
|
|
|
|
|
|
47
|
48
|
|
|
|
|
167
|
$self; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub mechanism { |
|
52
|
77
|
|
|
77
|
1
|
12540
|
my $self = shift; |
|
53
|
77
|
50
|
|
|
|
510
|
@_ ? $self->{mechanism} = shift |
|
54
|
|
|
|
|
|
|
: $self->{mechanism}; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub callback { |
|
58
|
99
|
|
|
99
|
1
|
152
|
my $self = shift; |
|
59
|
|
|
|
|
|
|
|
|
60
|
99
|
50
|
|
|
|
248
|
return $self->{callback}{$_[0]} if @_ == 1; |
|
61
|
|
|
|
|
|
|
|
|
62
|
99
|
|
|
|
|
290
|
my %new = @_; |
|
63
|
99
|
|
|
|
|
228
|
@{$self->{callback}}{keys %new} = values %new; |
|
|
99
|
|
|
|
|
784
|
|
|
64
|
|
|
|
|
|
|
|
|
65
|
99
|
|
|
|
|
1187
|
$self->{callback}; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# The list of packages should not really be hardcoded here |
|
69
|
|
|
|
|
|
|
# We need some way to discover what plugins are installed |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub client_new { # $self, $service, $host, $secflags |
|
72
|
33
|
|
|
33
|
1
|
105
|
my $self = shift; |
|
73
|
|
|
|
|
|
|
|
|
74
|
33
|
|
|
|
|
51
|
my $err; |
|
75
|
33
|
|
|
|
|
254
|
foreach my $pkg (@Plugins) { |
|
76
|
33
|
50
|
33
|
|
|
2286
|
if (eval "require $pkg" and $pkg->can("client_new")) { |
|
77
|
33
|
50
|
|
|
|
79
|
if ($self->{conn} = eval { $pkg->client_new($self, @_) }) { |
|
|
33
|
|
|
|
|
166
|
|
|
78
|
33
|
|
|
|
|
131
|
return $self->{conn}; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
0
|
|
|
|
|
0
|
$err = $@; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
0
|
|
0
|
|
|
0
|
croak $err || "Cannot find a SASL Connection library"; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub server_new { # $self, $service, $host, $secflags |
|
88
|
18
|
|
|
18
|
1
|
3240
|
my $self = shift; |
|
89
|
|
|
|
|
|
|
|
|
90
|
18
|
|
|
|
|
30
|
my $err; |
|
91
|
18
|
|
|
|
|
46
|
foreach my $pkg (@Plugins) { |
|
92
|
18
|
50
|
33
|
|
|
982
|
if (eval "require $pkg" and $pkg->can("server_new")) { |
|
93
|
18
|
50
|
|
|
|
31
|
if ($self->{conn} = eval { $pkg->server_new($self, @_) } ) { |
|
|
18
|
|
|
|
|
82
|
|
|
94
|
18
|
|
|
|
|
66
|
return $self->{conn}; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
0
|
|
|
|
|
|
$err = $@; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
} |
|
99
|
0
|
|
0
|
|
|
|
croak $err || "Cannot find a SASL Connection library for server-side authentication"; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub error { |
|
103
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
104
|
0
|
0
|
|
|
|
|
$self->{conn} && $self->{conn}->error; |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# Compat. |
|
108
|
|
|
|
|
|
|
sub user { |
|
109
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
110
|
0
|
|
|
|
|
|
my $user = $self->{callback}{user}; |
|
111
|
0
|
0
|
|
|
|
|
$self->{callback}{user} = shift if @_; |
|
112
|
0
|
|
|
|
|
|
$user; |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub challenge { |
|
116
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
117
|
0
|
|
|
|
|
|
$self->{conn}->client_step(@_); |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub initial { |
|
121
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
122
|
0
|
|
|
|
|
|
$self->client_new($self)->client_start; |
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub name { |
|
126
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
127
|
0
|
0
|
|
|
|
|
$self->{conn} ? $self->{conn}->mechanism : ($self->{mechanism} =~ /(\S+)/)[0]; |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
1; |