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

From Tom Lane
Subject Re: Can we avoid chdir'ing in resolve_symlinks() ?
Date
Msg-id 1403451.1662218489@sss.pgh.pa.us
Whole thread Raw
In response to Re: Can we avoid chdir'ing in resolve_symlinks() ?  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: Can we avoid chdir'ing in resolve_symlinks() ?
List pgsql-hackers
Andrew Dunstan <andrew@dunslane.net> writes:
> On 2022-09-01 Th 19:39, Tom Lane wrote:
>> find_my_exec() wants to obtain an absolute, symlink-free path
>> to the program's own executable, for what seem to me good
>> reasons.  However, chasing down symlinks is left to its
>> subroutine resolve_symlinks(), which does this:

> These days there seem to be library functions that do this, realpath(3)
> and canonicalize_file_name(3). The latter is what seems to be called by
> readlink(1). Should we be using one of those?

Oh!  I see realpath() in POSIX, but not canonicalize_file_name().
It does look like realpath() would be helpful here, although if
it's not present on Windows that's a problem.

Quick googling suggests that _fullpath() could be used as a substitute.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: pg_basebackup's --gzip switch misbehaves
Next
From: Noah Misch
Date:
Subject: Re: Solaris "sed" versus pre-v13 plpython tests