diff options
author | Tom Lane | 2015-05-29 21:02:58 +0000 |
---|---|---|
committer | Tom Lane | 2015-05-29 21:02:58 +0000 |
commit | 99f50dd720de59872bd842be3ec8eecea2be4b92 (patch) | |
tree | 15796a72c5daad4653e9bd2eacc9945a5df4b243 | |
parent | 70a4519b82beee9e7bffb17ae4e6d81bb3ab89d8 (diff) |
initdb -S should now have an explicit check that $PGDATA is valid.
The fsync code from the backend essentially assumes that somebody's already
validated PGDATA, at least to the extent of it being a readable directory.
That's safe enough for initdb's normal code path too, but "initdb -S"
doesn't have any other processing at all that touches the target directory.
To have reasonable error-case behavior, add a pg_check_dir call.
Per gripe from Peter E.
-rw-r--r-- | src/bin/initdb/initdb.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index 57f5f89dd94..85dfd085272 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -3726,10 +3726,19 @@ main(int argc, char *argv[]) exit(1); } - /* If we only need to fsync, just to it and exit */ + /* If we only need to fsync, just do it and exit */ if (sync_only) { setup_pgdata(); + + /* must check that directory is readable */ + if (pg_check_dir(pg_data) <= 0) + { + fprintf(stderr, _("%s: could not access directory \"%s\": %s\n"), + progname, pg_data, strerror(errno)); + exit_nicely(); + } + fsync_pgdata(); return 0; } |