{"thread":{"id":"49950","subject":"gitweb: local configuration not found","startedAt":"2018-12-05T18:44:08Z","lastAt":"2018-12-06T15:08:12Z","messageCount":4,"participants":["Jonathan Nieder","Ævar Arnfjörð Bjarmason","Junio C Hamano","Martin Mareš"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"364632","messageId":"20181205184404.GC246451@google.com","threadId":"49950","inReplyTo":"154401401074.29584.11169979442731329694.reportbug@gimli.ms.mff.cuni.cz","subject":"gitweb: local configuration not found","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2018-12-05T18:44:04Z","receivedAt":"2018-12-05T18:44:08Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Martin Mares wrote[1]:\n\n> After upgrade to Stretch, gitweb no longer finds the configuration file\n> \"gitweb_config.perl\" in the current directory. However, \"man gitweb\" still\n> mentions this as one of the possible locations of the config file (and\n> indeed a useful one when using multiple instances of gitweb).\n>\n> It was probably broken by Perl dropping \".\" from the default search path\n> for security reasons.\n\nIndeed, perldelta(1) tells me that in 5.24.1 (and 5.26, etc),\n\n  Core modules and tools no longer search \".\" for optional modules\n\ngitweb.perl contains\n\n sub read_config_file {\n         my $filename = shift;\n         return unless defined $filename;\n         # die if there are errors parsing config file\n         if (-e $filename) {\n                 do $filename;\n\nwhich implies an @INC search but it is silly --- as the \"-e\" test\nillustrates, this never intended to search @INC.\n\nDocumentation says \"If you are absolutely certain that you want your\nscript to load and execute a file from the current directory, then use\na ./ prefix\".  We can do that, like so:\n\ndiff --git i/gitweb/Makefile w/gitweb/Makefile\nindex cd194d057f..3160b6cc5d 100644\n--- i/gitweb/Makefile\n+++ w/gitweb/Makefile\n@@ -18,7 +18,7 @@ RM ?= rm -f\n INSTALL ?= install\n \n # default configuration for gitweb\n-GITWEB_CONFIG = gitweb_config.perl\n+GITWEB_CONFIG = ./gitweb_config.perl\n GITWEB_CONFIG_SYSTEM = /etc/gitweb.conf\n GITWEB_CONFIG_COMMON = /etc/gitweb-common.conf\n GITWEB_HOME_LINK_STR = projects\n\nbut that does not help if someone overrides GITWEB_CONFIG, and besides,\nit would be nicer to avoid the possibility of an @INC search altogether.\nAnother alternative would be to use\n\n\tlocal @INC = ('.');\n\nWould that be better?\n\nAdvice from someone more versed than I am in perl would be very welcome\n(hence the cc to Ævar).\n\nThanks for reporting and hope that helps,\nJonathan\n\n[1] https://bugs.debian.org/915632\n"},{"id":"364634","messageId":"87bm5zzt4a.fsf@evledraar.gmail.com","threadId":"49950","inReplyTo":"20181205184404.GC246451@google.com","subject":"Re: gitweb: local configuration not found","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-12-05T19:11:17Z","receivedAt":"2018-12-05T19:11:24Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Wed, Dec 05 2018, Jonathan Nieder wrote:\n\n> Martin Mares wrote[1]:\n>\n>> After upgrade to Stretch, gitweb no longer finds the configuration file\n>> \"gitweb_config.perl\" in the current directory. However, \"man gitweb\" still\n>> mentions this as one of the possible locations of the config file (and\n>> indeed a useful one when using multiple instances of gitweb).\n>>\n>> It was probably broken by Perl dropping \".\" from the default search path\n>> for security reasons.\n>\n> Indeed, perldelta(1) tells me that in 5.24.1 (and 5.26, etc),\n>\n>   Core modules and tools no longer search \".\" for optional modules\n>\n> gitweb.perl contains\n>\n>  sub read_config_file {\n>          my $filename = shift;\n>          return unless defined $filename;\n>          # die if there are errors parsing config file\n>          if (-e $filename) {\n>                  do $filename;\n>\n> which implies an @INC search but it is silly --- as the \"-e\" test\n> illustrates, this never intended to search @INC.\n>\n> Documentation says \"If you are absolutely certain that you want your\n> script to load and execute a file from the current directory, then use\n> a ./ prefix\".  We can do that, like so:\n>\n> diff --git i/gitweb/Makefile w/gitweb/Makefile\n> index cd194d057f..3160b6cc5d 100644\n> --- i/gitweb/Makefile\n> +++ w/gitweb/Makefile\n> @@ -18,7 +18,7 @@ RM ?= rm -f\n>  INSTALL ?= install\n>\n>  # default configuration for gitweb\n> -GITWEB_CONFIG = gitweb_config.perl\n> +GITWEB_CONFIG = ./gitweb_config.perl\n>  GITWEB_CONFIG_SYSTEM = /etc/gitweb.conf\n>  GITWEB_CONFIG_COMMON = /etc/gitweb-common.conf\n>  GITWEB_HOME_LINK_STR = projects\n>\n> but that does not help if someone overrides GITWEB_CONFIG, and besides,\n> it would be nicer to avoid the possibility of an @INC search altogether.\n> Another alternative would be to use\n>\n> \tlocal @INC = ('.');\n>\n> Would that be better?\n>\n> Advice from someone more versed than I am in perl would be very welcome\n> (hence the cc to Ævar).\n\nIt seems most sensible to follow the ./FILE.pl advice per\nhttps://metacpan.org/pod/distribution/perl/pod/perl5260delta.pod#Removal-of-the-current-directory-(%22.%22)-from-@INC\n\nJust:\n\n    local @INC = '.';\n    do 'FILE.pl';\n\nWould do the same thing, but seems like a more indirect way to do it if\nall we want is ./ anyway. FWIW to be pedantically bug-compatible with\nthe old version (we should not do this) it's:\n\n    local @INC = (@INC, \".\");\n    do 'FILE.pl';\n\nI.e. before our behavior was implicitly to check whether we had a local\nFILE.pl, then loop through all of @INC to see if we found it there, and\nfinally come back to the file we did the -e check for.\n"},{"id":"364663","messageId":"xmqq5zw7bhgv.fsf@gitster-ct.c.googlers.com","threadId":"49950","inReplyTo":"87bm5zzt4a.fsf@evledraar.gmail.com","subject":"Re: gitweb: local configuration not found","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-12-06T00:56:48Z","receivedAt":"2018-12-06T00:56:57Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n>> Documentation says \"If you are absolutely certain that you want your\n>> script to load and execute a file from the current directory, then use\n>> a ./ prefix\".  We can do that, like so:\n>>\n>> diff --git i/gitweb/Makefile w/gitweb/Makefile\n>> index cd194d057f..3160b6cc5d 100644\n>> --- i/gitweb/Makefile\n>> +++ w/gitweb/Makefile\n>> @@ -18,7 +18,7 @@ RM ?= rm -f\n>>  INSTALL ?= install\n>>\n>>  # default configuration for gitweb\n>> -GITWEB_CONFIG = gitweb_config.perl\n>> +GITWEB_CONFIG = ./gitweb_config.perl\n>>  GITWEB_CONFIG_SYSTEM = /etc/gitweb.conf\n>>  GITWEB_CONFIG_COMMON = /etc/gitweb-common.conf\n>>  GITWEB_HOME_LINK_STR = projects\n>>\n>> but that does not help if someone overrides GITWEB_CONFIG, and besides,\n>> it would be nicer to avoid the possibility of an @INC search altogether.\n>> ...\n> Just:\n>\n>     local @INC = '.';\n>     do 'FILE.pl';\n>\n> Would do the same thing, but seems like a more indirect way to do it if\n> all we want is ./ anyway.\n\nYeah, it does look indirect.  Despite what you said, it also would\nsupport users giving an absolute path via GITWEB_CONFIG.\n\nWith \"use File::Spec\", perhaps something like this?\n\n gitweb/gitweb.perl | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 2594a4badb..239e7cbc25 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -719,6 +719,10 @@ sub filter_and_validate_refs {\n sub read_config_file {\n \tmy $filename = shift;\n \treturn unless defined $filename;\n+\n+\t$filename = File::Spec->catfile(\".\", $filename)\n+\t\tunless File::Spec->file_name_is_absolute($filename);\n+\n \t# die if there are errors parsing config file\n \tif (-e $filename) {\n \t\tdo $filename;\n"},{"id":"364690","messageId":"mj+md-20181206.150151.76906.nikam@ucw.cz","threadId":"49950","inReplyTo":"xmqq5zw7bhgv.fsf@gitster-ct.c.googlers.com","subject":"Re: gitweb: local configuration not found","fromName":"Martin Mareš","fromEmail":"mj@ucw.cz","sentAt":"2018-12-06T15:02:12Z","receivedAt":"2018-12-06T15:08:12Z","isPatch":false,"sender":{"key":"mj@ucw.cz","avatar":null},"body":"Hello!\n\n> Yeah, it does look indirect.  Despite what you said, it also would\n> support users giving an absolute path via GITWEB_CONFIG.\n> \n> With \"use File::Spec\", perhaps something like this?\n\nYes, this looks right.\n\n\t\t\t\tMartin\n"}]}