Fwctl/Services/lpd.pm untested

filter: Statementstmt 0.0% 0 / 33 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 67 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 # lpd.pm: Fwctl service module to handle the Berkeley Line Printer protocol.
3 #
4 # This file is part of Fwctl.
5 #
6 # Author: Francis J. Lacoste <francis@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::lpd;
16  
17 use strict;
18  
19 use Fwctl::RuleSet qw(:tcp_rulesets :masq);
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 # Check for printer service
32 my $local_ports = $options->{local_port} || "512:1023";
33 my $port = getservbyname "printer", 'tcp' || "515";
34 # Build prototypes
35 (
36 IPChains->new(
37 Rule => $target,
38 Prot => 'tcp',
39 SourcePort => $local_ports,
40 DestPort => $port,
41 %{$options->{ipchains}},
42 ),
43 );
44 }
45  
46 sub block_rules {
47 my $self = shift;
48 my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_;
49  
50  
51 my ($lpd,$stderr) = $self->prototypes( $target, $options );
52 block_tcp_ruleset( $lpd, $src, $src_if, $dst, $dst_if );
53 }
54  
55 sub accept_rules {
56 my $self = shift;
57 my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_;
58  
59 my ($lpd,$stderr) = $self->prototypes( $target, $options );
60  
61 my $masq = defined $options->{portfw} ? PORTFW :
62 $options->{masq} ? MASQ : NOMASQ;
63 accept_tcp_ruleset( $lpd, $src, $src_if, $dst, $dst_if,
64 $masq, $options->{portfw} );
65 }
66  
67 sub account_rules {
68 my $self = shift;
69 my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_;
70  
71 my ($lpd,$stderr) = $self->prototypes( $target, $options );
72 my $masq = defined $options->{portfw} ? PORTFW :
73 $options->{masq} ? MASQ : NOMASQ;
74 acct_tcp_ruleset( $lpd, $src, $src_if, $dst, $dst_if, $masq );
75 }
76  
77 sub valid_options {
78 my $self = shift;
79 ( "local_port=s" );
80 }
81  
82 1;
83 =pod
84  
85 =head1 NAME
86  
87 Fwctl::Services::lpd - Fwctl module to handle the Berkeley Line Printer
88 protocol.
89  
90 =head1 SYNOPSIS
91  
92 accept lpd -src INTERNAL_NET -dst PRINTER
93  
94 =head1 DESCRIPTION
95  
96 The lpd modules handles the LP protocol. It permits a tcp connection from
97 the privileged 512 through 1023 to the printer port (515). You can use
98 the local_port option to specifies another range of port.
99  
100 =head1 AUTHOR
101  
102 Francis J. Lacoste <francis.lacoste@iNsu.COM>
103  
104 =head1 COPYRIGHT
105  
106 Copyright (c) 1999,2000 iNsu Innovations Inc.
107 All rights reserved.
108  
109 This program is free software; you can redistribute it and/or modify
110 it under the terms of the GNU General Public License as published by
111 the Free Software Foundation; either version 2 of the License, or
112 (at your option) any later version.
113  
114 =head1 SEE ALSO
115  
116 fwctl(8) Fwctl(3) Fwctl::RuleSet(3)
117  
118 =cut
119