2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-05-17 11:54:16 +00:00

Fix xcatprobe TFTP check failure with restrictive umask

The is_tftp_ready() function creates test files that inherit the
shell's umask. With umask 027, files get 640 permissions and the
TFTP daemon (running as nobody/tftp) cannot read them, causing a
false negative even when TFTP service is healthy.

Temporarily set umask to 022 during test file creation so files
are world-readable (644), then restore the original umask.

Fixes: https://github.com/xcat2/xcat-core/issues/7487
This commit is contained in:
Vinícius Ferrão
2026-05-11 13:13:05 -03:00
parent 2623c6889b
commit 701e9e00c0
+2
View File
@@ -552,12 +552,14 @@ sub is_tftp_ready {
$mnip = shift if (($mnip) && ($mnip =~ /probe_utils/));
my $tftpdir = shift;
my $test_dir = $tftpdir . "/tftptest/";
my $old_umask = umask(022);
system("mkdir -p $test_dir");
rename("/$test_dir/tftptestt.tmp", "/$test_dir/tftptestt.tmp.old") if (-e "/$test_dir/tftptestt.tmp");
rename("./tftptestt.tmp", "./tftptestt.tmp.old") if (-e "./tftptestt.tmp");
system("date > /$test_dir/tftptestt.tmp");
umask($old_umask);
my $output = `tftp -4 -v $mnip -c get /tftptest/tftptestt.tmp 2>&1`;
if ((!$?) && (-s "./tftptestt.tmp")) {
unlink("./tftptestt.tmp");