blib/lib/Net/Daemon/SSL.pm

filter: Statementstmt 52.5% 21 / 40 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 55.5% 5 / 9 Podpod 66.6% 2 / 3 totaltotal 41.7% 28 / 67 CC 6 SCAR 25.0
CC
6
Cov
41%
Bind
30.0
accept
6.0
Version
2.0
CRAP 12.2
↑ Summary
1 package IO::Socket::SSL::SafeAccept;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use POSIX;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use IO::Socket::SSL;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 $IO::Socket::SSL::SafeAccept::VERSION = ( split " ", '# $Id: SSL.pm,v 1.0 2000/06/14 10:30:56 mkul Exp $ ' )[3];
7 1 @IO::Socket::SSL::SafeAccept::ISA = qw(IO::Socket::SSL);
8  
9 sub accept
10 0 ▶{
Subroutine accept: not called CC=2 SCAR=17.9
11 0 my $this = shift;
12 0 my $result = $this->SUPER::accept ( @_ );
13 0 ▶ $! = POSIX::EINTR() if ( ! $result );
Branch: 1 branch
BranchTrueFalseTotal
unless $result 0 0 0
14 0 $result;
15 }
16  
17 1 1;
18  
19 package Net::Daemon::SSL;
20  
21 =head1 NAME
22  
23 Net::Daemon::SSL - perl extensions for portable ssl daemons
24  
25 =head1 SYNOPSIS
26  
27 use Net::Daemon::SSL;
28 package MyDaemon;
29 @MyDaemon::ISA = qw (Net::Daemon::SSL);
30 sub Run
31 {
32 my $this = shift;
33 my $buffer;
34 $this->{socket}->print ( "vasja was here\n" );
35 $this->{socket}->sysread ( $buffer, 100 ); # Attention! getline() method
36 # do not work with IO::Socket::SSL
37 # version 0.73
38 # see perldoc IO::Socket::SSL
39 # for more details
40 }
41 package main;
42 my $daemon = new MyDaemon ( {}, \ @ARGV ); # you can use --help command line key
43 $daemon || die "error create daemon instance: $!\n";
44 $daemon->Bind();
45  
46 =head1 DESCRIPTION
47  
48 This class implements an IO::Socket::SSL functionality for Net::Daemon
49 class. See perldoc Net::Daemon for more information about Net::Daemon usage.
50  
51 =cut
52  
53 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
54 1 ▶use Net::Daemon;
Subroutine BEGIN: called CC=1 SCAR=0.0
55 1 $Net::Daemon::SSL::VERSION = ( split " ", '# $Id: SSL.pm,v 1.0 2000/06/14 10:30:56 mkul Exp $ ' )[3];
56 1 @Net::Daemon::SSL::ISA = qw (Net::Daemon);
57  
58 sub Version ($)
59 0 ▶{
Subroutine Version: not called CC=1 SCAR=6.9
Pod undocumented
60 0 'Generic Net::Daemon::SSL server 1.0 (C) Michael Kulakov 2000';
61 }
62  
63 =head2 Options
64  
65 This method add IO::Socket::SSL specific options ( SSL_use_cert,
66 SSL_verify_mode, SSL_key_file, SSL_cert_file, SSL_ca_path, SSL_ca_file ) to
67 generic Net::Daemon options. See perldoc IO::Socket::SSL for description of
68 this options
69  
70 =cut
71  
72 sub Options ($)
73 0 ▶{
Subroutine Options: not called CC=1 SCAR=6.9
Pod documented
74 0 my $this = shift;
75 0 my $options = $this->SUPER::Options();
76 0 my $descr = ' - see perldoc IO::Socket::SSL for same parameter';
77 0 $options->{SSL_use_cert} = { 'template' => 'SSL_use_cert',
78 'description' => '--SSL_use_cert' . $descr };
79 0 $options->{SSL_verify_mode} = { 'template' => 'SSL_verify_mode=s',
80 'description' => '--SSL_verify_mode' . $descr };
81 0 $options->{SSL_key_file} = { 'template' => 'SSL_key_file=s',
82 'description' => '--SSL_key_file' . $descr };
83 0 $options->{SSL_cert_file} = { 'template' => 'SSL_cert_file=s',
84 'description' => '--SSL_cert_file' . $descr };
85 0 $options->{SSL_ca_path} = { 'template' => 'SSL_ca_path=s',
86 'description' => '--SSL_ca_path' . $descr };
87 0 $options->{SSL_ca_file} = { 'template' => 'SSL_ca_file=s',
88 'description' => '--SSL_ca_file' . $descr };
89 0 $options;
90 }
91  
92 =head2 Bind
93  
94 This method creates an IO::Socket::SSL::SafeAccept socket, stores this socket
95 into $this->{socket} and passes control to parent Net::Daemon::Bind. The
96 IO::Socket::SSL::SafeAccept is a class inherited from
97 IO::Socket::SSL with the only difference from parent class - the accept() method of
98 this class returns EINTR on *any* error. This trick is needed to "hack"
99 Net::Daemon::Bind functionality: if this method gets an error from accept()
100 ( Net::Daemon::SSL auth error, for example ) it will call Fatal() method and
101 die unless this is a EINTR error.
102  
103 =cut
104  
105 sub Bind
106 0 ▶{
Subroutine Bind: not called CC=5 SCAR=34.0
Pod documented
107 0 my $this = shift;
108 0 ▶ unless ( $this->{socket} )
Branch: 1 branch
BranchTrueFalseTotal
unless ($this->{"socket"}) 0 0 0
109 {
110 $this->{socket} = new IO::Socket::SSL::SafeAccept
111 ( LocalAddr => $this->{localaddr},
112 LocalPort => $this->{localport},
113 Proto => $this->{proto} || 'tcp',
114 Listen => $this->{listen} || 10,
115 Reuse => 1,
116 SSL_use_cert => $this->{SSL_use_cert},
117 SSL_verify_mode => $this->{SSL_verify_mode},
118 SSL_key_file => $this->{SSL_key_file},
119 SSL_cert_file => $this->{SSL_cert_file},
120 SSL_ca_path => $this->{SSL_ca_path},
121 0 ▶ SSL_ca_file => $this->{SSL_ca_file} ) || $this->Fatal("Cannot create socket: $!");
Condition0%0/7
'IO::Socket::SSL::SafeAccept'->new('LocalAddr', $this->{'localaddr'}, 'LocalPort', $this->{'localport'}, 'Proto', $this->{'proto'} || 'tcp', 'Listen', $this->{'listen'} || 10, 'Reuse', 1, 'SSL_use_cert', $this->{'SSL_use_cert'}, 'SSL_verify_mode', $this->{'SSL_verify_mode'}, 'SSL_key_file', $this->{'SSL_key_file'}, 'SSL_cert_file', $this->{'SSL_cert_file'}, 'SSL_ca_path', $this->{'SSL_ca_path'}, 'SSL_ca_file', $this->{'SSL_ca_file'}) || $this->Fatal("Cannot create socket: $!")
l!l&&r!l&&!r
000
$this->{'proto'} || 'tcp'
l!l
00
$this->{'listen'} || 10
l!l
00
MC/DC0%0/2
'IO::Socket::SSL::SafeAccept'->new('LocalAddr', $this->{'localaddr'}, 'LocalPort', $this->{'localport'}, 'Proto', $this->{'proto'} || 'tcp', 'Listen', $this->{'listen'} || 10, 'Reuse', 1, 'SSL_use_cert', $this->{'SSL_use_cert'}, 'SSL_verify_mode', $this->{'SSL_verify_mode'}, 'SSL_key_file', $this->{'SSL_key_file'}, 'SSL_cert_file', $this->{'SSL_cert_file'}, 'SSL_ca_path', $this->{'SSL_ca_path'}, 'SSL_ca_file', $this->{'SSL_ca_file'}) || $this->Fatal("Cannot create socket: $!")
'IO::Socket::SSL::SafeAccept'->new('LocalAddr', $this->{'localaddr'}, 'LocalPort', $this->{'localport'}, 'Proto', $this->{'proto'} || 'tcp', 'Listen', $this->{'listen'} || 10, 'Reuse', 1, 'SSL_use_cert', $this->{'SSL_use_cert'}, 'SSL_verify_mode', $this->{'SSL_verify_mode'}, 'SSL_key_file', $this->{'SSL_key_file'}, 'SSL_cert_file', $this->{'SSL_cert_file'}, 'SSL_ca_path', $this->{'SSL_ca_path'}, 'SSL_ca_file', $this->{'SSL_ca_file'}) $this->Fatal("Cannot create socket: $!")
MC/DC0%0/1
$this->{'proto'} || 'tcp'
$this->{'proto'}
MC/DC0%0/1
$this->{'listen'} || 10
$this->{'listen'}
Truth table0%0/3
A || B
A= 'IO::Socket::SSL::SafeAccept'->new('LocalAddr', $this->{'localaddr'}, 'LocalPort', $this->{'localport'}, 'Proto', $this->{'proto'} || 'tcp', 'Listen', $this->{'listen'} || 10, 'Reuse', 1, 'SSL_use_cert', $this->{'SSL_use_cert'}, 'SSL_verify_mode', $this->{'SSL_verify_mode'}, 'SSL_key_file', $this->{'SSL_key_file'}, 'SSL_cert_file', $this->{'SSL_cert_file'}, 'SSL_ca_path', $this->{'SSL_ca_path'}, 'SSL_ca_file', $this->{'SSL_ca_file'})B= $this->Fatal("Cannot create socket: $!")
ABresult
1X1
011
000
Truth table0%0/2
A
A= $this->{'proto'}
Aresult
11
00
Truth table0%0/2
A
A= $this->{'listen'}
Aresult
11
00
122 }
123 0 $this->SUPER::Bind ( @_ );
124 }
125  
126 1 1;
127  
128 =head1 AUTHOR AND COPYRIGHT
129  
130 Net::Daemon::SSL (C) Michael Kulakov, Zenon N.S.P. 2000
131 125124, 19, 1-st Jamskogo polja st,
132 Moscow, Russian Federation
133  
134 mkul@cpan.org
135  
136 All rights reserved.
137  
138 You may distribute this package under the terms of either the GNU
139 General Public License or the Artistic License, as specified in the
140 Perl README file.
141  
142 =head1 SEE ALSO
143  
144 L<Net::Daemon(3)>, L<IO::Socket::SSL(3)>
145  
146 =cut
147  
148 __END__
↑ Summary