1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

pg_upgrade: adjust umask() calls

Since pg_upgrade -j on Windows uses threads, calling umask()
before/after opening a file via fopen_priv() is no longer possible, so
set umask() as we enter the thread-creating loop, and reset it on exit.
Also adjust internal fopen_priv() calls to just use fopen().
Backpatch to 9.3beta.
This commit is contained in:
Bruce Momjian
2013-07-25 11:33:14 -04:00
parent b48f1dc2d3
commit 830d0e0edd
2 changed files with 13 additions and 8 deletions

View File

@ -17,6 +17,7 @@ void
generate_old_dump(void)
{
int dbnum;
mode_t old_umask;
prep_status("Creating dump of global objects");
@ -31,6 +32,13 @@ generate_old_dump(void)
prep_status("Creating dump of database schemas\n");
/*
* Set umask for this function, all functions it calls, and all
* subprocesses/threads it creates. We can't use fopen_priv()
* as Windows uses threads and umask is process-global.
*/
old_umask = umask(S_IRWXG | S_IRWXO);
/* create per-db dump files */
for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
{
@ -54,6 +62,8 @@ generate_old_dump(void)
while (reap_child(true) == true)
;
umask(old_umask);
end_progress_output();
check_ok();
}