line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#! /usr/bin/perl |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# $Id: Rule.pm 75 2009-08-12 22:08:28Z lem $ |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Net::Radius::Server::Rule; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
3212
|
use 5.008; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
44
|
|
9
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
10
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
6
|
use base qw/Net::Radius::Server::Base/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
86
|
|
13
|
1
|
|
|
1
|
|
5
|
use Net::Radius::Server::Base qw/:all/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = do { sprintf "%0.3f", 1+(q$Revision: 75 $ =~ /\d+/g)[0]/1000 }; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw/match_methods set_methods/); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub eval |
20
|
|
|
|
|
|
|
{ |
21
|
0
|
|
|
0
|
|
|
my $self = shift; |
22
|
0
|
0
|
|
|
|
|
$self->match_methods([]) unless $self->match_methods; |
23
|
0
|
0
|
|
|
|
|
$self->set_methods([]) unless $self->set_methods; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
$self->log(4, "Starting eval"); |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
my $c = 0; |
28
|
|
|
|
|
|
|
# Verify match methods |
29
|
0
|
|
|
|
|
|
for my $m (@{$self->match_methods}) |
|
0
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
{ |
31
|
0
|
|
|
|
|
|
$self->log(4, "Invoking match method $c"); |
32
|
0
|
0
|
|
|
|
|
unless ($m->(@_) == NRS_MATCH_OK) |
33
|
|
|
|
|
|
|
{ |
34
|
0
|
|
|
|
|
|
$self->log(3, "Method $c did not match - Rule fail"); |
35
|
0
|
|
|
|
|
|
return; |
36
|
|
|
|
|
|
|
} |
37
|
0
|
|
|
|
|
|
$c++; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
$self->log(4, "Rule matches"); |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
my $r = NRS_SET_DISCARD; # Default retval |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
$c = 0; |
45
|
|
|
|
|
|
|
# Invoke set methods |
46
|
0
|
|
|
|
|
|
for my $s (@{$self->set_methods}) |
|
0
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
{ |
48
|
0
|
|
|
|
|
|
$self->log(4, "Invoking set method $c"); |
49
|
0
|
|
|
|
|
|
$r = $s->(@_); |
50
|
0
|
0
|
|
|
|
|
if ($r & NRS_SET_SKIP) |
51
|
|
|
|
|
|
|
{ |
52
|
0
|
|
|
|
|
|
$self->log(3, "Set method returned $c (skip)"); |
53
|
0
|
|
|
|
|
|
last; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
$self->log(4, "Set returning $r"); |
58
|
0
|
|
|
|
|
|
return $r; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
42; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |