| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#! /usr/bin/perl |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# $Id: Match.pm 75 2009-08-12 22:08:28Z lem $ |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Net::Radius::Server::Match; |
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
1123
|
use 5.008; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
30
|
|
|
9
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
22
|
|
|
10
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
22
|
|
|
11
|
1
|
|
|
1
|
|
5
|
use Carp qw/croak/; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
50
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
4
|
use Net::Radius::Server::Base ':match'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
11
|
|
|
14
|
1
|
|
|
1
|
|
23
|
use base 'Net::Radius::Server::Base'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
276
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = do { sprintf "%0.3f", 1+(q$Revision: 75 $ =~ /\d+/g)[0]/1000 }; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub mk |
|
18
|
|
|
|
|
|
|
{ |
|
19
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
20
|
0
|
0
|
0
|
|
|
|
croak "->mk() cannot have arguments when in object-method mode\n" |
|
|
|
|
0
|
|
|
|
|
|
21
|
|
|
|
|
|
|
if ref($self) and $self->isa('UNIVERSAL') and @_; |
|
22
|
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
my $n = $self; |
|
24
|
|
|
|
|
|
|
|
|
25
|
0
|
0
|
|
|
|
|
if (@_) |
|
26
|
|
|
|
|
|
|
{ |
|
27
|
0
|
|
|
|
|
|
$n = $self->new(@_); |
|
28
|
0
|
0
|
|
|
|
|
die "Failed to create new object\n" unless $n; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
0
|
|
|
0
|
|
|
return sub { $n->_match(@_) }; |
|
|
0
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _match |
|
35
|
|
|
|
|
|
|
{ |
|
36
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
37
|
0
|
|
|
|
|
|
my $r_args = shift; |
|
38
|
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
for my $arg (sort keys %$self) |
|
40
|
|
|
|
|
|
|
{ |
|
41
|
0
|
|
|
|
|
|
my $n = NRS_MATCH_OK; |
|
42
|
0
|
0
|
|
|
|
|
next if $arg =~ /^_/; |
|
43
|
0
|
0
|
|
|
|
|
if ($self->can('match_' . $arg)) |
|
44
|
|
|
|
|
|
|
{ |
|
45
|
1
|
|
|
1
|
|
4
|
no strict 'refs'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
272
|
|
|
46
|
0
|
|
|
|
|
|
my $m = 'match_' . $arg; |
|
47
|
0
|
|
|
|
|
|
$self->log(4, "Invoking match method $m"); |
|
48
|
0
|
|
|
|
|
|
$n = $self->$m($r_args, @_); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
0
|
0
|
|
|
|
|
unless ($n == NRS_MATCH_OK) |
|
51
|
|
|
|
|
|
|
{ |
|
52
|
0
|
0
|
|
|
|
|
if ($r_args->{dict}) |
|
53
|
|
|
|
|
|
|
{ |
|
54
|
0
|
|
0
|
|
|
|
$self->log(2, "Fail request from " . |
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
55
|
|
|
|
|
|
|
($r_args->{request}->attr |
|
56
|
|
|
|
|
|
|
($r_args->{dict}->attr_name(4)) |
|
57
|
|
|
|
|
|
|
|| '(no NAS-IP-Address)') |
|
58
|
|
|
|
|
|
|
. " [" . ($r_args->{peer_addr} || '(no peer)') |
|
59
|
|
|
|
|
|
|
. "] for user " |
|
60
|
|
|
|
|
|
|
. ($r_args->{request}->attr |
|
61
|
|
|
|
|
|
|
($r_args->{dict}->attr_name(1)) |
|
62
|
|
|
|
|
|
|
|| '(no user)')); |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
else |
|
65
|
|
|
|
|
|
|
{ |
|
66
|
0
|
|
0
|
|
|
|
$self->log(2, "Fail request from [" |
|
67
|
|
|
|
|
|
|
. ($r_args->{peer_addr} || '(no peer)') |
|
68
|
|
|
|
|
|
|
. "] and no dictionary"); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
0
|
|
|
|
|
|
$self->log(4, "Return $n from match method"); |
|
71
|
0
|
|
|
|
|
|
return $n; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
0
|
|
|
|
|
if ($r_args->{dict}) |
|
76
|
|
|
|
|
|
|
{ |
|
77
|
0
|
|
0
|
|
|
|
$self->log(2, "Match request from " . |
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
78
|
|
|
|
|
|
|
($r_args->{request}->attr |
|
79
|
|
|
|
|
|
|
($r_args->{dict}->attr_name(4)) |
|
80
|
|
|
|
|
|
|
|| '(no NAS-IP-Address)') |
|
81
|
|
|
|
|
|
|
. " [" . ($r_args->{peer_addr} || '(no peer)') |
|
82
|
|
|
|
|
|
|
. "] for user " |
|
83
|
|
|
|
|
|
|
. ($r_args->{request}->attr |
|
84
|
|
|
|
|
|
|
($r_args->{dict}->attr_name(1)) |
|
85
|
|
|
|
|
|
|
|| '(no user)')); |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
else |
|
88
|
|
|
|
|
|
|
{ |
|
89
|
0
|
|
0
|
|
|
|
$self->log(2, "Match request from [" |
|
90
|
|
|
|
|
|
|
. ($r_args->{peer_addr} || '(no peer)') |
|
91
|
|
|
|
|
|
|
. "] and no dictionary"); |
|
92
|
|
|
|
|
|
|
} |
|
93
|
0
|
|
|
|
|
|
return NRS_MATCH_OK; # Fail by default |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
42; |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
__END__ |