Use my instead of local

This commit is contained in:
Jamie Cameron
2026-01-07 11:06:53 -08:00
parent 27c5ad998e
commit e9be9b1d53

View File

@@ -34,7 +34,7 @@ if ($aerr) {
exit;
}
if (open(RANDOM, "/dev/urandom")) {
local $tmpsid;
my $tmpsid;
read(RANDOM, $tmpsid, 16);
$sid = lc(unpack('h*', $tmpsid));
close RANDOM;
@@ -57,7 +57,7 @@ untie(*STDIN);
untie(*STDOUT);
# Accept the TCP connection
local $rmask;
my $rmask;
vec($rmask, fileno(MAIN), 1) = 1;
if ($use_ipv6) {
vec($rmask, fileno(MAIN6), 1) = 1;
@@ -85,32 +85,32 @@ select($oldsel);
$rcount = 0;
while(1) {
# Wait for the request. Wait longer if this isn't the first one
local $rmask;
my $rmask;
vec($rmask, fileno(SOCK), 1) = 1;
local $sel = select($rmask, undef, undef, $rcount ? 360 : 60);
my $sel = select($rmask, undef, undef, $rcount ? 360 : 60);
if ($sel <= 0) {
print STDERR "fastrpc: session timed out\n"
if ($gconfig{'rpcdebug'});
last;
}
local $line = <SOCK>;
my $line = <SOCK>;
last if (!$line);
local ($len, $auth) = split(/\s+/, $line);
my ($len, $auth) = split(/\s+/, $line);
die "Invalid session ID" if ($auth ne $sid);
local $rawarg;
my $rawarg;
while(length($rawarg) < $len) {
local $got;
local $rv = read(SOCK, $got, $len - length($rawarg));
my $got;
my $rv = read(SOCK, $got, $len - length($rawarg));
exit if ($rv <= 0);
$rawarg .= $got;
}
print STDERR "fastrpc: raw $rawarg\n" if ($gconfig{'rpcdebug'});
local $dumper = substr($rawarg, 0, 5) eq '$VAR1' ? 1 : 0;
local $arg = &unserialise_variable($rawarg);
my $dumper = substr($rawarg, 0, 5) eq '$VAR1' ? 1 : 0;
my $arg = &unserialise_variable($rawarg);
# Process it
local $rv;
my $rv;
if ($arg->{'action'} eq 'ping') {
# Just respond with an OK
print STDERR "fastrpc: ping\n" if ($gconfig{'rpcdebug'});
@@ -126,12 +126,12 @@ while(1) {
elsif ($arg->{'action'} eq 'config') {
# Get the config for some module
print STDERR "fastrpc: config $arg->{'module'}\n" if ($gconfig{'rpcdebug'});
local %config = &foreign_config($arg->{'module'});
my %config = &foreign_config($arg->{'module'});
$rv = { 'status' => 1, 'rv' => \%config };
}
elsif ($arg->{'action'} eq 'write') {
# Transfer data to a local temp file
local $file = $arg->{'file'} ? $arg->{'file'} :
# Transfer data to a my temp file
my $file = $arg->{'file'} ? $arg->{'file'} :
$arg->{'name'} ? &tempname($arg->{'name'}) :
&tempname();
print STDERR "fastrpc: write $file\n" if ($gconfig{'rpcdebug'});
@@ -142,24 +142,24 @@ while(1) {
$rv = { 'status' => 1, 'rv' => $file };
}
elsif ($arg->{'action'} eq 'tcpwrite') {
# Transfer data to a local temp file over TCP connection
local $file = $arg->{'file'} ? $arg->{'file'} :
# Transfer data to a my temp file over TCP connection
my $file = $arg->{'file'} ? $arg->{'file'} :
$arg->{'name'} ? &tempname($arg->{'name'}) :
&tempname();
print STDERR "fastrpc: tcpwrite $file\n" if ($gconfig{'rpcdebug'});
local $tsock = time().$$;
local $tsock6 = $use_ipv6 ? time().$$."v6" : undef;
local $tport = $port + 1;
my $tsock = time().$$;
my $tsock6 = $use_ipv6 ? time().$$."v6" : undef;
my $tport = $port + 1;
&allocate_socket($tsock, $tsock6, \$tport);
if (!fork()) {
# Accept connection in separate process
print STDERR "fastrpc: tcpwrite $file port $tport\n" if ($gconfig{'rpcdebug'});
local $rmask;
my $rmask;
vec($rmask, fileno($tsock), 1) = 1;
if ($use_ipv6) {
vec($rmask, fileno($tsock6), 1) = 1;
}
local $sel = select($rmask, undef, undef, 30);
my $sel = select($rmask, undef, undef, 30);
exit if ($sel <= 0);
if (vec($rmask, fileno($tsock), 1)) {
accept(TRANS, $tsock) || exit;
@@ -168,14 +168,14 @@ while(1) {
accept(TRANS, $tsock6) || exit;
}
print STDERR "fastrpc: tcpwrite $file accepted\n" if ($gconfig{'rpcdebug'});
local $buf;
local $err;
my $buf;
my $err;
if (open(FILE, ">$file")) {
binmode(FILE);
print STDERR "fastrpc: tcpwrite $file writing\n" if ($gconfig{'rpcdebug'});
my $bs = &get_buffer_size();
while(read(TRANS, $buf, $bs) > 0) {
local $ok = (print FILE $buf);
my $ok = (print FILE $buf);
if (!$ok) {
$err = "Write to $file failed : $!";
last;
@@ -200,7 +200,7 @@ while(1) {
elsif ($arg->{'action'} eq 'read') {
# Transfer data from a file
print STDERR "fastrpc: read $arg->{'file'}\n" if ($gconfig{'rpcdebug'});
local ($data, $got);
my ($data, $got);
open(FILE, "<$arg->{'file'}");
binmode(FILE);
my $bs = &get_buffer_size();
@@ -221,18 +221,18 @@ while(1) {
}
else {
binmode(FILE);
local $tsock = time().$$;
local $tsock6 = $use_ipv6 ? time().$$."v6" : undef;
local $tport = $port + 1;
my $tsock = time().$$;
my $tsock6 = $use_ipv6 ? time().$$."v6" : undef;
my $tport = $port + 1;
&allocate_socket($tsock, $tsock6, \$tport);
if (!fork()) {
# Accept connection in separate process
local $rmask;
my $rmask;
vec($rmask, fileno($tsock), 1) = 1;
if ($use_ipv6) {
vec($rmask, fileno($tsock6), 1) = 1;
}
local $sel = select($rmask, undef, undef, 30);
my $sel = select($rmask, undef, undef, 30);
exit if ($sel <= 0);
if (vec($rmask, fileno($tsock), 1)) {
accept(TRANS, $tsock) || exit;
@@ -240,7 +240,7 @@ while(1) {
elsif (vec($rmask, fileno($tsock6), 1)) {
accept(TRANS, $tsock6) || exit;
}
local $buf;
my $buf;
while(read(FILE, $buf, 1024) > 0) {
print TRANS $buf;
}
@@ -274,7 +274,7 @@ while(1) {
elsif ($arg->{'action'} eq 'call') {
# execute a function
print STDERR "fastrpc: call $arg->{'module'}::$arg->{'func'}(",join(",", @{$arg->{'args'}}),")\n" if ($gconfig{'rpcdebug'});
local @rv;
my @rv;
eval {
local $main::error_must_die = 1;
@rv = &foreign_call($arg->{'module'},
@@ -296,9 +296,9 @@ while(1) {
elsif ($arg->{'action'} eq 'eval') {
# eval some perl code
print STDERR "fastrpc: eval $arg->{'module'} $arg->{'code'}\n" if ($gconfig{'rpcdebug'});
local $erv;
my $erv;
if ($arg->{'module'}) {
local $pkg = $arg->{'module'};
my $pkg = $arg->{'module'};
$pkg =~ s/[^A-Za-z0-9]/_/g;
$erv = eval "package $pkg;\n".
$arg->{'code'}."\n";
@@ -334,8 +334,8 @@ while(1) {
# allocate_socket(handle, ipv6-handle, &port)
sub allocate_socket
{
local ($fh, $fh6, $port) = @_;
local $proto = getprotobyname('tcp');
my ($fh, $fh6, $port) = @_;
my $proto = getprotobyname('tcp');
if (!socket($fh, PF_INET, SOCK_STREAM, $proto)) {
return "socket failed : $!";
}