Fwctl/Services/portmap.pm untested

filter: Statementstmt 0.0% 0 / 35 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 63 CC 5 SCAR 18.9
CC
5
Cov
0%
accept_rules
12.0
account_rules
12.0
new
2.0
CRAP 6.6
1 #
2 # portmap.pm: Fwctl service module to handle the portmapper protocol.
3 #
4 # This file is part of Fwctl.
5 #
6 # Author: Francis J. Lacoste <francis.lacoste@iNsu.COM>
7 #
8 # Copyright (c) 1999,2000 iNsu Innovations Inc.
9 #
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
14 #
15 package Fwctl::Services::portmap;
16  
17 use strict;
18  
19 use Fwctl::RuleSet qw(:tcp_rulesets :udp_rulesets :masq :ports);
20 use IPChains;
21  
22 sub new {
23 my $proto = shift;
24 my $class = ref $proto || $proto;
25 bless {}, $class;
26 }
27  
28 sub prototypes {
29 my ($self,$target,$options) = @_;
30  
31 # Build prototype rule
32 (
33 IPChains->new(
34 Rule => $target,
35 Prot => 'udp',
36 SourcePort => '512:1023',
37 DestPort => 'sunrpc',
38 %{$options->{ipchains}},
39 ),
40 IPChains->new(
41 Rule => $target,
42 Prot => 'tcp',
43 SourcePort => UNPRIVILEGED_PORTS,
44 DestPort => '111',
45 %{$options->{ipchains}},
46 ),
47 );
48 }
49  
50 sub block_rules {
51 my $self = shift;
52 my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_;
53  
54  
55 my ($udp,$tcp) = $self->prototypes( $target, $options );
56 block_udp_ruleset( $udp, $src, $src_if, $dst, $dst_if );
57 block_tcp_ruleset( $tcp, $src, $src_if, $dst, $dst_if );
58 }
59  
60 sub accept_rules {
61 my $self = shift;
62 my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_;
63  
64 my ($udp,$tcp) = $self->prototypes( $target, $options );
65  
66 my $masq = defined $options->{portfw} ? PORTFW :
67 $options->{masq} ? MASQ : NOMASQ;
68  
69 accept_udp_ruleset( $udp, $src, $src_if, $dst, $dst_if,
70 $masq, $options->{portfw} );
71  
72 accept_tcp_ruleset( $tcp, $src, $src_if, $dst, $dst_if,
73 $masq, $options->{portfw} );
74 }
75  
76 sub account_rules {
77 my $self = shift;
78 my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_;
79  
80 my ($udp,$tcp) = $self->prototypes( $target, $options );
81  
82 my $masq = defined $options->{portfw} ? PORTFW :
83 $options->{masq} ? MASQ : NOMASQ;
84  
85 acct_udp_ruleset( $udp, $src, $src_if, $dst, $dst_if,
86 $masq, $options->{portfw} );
87  
88 acct_tcp_ruleset( $tcp, $src, $src_if, $dst, $dst_if,
89 $masq, $options->{portfw} );
90 }
91  
92 sub valid_options {
93 my $self = shift;
94 ( );
95 }
96  
97 1;
98 =pod
99  
100 =head1 NAME
101  
102 Fwctl::Services::portmap - Fwctl module to handle the portmapper service.
103  
104 =head1 SYNOPSIS
105  
106 deny portmap -src INTERNET --account
107  
108 =head1 DESCRIPTION
109  
110 The portmapper handles portmap traffic.
111  
112 =head1 AUTHOR
113  
114 Francis J. Lacoste <francis.lacoste@iNsu.COM>
115  
116 =head1 COPYRIGHT
117  
118 Copyright (c) 1999,2000 iNsu Innovations Inc.
119 All rights reserved.
120  
121 This program is free software; you can redistribute it and/or modify
122 it under the terms of the GNU General Public License as published by
123 the Free Software Foundation; either version 2 of the License, or
124 (at your option) any later version.
125  
126 =head1 SEE ALSO
127  
128 fwctl(8) Fwctl(3) Fwctl::RuleSet(3)
129  
130 =cut
131