]> granicus.if.org Git - postgresql/commit
Avoid choosing "localtime" or "posixrules" as TimeZone during initdb.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 26 Jul 2019 16:45:32 +0000 (12:45 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 26 Jul 2019 16:46:15 +0000 (12:46 -0400)
commit9ef8117420d49ee70d50b19a862607def58ab560
tree17ef247e6ec5e6f0fc0d32bf0c2b5945e5d51585
parent13e493cf68a4ed8a54e974c41470fab43676e67c
Avoid choosing "localtime" or "posixrules" as TimeZone during initdb.

Some platforms create a file named "localtime" in the system
timezone directory, making it a copy or link to the active time
zone file.  If Postgres is built with --with-system-tzdata, initdb
will see that file as an exact match to localtime(3)'s behavior,
and it may decide that "localtime" is the most preferred spelling of
the active zone.  That's a very bad choice though, because it's
neither informative, nor portable, nor stable if someone changes
the system timezone setting.  Extend the preference logic added by
commit e3846a00c so that we will prefer any other zone file that
matches localtime's behavior over "localtime".

On the same logic, also discriminate against "posixrules", which
is another not-really-a-zone file that is often present in the
timezone directory.  (Since we install "posixrules" but not
"localtime", this change can affect the behavior of Postgres
with or without --with-system-tzdata.)

Note that this change doesn't prevent anyone from choosing these
pseudo-zones if they really want to (i.e., by setting TZ for initdb,
or modifying the timezone GUC later on).  It just prevents initdb
from preferring these zone names when there are multiple matches to
localtime's behavior.

Since we generally prefer to keep timezone-related behavior the
same in all branches, and since this is arguably a bug fix,
back-patch to all supported branches.

Discussion: https://postgr.es/m/CADT4RqCCnj6FKLisvT8tTPfTP4azPhhDFJqDF1JfBbOH5w4oyQ@mail.gmail.com
Discussion: https://postgr.es/m/27991.1560984458@sss.pgh.pa.us
src/bin/initdb/findtimezone.c