Last week, I upgraded my Linux file server from Fedora 39 to Fedora 40, and several CGI applications written in Perl stopped working. I first noticed it when Foswiki could not show any pages, because it was unable to open its log file. After unsuccessfully pursuing a theory that the system upgrade had resulted in some incompatibility between (updated) perl libraries and the (same old) Foswiki application, I discovered that an application that I had written myself had the same problem.
I have now reduced it to a very small program, the core of which is just these few lines:
my $file_to_write = "/tmp/writetest.txt";
unless (open(OUTFILE, ">>", $file_to_write)) {
print "Failed to open (for append) $file_to_write.<BR>\n";
}
printf "%s %s Write test to $file_to_write\n", ljpDate(), ljpTime();
printf OUTFILE "%s %s Write test\n", ljpDate(), ljpTime();
close OUTFILE;
print "Write completed<BR>\n";
It appears that the open succeeds (I do not get the "Failed .." message), but nothing is written to the file, even though it has mode 666 (-rw-rw-rw-) and it is owned by apache:apache. If the file exists, it is untouched, and if it does not exist, it is not created.
If I run the script from the command line (./writetest.cgi) everything works as expected.
This worked last week before the update. Is there some new sandboxing feature that kills my applications ?
I should add that SElinux is disabled on this system, as confirmed by sestatus
.
PrivateTmp
. Look atsystemctl show -p PrivateTmp httpd
(or whatever service is running your cgi) forPrivateTmp=yes
, or for a tmp directory in/tmp/systemd-private-*/
.