sshserver.pl: harden more system() calls

Ref: https://perldoc.perl.org/functions/system

Closes #20997
This commit is contained in:
Viktor Szakats 2026-03-19 01:56:46 +01:00
parent 1509b0ce6a
commit 1c7a270e26
No known key found for this signature in database

View file

@ -424,14 +424,14 @@ if((! -e pp($hstprvkeyf)) || (! -s pp($hstprvkeyf)) ||
chmod 0600, pp($cliprvkeyf);
if(($^O eq 'cygwin' || $^O eq 'msys') && -e "/bin/setfacl") {
# https://cygwin.com/cygwin-ug-net/setfacl.html
system "/bin/setfacl --remove-all " . pp($hstprvkeyf);
system('/bin/setfacl', ('--remove-all', pp($hstprvkeyf)));
}
elsif(pathhelp::os_is_win()) {
# https://ss64.com/nt/icacls.html
$ENV{'MSYS2_ARG_CONV_EXCL'} = '/reset';
system "icacls \"" . pathhelp::sys_native_abs_path(pp($hstprvkeyf)) . "\" /reset";
system "icacls \"" . pathhelp::sys_native_abs_path(pp($hstprvkeyf)) . "\" /grant:r \"$username:(R)\"";
system "icacls \"" . pathhelp::sys_native_abs_path(pp($hstprvkeyf)) . "\" /inheritance:r";
system('icacls', (pathhelp::sys_native_abs_path(pp($hstprvkeyf)), '/reset'));
system('icacls', (pathhelp::sys_native_abs_path(pp($hstprvkeyf)), '/grant:r', "$username:(R)"));
system('icacls', (pathhelp::sys_native_abs_path(pp($hstprvkeyf)), '/inheritance:r'));
}
# Save md5 and sha256 hashes of public host key
open(my $rsakeyfile, "<", pp($hstpubkeyf));