| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# (C) 1998 Mike Shoyher , |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Authen::TacacsPlus; |
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
4560
|
use strict; |
|
|
1
|
|
|
|
|
8
|
|
|
|
1
|
|
|
|
|
24
|
|
|
7
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
44
|
|
|
8
|
1
|
|
|
1
|
|
4
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $AUTOLOAD); |
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
712
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
require Exporter; |
|
11
|
|
|
|
|
|
|
require DynaLoader; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
@ISA = qw(Exporter DynaLoader); |
|
14
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
|
15
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
|
16
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
|
17
|
|
|
|
|
|
|
@EXPORT_OK = qw( |
|
18
|
|
|
|
|
|
|
TACPLUS_CLIENT |
|
19
|
|
|
|
|
|
|
); |
|
20
|
|
|
|
|
|
|
$VERSION = '0.27'; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new |
|
23
|
|
|
|
|
|
|
{ |
|
24
|
1
|
|
|
1
|
0
|
110
|
my $class = shift; |
|
25
|
1
|
|
|
|
|
3
|
my %h; |
|
26
|
1
|
|
|
|
|
2
|
my $self = {}; |
|
27
|
1
|
|
|
|
|
2
|
bless $self, $class; |
|
28
|
1
|
|
|
|
|
7
|
$self->{'servers'} = []; |
|
29
|
1
|
50
|
|
|
|
5
|
if (ref $_[0] eq 'ARRAY') { |
|
30
|
0
|
|
|
|
|
0
|
%h = @{ $_[0] }; |
|
|
0
|
|
|
|
|
0
|
|
|
31
|
0
|
|
|
|
|
0
|
shift @_; |
|
32
|
0
|
|
|
|
|
0
|
push @{ $self->{'servers'} }, @_; |
|
|
0
|
|
|
|
|
0
|
|
|
33
|
|
|
|
|
|
|
} else { |
|
34
|
1
|
|
|
|
|
5
|
%h = @_; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
1
|
|
|
|
|
2
|
my $res=-1; |
|
37
|
1
|
50
|
|
|
|
4
|
$self->{'timeout'} = $h{'Timeout'} ? $h{'Timeout'} : 15; |
|
38
|
1
|
50
|
|
|
|
3
|
$self->{'port'} = $h{'Port'} ? $h{'Port'} : 'tacacs'; |
|
39
|
1
|
|
|
|
|
2
|
$self->{'host'} = $h{'Host'}; |
|
40
|
1
|
|
|
|
|
3
|
$self->{'key'} = $h{'Key'}; |
|
41
|
|
|
|
|
|
|
$res=init_tac_session($self->{'host'},$self->{'port'}, |
|
42
|
1
|
|
|
|
|
39094
|
$self->{'key'},$self->{'timeout'}); |
|
43
|
1
|
50
|
|
|
|
15
|
if ($res<0) { |
|
44
|
1
|
|
|
|
|
5
|
my $s = $self->{'servers'}; |
|
45
|
1
|
|
|
|
|
6
|
while ($s->[0]) { |
|
46
|
0
|
|
|
|
|
0
|
my %h = @{ $s->[0] }; |
|
|
0
|
|
|
|
|
0
|
|
|
47
|
0
|
|
|
|
|
0
|
shift @{ $s }; |
|
|
0
|
|
|
|
|
0
|
|
|
48
|
|
|
|
|
|
|
$res=init_tac_session( $h{'Host'}, |
|
49
|
|
|
|
|
|
|
$h{'Port'} ? $h{'Port'} : 'tacacs', |
|
50
|
|
|
|
|
|
|
$h{'Key'}, |
|
51
|
0
|
0
|
|
|
|
0
|
$h{'Timeout'} ? $h{'Timeout'} : 15 |
|
|
|
0
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
); |
|
53
|
0
|
0
|
|
|
|
0
|
$self->{'open'} = 1 if ($res >= 0); |
|
54
|
0
|
0
|
|
|
|
0
|
last if ($res >= 0); |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
} |
|
57
|
1
|
50
|
|
|
|
14
|
undef $self if ($res < 0); |
|
58
|
1
|
|
|
|
|
27
|
$self; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# Third arg authen_type is optional, defaults to |
|
62
|
|
|
|
|
|
|
# TAC_PLUS_AUTHEN_TYPE_ASCII |
|
63
|
|
|
|
|
|
|
sub authen |
|
64
|
|
|
|
|
|
|
{ |
|
65
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
66
|
0
|
|
|
|
|
0
|
my $username = shift; |
|
67
|
0
|
|
|
|
|
0
|
my $password = shift; |
|
68
|
0
|
|
0
|
|
|
0
|
my $authen_type = shift || &Authen::TacacsPlus::TAC_PLUS_AUTHEN_TYPE_ASCII; |
|
69
|
0
|
|
|
|
|
0
|
my $res=make_auth($username,$password,$authen_type); |
|
70
|
0
|
0
|
0
|
|
|
0
|
unless ($res || errmsg() =~ /Authentication failed/) { |
|
71
|
0
|
|
|
|
|
0
|
my $s = $self->{'servers'}; |
|
72
|
0
|
|
|
|
|
0
|
while ($s->[0]) { |
|
73
|
0
|
|
|
|
|
0
|
my %h = @{ $s->[0] }; |
|
|
0
|
|
|
|
|
0
|
|
|
74
|
0
|
|
|
|
|
0
|
shift @{ $s }; |
|
|
0
|
|
|
|
|
0
|
|
|
75
|
|
|
|
|
|
|
my $ret=init_tac_session( $h{'Host'}, |
|
76
|
|
|
|
|
|
|
$h{'Port'} ? $h{'Port'} : 'tacacs', |
|
77
|
|
|
|
|
|
|
$h{'Key'}, |
|
78
|
0
|
0
|
|
|
|
0
|
$h{'Timeout'} ? $h{'Timeout'} : 15 |
|
|
|
0
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
); |
|
80
|
0
|
0
|
|
|
|
0
|
next if ($ret < 0); |
|
81
|
0
|
|
|
|
|
0
|
$res=make_auth($username,$password,$authen_type); |
|
82
|
0
|
0
|
|
|
|
0
|
last if $res; |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
} |
|
86
|
0
|
|
|
|
|
0
|
$res; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub close |
|
90
|
|
|
|
|
|
|
{ |
|
91
|
1
|
|
|
1
|
0
|
3
|
my ($self) = @_; |
|
92
|
|
|
|
|
|
|
|
|
93
|
1
|
50
|
|
|
|
11
|
if ($self->{'open'}) |
|
94
|
|
|
|
|
|
|
{ |
|
95
|
0
|
|
|
|
|
0
|
deinit_tac_session(); |
|
96
|
0
|
|
|
|
|
0
|
$self->{'open'} = 0; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub DESTROY |
|
101
|
|
|
|
|
|
|
{ |
|
102
|
1
|
|
|
1
|
|
6
|
my ($self) = @_; |
|
103
|
|
|
|
|
|
|
|
|
104
|
1
|
|
|
|
|
6
|
$self->close(); |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub AUTOLOAD { |
|
109
|
|
|
|
|
|
|
# This AUTOLOAD is used to 'autoload' constants from the constant() |
|
110
|
|
|
|
|
|
|
# XS function. If a constant is not found then control is passed |
|
111
|
|
|
|
|
|
|
# to the AUTOLOAD in AutoLoader. |
|
112
|
|
|
|
|
|
|
|
|
113
|
0
|
|
|
0
|
|
|
my $constname; |
|
114
|
0
|
|
|
|
|
|
($constname = $AUTOLOAD) =~ s/.*:://; |
|
115
|
0
|
0
|
|
|
|
|
my $val = constant($constname, @_ ? $_[0] : 0); |
|
116
|
0
|
0
|
|
|
|
|
if ($! != 0) { |
|
117
|
0
|
0
|
|
|
|
|
if ($! =~ /Invalid/) { |
|
118
|
0
|
|
|
|
|
|
$AutoLoader::AUTOLOAD = $AUTOLOAD; |
|
119
|
0
|
|
|
|
|
|
goto &AutoLoader::AUTOLOAD; |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
else { |
|
122
|
0
|
|
|
|
|
|
croak "Your vendor has not defined Authen::TacacsPlus macro $constname"; |
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
} |
|
125
|
0
|
|
|
|
|
|
eval "sub $AUTOLOAD { $val }"; |
|
126
|
0
|
|
|
|
|
|
goto &$AUTOLOAD; |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
bootstrap Authen::TacacsPlus $VERSION; |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
# Preloaded methods go here. |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
# Autoload methods go after =cut, and are processed by the autosplit program. |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
1; |
|
136
|
|
|
|
|
|
|
__END__ |