| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package IO::Socket::SSL::SafeAccept; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
655
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
38
|
|
|
4
|
1
|
|
|
1
|
|
801
|
use POSIX; |
|
|
1
|
|
|
|
|
7838
|
|
|
|
1
|
|
|
|
|
7
|
|
|
5
|
1
|
|
|
1
|
|
5113
|
use IO::Socket::SSL; |
|
|
1
|
|
|
|
|
127229
|
|
|
|
1
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
|
|
$IO::Socket::SSL::SafeAccept::VERSION = ( split " ", '# $Id: SSL.pm,v 1.0 2000/06/14 10:30:56 mkul Exp $ ' )[3]; |
|
7
|
|
|
|
|
|
|
@IO::Socket::SSL::SafeAccept::ISA = qw(IO::Socket::SSL); |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub accept |
|
10
|
|
|
|
|
|
|
{ |
|
11
|
0
|
|
|
0
|
|
|
my $this = shift; |
|
12
|
0
|
|
|
|
|
|
my $result = $this->SUPER::accept ( @_ ); |
|
13
|
0
|
0
|
|
|
|
|
$! = POSIX::EINTR() if ( ! $result ); |
|
14
|
0
|
|
|
|
|
|
$result; |
|
15
|
|
|
|
|
|
|
} |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
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
|
|
|
1
|
|
367
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
42
|
|
|
54
|
1
|
|
|
1
|
|
1104
|
use Net::Daemon; |
|
|
1
|
|
|
|
|
739357
|
|
|
|
1
|
|
|
|
|
496
|
|
|
55
|
|
|
|
|
|
|
$Net::Daemon::SSL::VERSION = ( split " ", '# $Id: SSL.pm,v 1.0 2000/06/14 10:30:56 mkul Exp $ ' )[3]; |
|
56
|
|
|
|
|
|
|
@Net::Daemon::SSL::ISA = qw (Net::Daemon); |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub Version ($) |
|
59
|
|
|
|
|
|
|
{ |
|
60
|
0
|
|
|
0
|
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
|
|
|
|
|
|
|
{ |
|
74
|
0
|
|
|
0
|
1
|
|
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
|
|
|
|
|
|
|
{ |
|
107
|
0
|
|
|
0
|
1
|
|
my $this = shift; |
|
108
|
0
|
0
|
|
|
|
|
unless ( $this->{socket} ) |
|
109
|
|
|
|
|
|
|
{ |
|
110
|
0
|
|
0
|
|
|
|
$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
|
|
|
|
|
|
|
SSL_ca_file => $this->{SSL_ca_file} ) || $this->Fatal("Cannot create socket: $!"); |
|
122
|
|
|
|
|
|
|
} |
|
123
|
0
|
|
|
|
|
|
$this->SUPER::Bind ( @_ ); |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
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, L |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
__END__ |