Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8829524

Browse files
committed
copydir() and rmtree() need to use lstat, not stat, to behave as expected
with symlinks. Noted while trying to use rmtree in new C-code pg_regress.
1 parent 11b7aec commit 8829524

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/port/copydir.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* as a service.
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/port/copydir.c,v 1.17 2006/03/05 15:59:10 momjian Exp $
14+
* $PostgreSQL: pgsql/src/port/copydir.c,v 1.18 2006/07/18 22:36:46 tgl Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -75,7 +75,7 @@ copydir(char *fromdir, char *todir, bool recurse)
7575
snprintf(fromfile, MAXPGPATH, "%s/%s", fromdir, xlde->d_name);
7676
snprintf(tofile, MAXPGPATH, "%s/%s", todir, xlde->d_name);
7777

78-
if (stat(fromfile, &fst) < 0)
78+
if (lstat(fromfile, &fst) < 0)
7979
ereport(ERROR,
8080
(errcode_for_file_access(),
8181
errmsg("could not stat file \"%s\": %m", fromfile)));

src/port/dirmod.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Win32 (NT, Win2k, XP). replace() doesn't work on Win95/98/Me.
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/port/dirmod.c,v 1.42 2006/03/05 15:59:10 momjian Exp $
13+
* $PostgreSQL: pgsql/src/port/dirmod.c,v 1.43 2006/07/18 22:36:46 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -434,7 +434,7 @@ rmtree(char *path, bool rmtopdir)
434434
{
435435
snprintf(filepath, MAXPGPATH, "%s/%s", path, *filename);
436436

437-
if (stat(filepath, &statbuf) != 0)
437+
if (lstat(filepath, &statbuf) != 0)
438438
goto report_and_fail;
439439

440440
if (S_ISDIR(statbuf.st_mode))

0 commit comments

Comments
 (0)