Re: BUG #15120: use of getcwd(3)/chdir(2) during path resolution (exec.c) - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #15120: use of getcwd(3)/chdir(2) during path resolution (exec.c)
Date
Msg-id 7607.1521309974@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #15120: use of getcwd(3)/chdir(2) during path resolution (exec.c)  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
Responses Re: BUG #15120: use of getcwd(3)/chdir(2) during path resolution (exec.c)
List pgsql-bugs
Andrew Gierth <andrew@tao11.riddles.org.uk> writes:
> "Tom" == Tom Lane <tgl@sss.pgh.pa.us> writes:
>  Tom> ... I find that quite an unacceptable answer. We need to resolve
>  Tom> the symlink correctly, or we risk malfunctioning later, for the
>  Tom> reasons recited in the comment for find_my_exec().

> On systems with openat(), would it not be possible to resolve symlinks
> without ever needing chdir?

Um ... AFAICS, openat() just opens a file, it doesn't give back a
resolved path.  Did you mean readlinkat()?

In any case, we'd still need to support logic that doesn't rely on
non-portable functions.  The (vague) idea I had was to try a little harder
to build absolute paths for ourselves instead of letting the system do it.
I believe for instance that canonicalize_path() has more smarts now about
shortening paths like /foo/bar/baz/../../quux than it did when these
functions were written, so we might be able to rely on just concatenating
paths and then canonicalizing the result.  (OTOH, I think there are
filesystems where this wouldn't necessarily yield a nice answer, due to
multiple mounts and suchlike.)

            regards, tom lane


pgsql-bugs by date:

Previous
From: Andrew Gierth
Date:
Subject: Re: BUG #15120: use of getcwd(3)/chdir(2) during path resolution (exec.c)
Next
From: Petar Bogdanovic
Date:
Subject: Re: BUG #15120: use of getcwd(3)/chdir(2) during path resolution(exec.c)