gitweb: die when a configuration file cannot be read

Fix a possibility of a permission to access error go unnoticed. Perl uses two different variables to manage errors from a "do $filename" construct. One is $@, which is set in this case when do is unable to compile the file. The other is $!, which is set in case do cannot read the file. The current code only checks "$@", which means a configuration file passed to GitWeb that is not readable by the server process does not cause it to "die". Make sure we also check and act on "$!" to fix this. Signed-off-by: Marcelo Roberto Jimenez <marcelo.jimenez@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Marcelo Roberto Jimenez committed Jan 10, 2024 at 19:57 UTC ac62a3649fcfd7f2caa80ffdfb8c3135764291ef
1 file changed +3 -1
gitweb/gitweb.perl
+3 -1
@@ -728,9 +728,11 @@ our $per_request_config = 1;
728 sub read_config_file {
729 my $filename = shift;
730 return unless defined $filename;
731 - # die if there are errors parsing config file
731 if (-e $filename) {
732 do $filename;
733 + # die if there is a problem accessing the file
734 + die $! if $!;
735 + # die if there are errors parsing config file
736 die $@ if $@;
737 return 1;
738 }