aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2015-05-28 12:44:31 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2015-05-28 12:44:39 -0400
commit0381fefaa44f04e17dffb7e46e7677374a4fb2c7 (patch)
tree56cf8fd43aef04395af30a3f32ce7d9c4b8f4e23 /src
parente5f1a4f1e350f1e72531d032eaa9095ba5baeb51 (diff)
downloadpostgresql-0381fefaa44f04e17dffb7e46e7677374a4fb2c7.tar.gz
postgresql-0381fefaa44f04e17dffb7e46e7677374a4fb2c7.zip
Fix pg_rewind's handling of top-level symlinks.
The previous coding suffered a null-pointer dereference if it found any symlink at the top level of $PGDATA. Fix that, and teach it to recurse into a symlink for pg_xlog, but not anything else. Per note from Abhijit Menon-Sen.
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_rewind/copy_fetch.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/bin/pg_rewind/copy_fetch.c b/src/bin/pg_rewind/copy_fetch.c
index c92744ca772..1ca00d12adf 100644
--- a/src/bin/pg_rewind/copy_fetch.c
+++ b/src/bin/pg_rewind/copy_fetch.c
@@ -42,6 +42,9 @@ traverse_datadir(const char *datadir, process_file_callback_t callback)
/*
* recursive part of traverse_datadir
+ *
+ * parent_path is the current subdirectory's path relative to datadir,
+ * or NULL at the top level.
*/
static void
recurse_dir(const char *datadir, const char *parentpath,
@@ -127,9 +130,11 @@ recurse_dir(const char *datadir, const char *parentpath,
/*
* If it's a symlink within pg_tblspc, we need to recurse into it,
- * to process all the tablespaces.
+ * to process all the tablespaces. We also follow a symlink if
+ * it's for pg_xlog. Symlinks elsewhere are ignored.
*/
- if (strcmp(parentpath, "pg_tblspc") == 0)
+ if ((parentpath && strcmp(parentpath, "pg_tblspc") == 0) ||
+ strcmp(path, "pg_xlog") == 0)
recurse_dir(datadir, path, callback);
#else
pg_fatal("\"%s\" is a symbolic link, but symbolic links are not supported on this platform\n",