Commit c98c35cd authored by Tom Lane's avatar Tom Lane

Avoid putting build-location-dependent strings into generated files.

Various Perl scripts we use to generate files were in the habit of
printing things like "generated by $0" into their output files.
That looks like a fine idea at first glance, but it results in
non-reproducible output, because in VPATH builds $0 won't be just
the name of the script file, but a full path for it.  We'd prefer
that you get identical results whether using VPATH or not, so this
is a bad thing.

Some of these places also printed their input file name(s), causing
an additional hazard of the same type.

Hence, establish a policy that thou shalt not print $0, nor input file
pathnames, into output files (they're still allowed in error messages,
though).  Instead just write the script name verbatim.  While we are at
it, we can make these annotations more useful by giving the script's
full relative path name within the PG source tree, eg instead of
Gen_fmgrtab.pl let's print src/backend/utils/Gen_fmgrtab.pl.

Not all of the changes made here actually affect any files shipped
in finished tarballs today, but it seems best to apply the policy
everyplace so that nobody copies unsafe code into places where it
could matter.

Christoph Berg and Tom Lane

Discussion: https://postgr.es/m/20171215102223.GB31812@msg.df7cb.de
parent 59d1e2b9
...@@ -340,7 +340,7 @@ print $schemapg <<EOM; ...@@ -340,7 +340,7 @@ print $schemapg <<EOM;
* *** DO NOT EDIT THIS FILE! *** * *** DO NOT EDIT THIS FILE! ***
* ****************************** * ******************************
* *
* It has been GENERATED by $0 * It has been GENERATED by src/backend/catalog/genbki.pl
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -118,8 +118,7 @@ qq|/*------------------------------------------------------------------------- ...@@ -118,8 +118,7 @@ qq|/*-------------------------------------------------------------------------
* *** DO NOT EDIT THIS FILE! *** * *** DO NOT EDIT THIS FILE! ***
* ****************************** * ******************************
* *
* It has been GENERATED by $0 * It has been GENERATED by src/backend/utils/Gen_fmgrtab.pl
* from $infile
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -153,8 +152,7 @@ qq|/*------------------------------------------------------------------------- ...@@ -153,8 +152,7 @@ qq|/*-------------------------------------------------------------------------
* *** DO NOT EDIT THIS FILE! *** * *** DO NOT EDIT THIS FILE! ***
* ****************************** * ******************************
* *
* It has been GENERATED by $0 * It has been GENERATED by src/backend/utils/Gen_fmgrtab.pl
* from $infile
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -181,8 +179,7 @@ qq|/*------------------------------------------------------------------------- ...@@ -181,8 +179,7 @@ qq|/*-------------------------------------------------------------------------
* *** DO NOT EDIT THIS FILE! *** * *** DO NOT EDIT THIS FILE! ***
* ****************************** * ******************************
* *
* It has been GENERATED by $0 * It has been GENERATED by src/backend/utils/Gen_fmgrtab.pl
* from $infile
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
use strict; use strict;
use convutils; use convutils;
my $this_script = $0; my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_BIG5.pl';
# Load BIG5.TXT # Load BIG5.TXT
my $all = &read_source("BIG5.TXT"); my $all = &read_source("BIG5.TXT");
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
use strict; use strict;
use convutils; use convutils;
my $this_script = $0; my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_EUC_CN.pl';
# Read the input # Read the input
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
use strict; use strict;
use convutils; use convutils;
my $this_script = $0; my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_EUC_JIS_2004.pl';
# first generate UTF-8 --> EUC_JIS_2004 table # first generate UTF-8 --> EUC_JIS_2004 table
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
use strict; use strict;
use convutils; use convutils;
my $this_script = $0; my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_EUC_JP.pl';
# Load JIS0212.TXT # Load JIS0212.TXT
my $jis0212 = &read_source("JIS0212.TXT"); my $jis0212 = &read_source("JIS0212.TXT");
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
use strict; use strict;
use convutils; use convutils;
my $this_script = $0; my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_EUC_KR.pl';
# Load the source file. # Load the source file.
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
use strict; use strict;
use convutils; use convutils;
my $this_script = $0; my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_EUC_TW.pl';
my $mapping = &read_source("CNS11643.TXT"); my $mapping = &read_source("CNS11643.TXT");
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
use strict; use strict;
use convutils; use convutils;
my $this_script = $0; my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_GB18030.pl';
# Read the input # Read the input
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
use strict; use strict;
use convutils; use convutils;
my $this_script = $0; my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_JOHAB.pl';
# Load the source file. # Load the source file.
......
...@@ -12,7 +12,7 @@ use convutils; ...@@ -12,7 +12,7 @@ use convutils;
# first generate UTF-8 --> SHIFT_JIS_2004 table # first generate UTF-8 --> SHIFT_JIS_2004 table
my $this_script = $0; my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_SHIFT_JIS_2004.pl';
my $in_file = "sjis-0213-2004-std.txt"; my $in_file = "sjis-0213-2004-std.txt";
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
use strict; use strict;
use convutils; use convutils;
my $this_script = $0; my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_SJIS.pl';
my $mapping = read_source("CP932.TXT"); my $mapping = read_source("CP932.TXT");
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
use strict; use strict;
use convutils; use convutils;
my $this_script = $0; my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_UHC.pl';
# Read the input # Read the input
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
use strict; use strict;
use convutils; use convutils;
my $this_script = $0; my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_most.pl';
my %filename = ( my %filename = (
'WIN866' => 'CP866.TXT', 'WIN866' => 'CP866.TXT',
......
...@@ -51,8 +51,7 @@ print $hfile_handle "/* ...@@ -51,8 +51,7 @@ print $hfile_handle "/*
* *** Do not change this file by hand. It is automatically * *** Do not change this file by hand. It is automatically
* *** generated from the DocBook documentation. * *** generated from the DocBook documentation.
* *
* generated by * generated by src/bin/psql/create_help.pl
* $^X $0 @ARGV
* *
*/ */
...@@ -76,8 +75,7 @@ print $cfile_handle "/* ...@@ -76,8 +75,7 @@ print $cfile_handle "/*
* *** Do not change this file by hand. It is automatically * *** Do not change this file by hand. It is automatically
* *** generated from the DocBook documentation. * *** generated from the DocBook documentation.
* *
* generated by * generated by src/bin/psql/create_help.pl
* $^X $0 @ARGV
* *
*/ */
...@@ -131,7 +129,7 @@ foreach my $file (sort readdir DIR) ...@@ -131,7 +129,7 @@ foreach my $file (sort readdir DIR)
my $nl_count = () = $cmdsynopsis =~ /\n/g; my $nl_count = () = $cmdsynopsis =~ /\n/g;
$cmdsynopsis =~ m!</>! $cmdsynopsis =~ m!</>!
and die "$0:$file: null end tag not supported in synopsis\n"; and die "$0: $file: null end tag not supported in synopsis\n";
$cmdsynopsis =~ s/%/%%/g; $cmdsynopsis =~ s/%/%%/g;
while ($cmdsynopsis =~ m!<(\w+)[^>]*>(.+?)</\1[^>]*>!) while ($cmdsynopsis =~ m!<(\w+)[^>]*>(.+?)</\1[^>]*>!)
......
...@@ -40,7 +40,7 @@ die "No text files specified" ...@@ -40,7 +40,7 @@ die "No text files specified"
print qq{ print qq{
/* /*
* DO NOT EDIT - THIS FILE IS AUTOGENERATED - CHANGES WILL BE LOST * DO NOT EDIT - THIS FILE IS AUTOGENERATED - CHANGES WILL BE LOST
* Written by $0 from @ARGV * Generated by src/pl/plperl/text2macro.pl
*/ */
}; };
......
...@@ -66,7 +66,7 @@ BEGIN ...@@ -66,7 +66,7 @@ BEGIN
delete $ENV{PGPORT}; delete $ENV{PGPORT};
delete $ENV{PGHOST}; delete $ENV{PGHOST};
$ENV{PGAPPNAME} = $0; $ENV{PGAPPNAME} = basename($0);
# Must be set early # Must be set early
$windows_os = $Config{osname} eq 'MSWin32' || $Config{osname} eq 'msys'; $windows_os = $Config{osname} eq 'MSWin32' || $Config{osname} eq 'msys';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment