Skip to content

Commit f0c08ae

Browse files
committed
Remove 'optimization' to skip resolve_symlinks() when the found
executable file isn't itself a symlink. We still need to run the algorithm so that any directory symlinks in the path to the executable are replaced by a true path. Noticed this on seeing pg_config give me a completely wrong answer for --pkglibdir when I called it through a symlink to the installation bindir.
1 parent bad4897 commit f0c08ae

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/port/exec.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/port/exec.c,v 1.34 2004/12/20 17:40:59 tgl Exp $
12+
* $PostgreSQL: pgsql/src/port/exec.c,v 1.35 2004/12/24 16:55:43 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -272,8 +272,7 @@ find_my_exec(const char *argv0, char *retpath)
272272
/*
273273
* resolve_symlinks - resolve symlinks to the underlying file
274274
*
275-
* If path does not point to a symlink, leave it alone. If it does,
276-
* replace it by the absolute path to the referenced file.
275+
* Replace "path" by the absolute path to the referenced file.
277276
*
278277
* Returns 0 if OK, -1 if error.
279278
*
@@ -290,17 +289,17 @@ resolve_symlinks(char *path)
290289
link_buf[MAXPGPATH];
291290
char *fname;
292291

293-
/* Quick out if it's not a symlink */
294-
if (lstat(path, &buf) < 0 ||
295-
(buf.st_mode & S_IFMT) != S_IFLNK)
296-
return 0;
297-
298292
/*
299293
* To resolve a symlink properly, we have to chdir into its directory
300294
* and then chdir to where the symlink points; otherwise we may fail to
301295
* resolve relative links correctly (consider cases involving mount
302296
* points, for example). After following the final symlink, we use
303297
* getcwd() to figure out where the heck we're at.
298+
*
299+
* One might think we could skip all this if path doesn't point to a
300+
* symlink to start with, but that's wrong. We also want to get rid
301+
* of any directory symlinks that are present in the given path.
302+
* We expect getcwd() to give us an accurate, symlink-free path.
304303
*/
305304
if (!getcwd(orig_wd, MAXPGPATH))
306305
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy