mirror of
https://github.com/webmin/webmin.git
synced 2025-07-23 00:30:33 +00:00
Fix use of IPv6 for file transfers https://forum.virtualmin.com/t/new-version-of-webmin-causes-problem-with-my-cron/113175/9
This commit is contained in:
28
fastrpc.cgi
28
fastrpc.cgi
@ -153,16 +153,25 @@ while(1) {
|
|||||||
&tempname();
|
&tempname();
|
||||||
print STDERR "fastrpc: tcpwrite $file\n" if ($gconfig{'rpcdebug'});
|
print STDERR "fastrpc: tcpwrite $file\n" if ($gconfig{'rpcdebug'});
|
||||||
local $tsock = time().$$;
|
local $tsock = time().$$;
|
||||||
|
local $tsock6 = time().$$."v6";
|
||||||
local $tport = $port + 1;
|
local $tport = $port + 1;
|
||||||
&allocate_socket($tsock, \$tport);
|
&allocate_socket($tsock, $tsock6, \$tport);
|
||||||
if (!fork()) {
|
if (!fork()) {
|
||||||
# Accept connection in separate process
|
# Accept connection in separate process
|
||||||
print STDERR "fastrpc: tcpwrite $file port $tport\n" if ($gconfig{'rpcdebug'});
|
print STDERR "fastrpc: tcpwrite $file port $tport\n" if ($gconfig{'rpcdebug'});
|
||||||
local $rmask;
|
local $rmask;
|
||||||
vec($rmask, fileno($tsock), 1) = 1;
|
vec($rmask, fileno($tsock), 1) = 1;
|
||||||
|
if ($use_ipv6) {
|
||||||
|
vec($rmask, fileno($tsock6), 1) = 1;
|
||||||
|
}
|
||||||
local $sel = select($rmask, undef, undef, 30);
|
local $sel = select($rmask, undef, undef, 30);
|
||||||
exit if ($sel <= 0);
|
exit if ($sel <= 0);
|
||||||
accept(TRANS, $tsock) || exit;
|
if (vec($rmask, fileno($tsock), 1)) {
|
||||||
|
accept(TRANS, $tsock) || exit;
|
||||||
|
}
|
||||||
|
elsif ($use_ipv6 && vec($rmask, fileno($tsock6), 1)) {
|
||||||
|
accept(TRANS, $tsock6) || exit;
|
||||||
|
}
|
||||||
print STDERR "fastrpc: tcpwrite $file accepted\n" if ($gconfig{'rpcdebug'});
|
print STDERR "fastrpc: tcpwrite $file accepted\n" if ($gconfig{'rpcdebug'});
|
||||||
local $buf;
|
local $buf;
|
||||||
local $err;
|
local $err;
|
||||||
@ -189,6 +198,7 @@ while(1) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
close($tsock);
|
close($tsock);
|
||||||
|
close($tsock6);
|
||||||
print STDERR "fastrpc: tcpwrite $file done\n" if ($gconfig{'rpcdebug'});
|
print STDERR "fastrpc: tcpwrite $file done\n" if ($gconfig{'rpcdebug'});
|
||||||
$rawrv = &serialise_variable(
|
$rawrv = &serialise_variable(
|
||||||
{ 'status' => 1, 'rv' => [ $file, $tport ] } );
|
{ 'status' => 1, 'rv' => [ $file, $tport ] } );
|
||||||
@ -221,15 +231,24 @@ while(1) {
|
|||||||
else {
|
else {
|
||||||
binmode(FILE);
|
binmode(FILE);
|
||||||
local $tsock = time().$$;
|
local $tsock = time().$$;
|
||||||
|
local $tsock6 = time().$$."v6";
|
||||||
local $tport = $port + 1;
|
local $tport = $port + 1;
|
||||||
&allocate_socket($tsock, \$tport);
|
&allocate_socket($tsock, $tsock6, \$tport);
|
||||||
if (!fork()) {
|
if (!fork()) {
|
||||||
# Accept connection in separate process
|
# Accept connection in separate process
|
||||||
local $rmask;
|
local $rmask;
|
||||||
vec($rmask, fileno($tsock), 1) = 1;
|
vec($rmask, fileno($tsock), 1) = 1;
|
||||||
|
if ($use_ipv6) {
|
||||||
|
vec($rmask, fileno($tsock6), 1) = 1;
|
||||||
|
}
|
||||||
local $sel = select($rmask, undef, undef, 30);
|
local $sel = select($rmask, undef, undef, 30);
|
||||||
exit if ($sel <= 0);
|
exit if ($sel <= 0);
|
||||||
accept(TRANS, $tsock) || exit;
|
if (vec($rmask, fileno($tsock), 1)) {
|
||||||
|
accept(TRANS, $tsock) || exit;
|
||||||
|
}
|
||||||
|
elsif (vec($rmask, fileno($tsock6), 1)) {
|
||||||
|
accept(TRANS, $tsock6) || exit;
|
||||||
|
}
|
||||||
local $buf;
|
local $buf;
|
||||||
while(read(FILE, $buf, 1024) > 0) {
|
while(read(FILE, $buf, 1024) > 0) {
|
||||||
print TRANS $buf;
|
print TRANS $buf;
|
||||||
@ -240,6 +259,7 @@ while(1) {
|
|||||||
}
|
}
|
||||||
close(FILE);
|
close(FILE);
|
||||||
close($tsock);
|
close($tsock);
|
||||||
|
close($tsock6);
|
||||||
print STDERR "fastrpc: tcpread $arg->{'file'} done\n" if ($gconfig{'rpcdebug'});
|
print STDERR "fastrpc: tcpread $arg->{'file'} done\n" if ($gconfig{'rpcdebug'});
|
||||||
$rawrv = &serialise_variable(
|
$rawrv = &serialise_variable(
|
||||||
{ 'status' => 1, 'rv' => [ $arg->{'file'}, $tport ] } );
|
{ 'status' => 1, 'rv' => [ $arg->{'file'}, $tport ] } );
|
||||||
|
Reference in New Issue
Block a user