line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: Util.pm,v 1.29 2008/10/02 20:46:17 turnstep Exp $ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Net::SSH::Perl::Util; |
4
|
4
|
|
|
4
|
|
31
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
132
|
|
5
|
4
|
|
|
4
|
|
23
|
use warnings; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
135
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
23
|
use vars qw( %FUNC_TO_MOD %EXPORT_TAGS ); |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
893
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
%FUNC_TO_MOD = ( |
10
|
|
|
|
|
|
|
_crc32 => 'SSH1Misc', |
11
|
|
|
|
|
|
|
_compute_session_id => 'SSH1MP', |
12
|
|
|
|
|
|
|
_mp_linearize => 'SSH1MP', |
13
|
|
|
|
|
|
|
_check_host_in_hostfile => 'Hosts', |
14
|
|
|
|
|
|
|
_all_keys_for_host => 'Hosts', |
15
|
|
|
|
|
|
|
_add_host_to_hostfile => 'Hosts', |
16
|
|
|
|
|
|
|
_remove_host_from_hostfile=> 'Hosts', |
17
|
|
|
|
|
|
|
_load_private_key => 'Authfile', |
18
|
|
|
|
|
|
|
_load_public_key => 'Authfile', |
19
|
|
|
|
|
|
|
_save_private_key => 'Authfile', |
20
|
|
|
|
|
|
|
_respond_to_rsa_challenge => 'RSA', |
21
|
|
|
|
|
|
|
_rsa_public_encrypt => 'RSA', |
22
|
|
|
|
|
|
|
_rsa_private_decrypt => 'RSA', |
23
|
|
|
|
|
|
|
_prompt => 'Term', |
24
|
|
|
|
|
|
|
_read_passphrase => 'Term', |
25
|
|
|
|
|
|
|
_read_yes_or_no => 'Term', |
26
|
|
|
|
|
|
|
_current_user_win32 => 'Win32', |
27
|
|
|
|
|
|
|
_socketpair => 'Win32', |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
%EXPORT_TAGS = ( |
31
|
|
|
|
|
|
|
hosts => [ qw( _check_host_in_hostfile _all_keys_for_host |
32
|
|
|
|
|
|
|
_add_host_to_hostfile _remove_host_from_hostfile ) ], |
33
|
|
|
|
|
|
|
rsa => [ qw( _rsa_public_encrypt _rsa_private_decrypt |
34
|
|
|
|
|
|
|
_respond_to_rsa_challenge ) ], |
35
|
|
|
|
|
|
|
ssh1mp => [ qw( _compute_session_id _mp_linearize ) ], |
36
|
|
|
|
|
|
|
authfile => [ qw( _load_public_key _load_private_key _save_private_key ) ], |
37
|
|
|
|
|
|
|
win32 => [ qw( _current_user_win32 _socketpair ) ], |
38
|
|
|
|
|
|
|
all => [ keys %FUNC_TO_MOD ], |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub import { |
42
|
4
|
|
|
4
|
|
12
|
my $class = shift; |
43
|
4
|
|
|
|
|
12
|
my $callpack = caller; |
44
|
|
|
|
|
|
|
|
45
|
4
|
|
|
|
|
9
|
my @to_export; |
46
|
4
|
|
|
|
|
14
|
my @args = @_; |
47
|
4
|
|
|
|
|
12
|
for my $item (@args) { |
48
|
|
|
|
|
|
|
push @to_export, |
49
|
12
|
50
|
|
|
|
58
|
$item =~ s/^:// ? @{ $EXPORT_TAGS{$item} || [] } : $item; |
|
4
|
100
|
|
|
|
28
|
|
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
4
|
|
|
|
|
10
|
my %loaded; |
53
|
4
|
|
|
4
|
|
31
|
no strict 'refs'; ## no critic |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
639
|
|
54
|
4
|
|
|
|
|
9
|
for my $func (@to_export) { |
55
|
24
|
|
|
|
|
93
|
my $mod = join '::', __PACKAGE__, $FUNC_TO_MOD{$func}; |
56
|
24
|
50
|
|
|
|
76
|
unless ($loaded{$mod}) { |
57
|
24
|
|
|
|
|
126
|
(my $lib = $mod . ".pm") =~ s!::!/!g; |
58
|
24
|
|
|
|
|
4667
|
require $lib; |
59
|
|
|
|
|
|
|
} |
60
|
24
|
|
|
|
|
57
|
*{"${callpack}::$func"} = \&{"${mod}::$func"}; |
|
24
|
|
|
|
|
263
|
|
|
24
|
|
|
|
|
106
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
__END__ |