Re: Can we avoid chdir'ing in resolve_symlinks() ? - Mailing list pgsql-hackers

From Isaac Morland
Subject Re: Can we avoid chdir'ing in resolve_symlinks() ?
Date
Msg-id CAMsGm5cn+8Pdf8igAYAT601LmhsaT2ocASzaaM+1m-ro5zgwZg@mail.gmail.com
Whole thread Raw
In response to Can we avoid chdir'ing in resolve_symlinks() ?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Can we avoid chdir'ing in resolve_symlinks() ?
List pgsql-hackers
On Thu, 1 Sept 2022 at 19:39, Tom Lane <tgl@sss.pgh.pa.us> wrote:

This code was mine originally (336969e49), but I sure don't
remember why I wrote it like that.  I know we didn't have a
robust version of canonicalize_path() then, and that may have
been the main issue, but that offhand comment about mount
points bothers me.  But I can't reconstruct precisely what
I was worried about there.  The only contemporaneous discussion
thread I can find is [2], which doesn't go into coding details.

Does this happen in a context where we need to worried about the directory structure changing under us, either accidentally or maliciously?

I'm wondering because I understand cd'ing through the structure can avoid some of the related problems and might be the reason for doing it that way originally. My impression is that the modern equivalent would be to use openat() with O_PATH to step through the hierarchy. But then I'm not clear on how to get back to the absolute path, given a file descriptor for the final directory.


pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: windows resource files, bugs and what do we actually want
Next
From: Tom Lane
Date:
Subject: Re: Can we avoid chdir'ing in resolve_symlinks() ?