line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::SSH::Perl::Util::Win32; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
31
|
use strict; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
129
|
|
4
|
4
|
|
|
4
|
|
24
|
use warnings; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
108
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
21
|
use Socket (); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
60
|
|
7
|
4
|
|
|
4
|
|
18
|
use POSIX (); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
114
|
|
8
|
4
|
|
|
4
|
|
1923
|
use if $^O eq 'MSWin32', Win32 => (); |
|
4
|
|
|
|
|
51
|
|
|
4
|
|
|
|
|
140
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# Taken from AnyEvent::Util |
11
|
|
|
|
|
|
|
# Thanks, Mark! |
12
|
|
|
|
|
|
|
sub _socketpair() { |
13
|
|
|
|
|
|
|
# perl's socketpair emulation fails on many vista machines, because |
14
|
|
|
|
|
|
|
# vista returns fantasy port numbers. |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
0
|
|
|
for (1..10) { |
17
|
0
|
0
|
|
|
|
|
socket my $l, Socket::AF_INET(), Socket::SOCK_STREAM(), 0 |
18
|
|
|
|
|
|
|
or next; |
19
|
|
|
|
|
|
|
|
20
|
0
|
0
|
|
|
|
|
bind $l, Socket::pack_sockaddr_in 0, "\x7f\x00\x00\x01" |
21
|
|
|
|
|
|
|
or next; |
22
|
|
|
|
|
|
|
|
23
|
0
|
0
|
|
|
|
|
my $sa = getsockname $l |
24
|
|
|
|
|
|
|
or next; |
25
|
|
|
|
|
|
|
|
26
|
0
|
0
|
|
|
|
|
listen $l, 1 |
27
|
|
|
|
|
|
|
or next; |
28
|
|
|
|
|
|
|
|
29
|
0
|
0
|
|
|
|
|
socket my $r, Socket::AF_INET(), Socket::SOCK_STREAM(), 0 |
30
|
|
|
|
|
|
|
or next; |
31
|
|
|
|
|
|
|
|
32
|
0
|
0
|
|
|
|
|
bind $r, Socket::pack_sockaddr_in 0, "\x7f\x00\x00\x01" |
33
|
|
|
|
|
|
|
or next; |
34
|
|
|
|
|
|
|
|
35
|
0
|
0
|
|
|
|
|
connect $r, $sa |
36
|
|
|
|
|
|
|
or next; |
37
|
|
|
|
|
|
|
|
38
|
0
|
0
|
|
|
|
|
accept my $w, $l |
39
|
|
|
|
|
|
|
or next; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# vista has completely broken peername/sockname that return |
42
|
|
|
|
|
|
|
# fantasy ports. this combo seems to work, though. |
43
|
0
|
0
|
|
|
|
|
(Socket::unpack_sockaddr_in getpeername $r)[0] |
44
|
|
|
|
|
|
|
== (Socket::unpack_sockaddr_in getsockname $w)[0] |
45
|
|
|
|
|
|
|
or (($! = POSIX::EWOULDBLOCK() && POSIX::EINVAL() ), next); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# vista example (you can't make this shit up...): |
48
|
|
|
|
|
|
|
#(Socket::unpack_sockaddr_in getsockname $r)[0] == 53364 |
49
|
|
|
|
|
|
|
#(Socket::unpack_sockaddr_in getpeername $r)[0] == 53363 |
50
|
|
|
|
|
|
|
#(Socket::unpack_sockaddr_in getsockname $w)[0] == 53363 |
51
|
|
|
|
|
|
|
#(Socket::unpack_sockaddr_in getpeername $w)[0] == 53365 |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
return ($r, $w); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
() |
57
|
0
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _current_user_win32 { |
60
|
0
|
|
|
0
|
|
|
my $user; |
61
|
0
|
|
|
|
|
|
eval { $user = Win32::LoginName() }; |
|
0
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
return $user; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |