pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix readlink() for non-PostgreSQL junction points on Windows. 4+ messages / 2 participants [nested] [flat]
* pgsql: Fix readlink() for non-PostgreSQL junction points on Windows. @ 2022-10-25 03:29 Thomas Munro <tmunro@postgresql.org> 0 siblings, 0 replies; 4+ messages in thread From: Thomas Munro @ 2022-10-25 03:29 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix readlink() for non-PostgreSQL junction points on Windows. Since commit c5cb8f3b taught stat() to follow symlinks, and since initdb uses pg_mkdir_p(), and that examines parent directories, our humble readlink() implementation can now be exposed to junction points not of PostgreSQL origin. Those might be corrupted by our naive path mangling, which doesn't really understand NT paths in general. Simply decline to transform paths that don't look like a drive absolute path. That means that readlink() returns the NT path directly when checking a parent directory of PGDATA that happen to point to a drive using "rooted" format. That works for the purposes of our stat() emulation. Reported-by: Roman Zharkov <r.zharkov@postgrespro.ru> Reviewed-by: Roman Zharkov <r.zharkov@postgrespro.ru> Discussion: https://postgr.es/m/4590c37927d7b8ee84f9855d83229018%40postgrespro.ru Discussion: https://postgr.es/m/CA%2BhUKG%2BajSQ_8eu2AogTncOnZ5me2D-Cn66iN_-wZnRjLN%2Bicg%40mail.gmail.com Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/f71007fbb3b83fba21daae9144cc07e205f2365c Modified Files -------------- src/port/dirmod.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix readlink() for non-PostgreSQL junction points on Windows. @ 2025-01-18 14:34 Andrew Dunstan <andrew@dunslane.net> 0 siblings, 0 replies; 4+ messages in thread From: Andrew Dunstan @ 2025-01-18 14:34 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix readlink() for non-PostgreSQL junction points on Windows. Since commit c5cb8f3b taught stat() to follow symlinks, and since initdb uses pg_mkdir_p(), and that examines parent directories, our humble readlink() implementation can now be exposed to junction points not of PostgreSQL origin. Those might be corrupted by our naive path mangling, which doesn't really understand NT paths in general. Simply decline to transform paths that don't look like a drive absolute path. That means that readlink() returns the NT path directly when checking a parent directory of PGDATA that happen to point to a drive using "rooted" format. That works for the purposes of our stat() emulation. Reported-by: Roman Zharkov <r.zharkov@postgrespro.ru> Reviewed-by: Roman Zharkov <r.zharkov@postgrespro.ru> Discussion: https://postgr.es/m/4590c37927d7b8ee84f9855d83229018%40postgrespro.ru Discussion: https://postgr.es/m/CA%2BhUKG%2BajSQ_8eu2AogTncOnZ5me2D-Cn66iN_-wZnRjLN%2Bicg%40mail.gmail.com Backpatched commit f71007fb as above by Thomas Munro into releases 13 thru 15 Discussion: https://postgr.es/m/CA+hUKGLbnv+pe3q1fYOVkLD3pMra7GuihfMxUN-1831YH9RYQg@mail.gmail.com Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/9b136b0f2e531e41d1949fba3f618405adfcef02 Author: Thomas Munro <tmunro@postgresql.org> Modified Files -------------- src/port/dirmod.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix readlink() for non-PostgreSQL junction points on Windows. @ 2025-01-18 14:34 Andrew Dunstan <andrew@dunslane.net> 0 siblings, 0 replies; 4+ messages in thread From: Andrew Dunstan @ 2025-01-18 14:34 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix readlink() for non-PostgreSQL junction points on Windows. Since commit c5cb8f3b taught stat() to follow symlinks, and since initdb uses pg_mkdir_p(), and that examines parent directories, our humble readlink() implementation can now be exposed to junction points not of PostgreSQL origin. Those might be corrupted by our naive path mangling, which doesn't really understand NT paths in general. Simply decline to transform paths that don't look like a drive absolute path. That means that readlink() returns the NT path directly when checking a parent directory of PGDATA that happen to point to a drive using "rooted" format. That works for the purposes of our stat() emulation. Reported-by: Roman Zharkov <r.zharkov@postgrespro.ru> Reviewed-by: Roman Zharkov <r.zharkov@postgrespro.ru> Discussion: https://postgr.es/m/4590c37927d7b8ee84f9855d83229018%40postgrespro.ru Discussion: https://postgr.es/m/CA%2BhUKG%2BajSQ_8eu2AogTncOnZ5me2D-Cn66iN_-wZnRjLN%2Bicg%40mail.gmail.com Backpatched commit f71007fb as above by Thomas Munro into releases 13 thru 15 Discussion: https://postgr.es/m/CA+hUKGLbnv+pe3q1fYOVkLD3pMra7GuihfMxUN-1831YH9RYQg@mail.gmail.com Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/f4fd5325cc870cc7563703ed2dc3661139cf5d13 Author: Thomas Munro <tmunro@postgresql.org> Modified Files -------------- src/port/dirmod.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix readlink() for non-PostgreSQL junction points on Windows. @ 2025-01-18 14:34 Andrew Dunstan <andrew@dunslane.net> 0 siblings, 0 replies; 4+ messages in thread From: Andrew Dunstan @ 2025-01-18 14:34 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix readlink() for non-PostgreSQL junction points on Windows. Since commit c5cb8f3b taught stat() to follow symlinks, and since initdb uses pg_mkdir_p(), and that examines parent directories, our humble readlink() implementation can now be exposed to junction points not of PostgreSQL origin. Those might be corrupted by our naive path mangling, which doesn't really understand NT paths in general. Simply decline to transform paths that don't look like a drive absolute path. That means that readlink() returns the NT path directly when checking a parent directory of PGDATA that happen to point to a drive using "rooted" format. That works for the purposes of our stat() emulation. Reported-by: Roman Zharkov <r.zharkov@postgrespro.ru> Reviewed-by: Roman Zharkov <r.zharkov@postgrespro.ru> Discussion: https://postgr.es/m/4590c37927d7b8ee84f9855d83229018%40postgrespro.ru Discussion: https://postgr.es/m/CA%2BhUKG%2BajSQ_8eu2AogTncOnZ5me2D-Cn66iN_-wZnRjLN%2Bicg%40mail.gmail.com Backpatched commit f71007fb as above by Thomas Munro into releases 13 thru 15 Discussion: https://postgr.es/m/CA+hUKGLbnv+pe3q1fYOVkLD3pMra7GuihfMxUN-1831YH9RYQg@mail.gmail.com Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/2c4a532c96a948e26b25e3260d155c1ec245c2ae Author: Thomas Munro <tmunro@postgresql.org> Modified Files -------------- src/port/dirmod.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2025-01-18 14:34 UTC | newest] Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2022-10-25 03:29 pgsql: Fix readlink() for non-PostgreSQL junction points on Windows. Thomas Munro <tmunro@postgresql.org> 2025-01-18 14:34 pgsql: Fix readlink() for non-PostgreSQL junction points on Windows. Andrew Dunstan <andrew@dunslane.net> 2025-01-18 14:34 pgsql: Fix readlink() for non-PostgreSQL junction points on Windows. Andrew Dunstan <andrew@dunslane.net> 2025-01-18 14:34 pgsql: Fix readlink() for non-PostgreSQL junction points on Windows. Andrew Dunstan <andrew@dunslane.net>
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