From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Make canonicalize_path() more canonical.
Date: Mon, 31 Jan 2022 17:05:43 +0000
Message-ID: <E1nEa7b-0004fm-Hp@gemulon.postgresql.org> (raw)
Make canonicalize_path() more canonical.
Teach canonicalize_path() how to strip all unnecessary uses of "."
and "..", replacing the previous ad-hoc code that got rid of only
some such cases. In particular, we can always remove all such
uses from absolute paths.
The proximate reason to do this is that Windows rejects paths
involving ".." in some cases (in particular, you can't put one in a
symlink), so we ought to be sure we don't use ".." unnecessarily.
Moreover, it seems like good cleanup on general principles.
There is other path-munging code that could be simplified now, but
we'll leave that for followup work.
It is tempting to call this a bug fix and back-patch it. On the other
hand, the misbehavior can only be reached if a highly privileged user
does something dubious, so it's not unreasonable to say "so don't do
that". And this patch could result in unexpected behavioral changes,
in case anybody was expecting uses of ".." to stay put. So at least
for now, just put it in HEAD.
Shenhao Wang, editorialized a bit by me
Discussion: https://postgr.es/m/OSBPR01MB4214FA221FFE046F11F2AD74F2D49@OSBPR01MB4214.jpnprd01.prod.outlook.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/c10f830c511f0ba3e6f4c9d99f444d39e30440c8
Modified Files
--------------
contrib/adminpack/expected/adminpack.out | 2 +-
src/port/path.c | 258 +++++++++++++++++++-----
src/test/regress/expected/create_function_1.out | 4 +
src/test/regress/expected/misc_functions.out | 135 +++++++++++++
src/test/regress/regress.c | 10 +
src/test/regress/sql/create_function_1.sql | 5 +
src/test/regress/sql/misc_functions.sql | 27 +++
7 files changed, 387 insertions(+), 54 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us
Subject: Re: pgsql: Make canonicalize_path() more canonical.
In-Reply-To: <E1nEa7b-0004fm-Hp@gemulon.postgresql.org>
References: <E1nEa7b-0004fm-Hp@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox