From: Tom Lane Date: Tue, 18 Jul 2006 22:36:46 +0000 (+0000) Subject: copydir() and rmtree() need to use lstat, not stat, to behave as expected X-Git-Url: http://waps.l3s.uni-hannover.de/gitweb/?a=commitdiff_plain;h=ae432fc211fd4ad53f41a8a5cddd12f1dd45ff12;p=users%2Fbernd%2Fpostgres.git 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. --- diff --git a/src/port/copydir.c b/src/port/copydir.c index 45659864cd..023b46dda7 100644 --- a/src/port/copydir.c +++ b/src/port/copydir.c @@ -75,7 +75,7 @@ copydir(char *fromdir, char *todir, bool recurse) snprintf(fromfile, MAXPGPATH, "%s/%s", fromdir, xlde->d_name); snprintf(tofile, MAXPGPATH, "%s/%s", todir, xlde->d_name); - if (stat(fromfile, &fst) < 0) + if (lstat(fromfile, &fst) < 0) ereport(ERROR, (errcode_for_file_access(), errmsg("could not stat file \"%s\": %m", fromfile))); diff --git a/src/port/dirmod.c b/src/port/dirmod.c index 14f42daa7a..292a6d103b 100644 --- a/src/port/dirmod.c +++ b/src/port/dirmod.c @@ -434,7 +434,7 @@ rmtree(char *path, bool rmtopdir) { snprintf(filepath, MAXPGPATH, "%s/%s", path, *filename); - if (stat(filepath, &statbuf) != 0) + if (lstat(filepath, &statbuf) != 0) goto report_and_fail; if (S_ISDIR(statbuf.st_mode))