diff options
author | Dan Fandrich <dan@coneharvesters.com> | 2023-03-28 13:29:36 -0700 |
---|---|---|
committer | Dan Fandrich <dan@coneharvesters.com> | 2023-03-30 09:53:57 -0700 |
commit | 0e3ae25337152b14c75e4fcc0d6f4da8f9850e3c (patch) | |
tree | 3d48f3b2b9cdfbeb9fc111bb5e72f4f001ae52b0 /tests/sshserver.pl | |
parent | b133f70a52703ccc6469280ae141643bcc06a685 (diff) | |
download | curl-0e3ae25337152b14c75e4fcc0d6f4da8f9850e3c.tar.gz |
tests: switch to 3-argument open in test suite
The perl 2-argument open has been considered not-quite-deprecated since
the 3-argument form was introduced almost a quarter century ago.
Diffstat (limited to 'tests/sshserver.pl')
-rwxr-xr-x | tests/sshserver.pl | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/tests/sshserver.pl b/tests/sshserver.pl index e64890dae..aaf503972 100755 --- a/tests/sshserver.pl +++ b/tests/sshserver.pl @@ -387,23 +387,23 @@ if((! -e $hstprvkeyf) || (! -s $hstprvkeyf) || system "chmod 600 $hstprvkeyf"; system "chmod 600 $cliprvkeyf"; # Save md5 and sha256 hashes of public host key - open(RSAKEYFILE, "<$hstpubkeyf"); - my @rsahostkey = do { local $/ = ' '; <RSAKEYFILE> }; - close(RSAKEYFILE); + open(my $rsakeyfile, "<", "$hstpubkeyf"); + my @rsahostkey = do { local $/ = ' '; <$rsakeyfile> }; + close($rsakeyfile); if(!$rsahostkey[1]) { logmsg 'Failed parsing base64 encoded RSA host key'; exit 1; } - open(PUBMD5FILE, ">$hstpubmd5f"); - print PUBMD5FILE md5_hex(decode_base64($rsahostkey[1])); - close(PUBMD5FILE); + open(my $pubmd5file, ">", "$hstpubmd5f"); + print $pubmd5file md5_hex(decode_base64($rsahostkey[1])); + close($pubmd5file); if((! -e $hstpubmd5f) || (! -s $hstpubmd5f)) { logmsg 'Failed writing md5 hash of RSA host key'; exit 1; } - open(PUBSHA256FILE, ">$hstpubsha256f"); - print PUBSHA256FILE sha256_base64(decode_base64($rsahostkey[1])); - close(PUBSHA256FILE); + open(my $pubsha256file, ">", "$hstpubsha256f"); + print $pubsha256file sha256_base64(decode_base64($rsahostkey[1])); + close($pubsha256file); if((! -e $hstpubsha256f) || (! -s $hstpubsha256f)) { logmsg 'Failed writing sha256 hash of RSA host key'; exit 1; @@ -780,12 +780,12 @@ if(system "\"$sshd\" -t -f $sshdconfig > $sshdlog 2>&1") { if((! -e $knownhosts) || (! -s $knownhosts)) { logmsg 'generating ssh client known hosts file...' if($verbose); unlink($knownhosts); - if(open(RSAKEYFILE, "<$hstpubkeyf")) { - my @rsahostkey = do { local $/ = ' '; <RSAKEYFILE> }; - if(close(RSAKEYFILE)) { - if(open(KNOWNHOSTS, ">$knownhosts")) { - print KNOWNHOSTS "$listenaddr ssh-rsa $rsahostkey[1]\n"; - if(!close(KNOWNHOSTS)) { + if(open(my $rsakeyfile, "<", "$hstpubkeyf")) { + my @rsahostkey = do { local $/ = ' '; <$rsakeyfile> }; + if(close($rsakeyfile)) { + if(open(my $knownhostsh, ">", "$knownhosts")) { + print $knownhostsh "$listenaddr ssh-rsa $rsahostkey[1]\n"; + if(!close($knownhostsh)) { $error = "Error: cannot close file $knownhosts"; } } @@ -1121,9 +1121,9 @@ logmsg "RUN: $cmd" if($verbose); # if ($sshdid =~ /OpenSSH-Windows/) { # Fake pidfile for ssh server on Windows. - if(open(OUT, ">$pidfile")) { - print OUT $$ . "\n"; - close(OUT); + if(open(my $out, ">", "$pidfile")) { + print $out $$ . "\n"; + close($out); } # Flush output. |