Skip to content

Commit c2b68b1

Browse files
committed
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.
1 parent 35dd1b5 commit c2b68b1

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/bin/initdb/initdb.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3650,10 +3650,19 @@ main(int argc, char *argv[])
36503650
exit(1);
36513651
}
36523652

3653-
/* If we only need to fsync, just to it and exit */
3653+
/* If we only need to fsync, just do it and exit */
36543654
if (sync_only)
36553655
{
36563656
setup_pgdata();
3657+
3658+
/* must check that directory is readable */
3659+
if (pg_check_dir(pg_data) <= 0)
3660+
{
3661+
fprintf(stderr, _("%s: could not access directory \"%s\": %s\n"),
3662+
progname, pg_data, strerror(errno));
3663+
exit_nicely();
3664+
}
3665+
36573666
fsync_pgdata();
36583667
return 0;
36593668
}

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