line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::SSH::Perl::Util::Win32; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
37
|
use strict; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
148
|
|
4
|
5
|
|
|
5
|
|
24
|
use warnings; |
|
5
|
|
|
|
|
17
|
|
|
5
|
|
|
|
|
118
|
|
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
24
|
use Socket (); |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
61
|
|
7
|
5
|
|
|
5
|
|
21
|
use POSIX (); |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
140
|
|
8
|
5
|
|
|
5
|
|
3404
|
use if $^O eq 'MSWin32', Win32 => (); |
|
5
|
|
|
|
|
70
|
|
|
5
|
|
|
|
|
56
|
|
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; |