aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_upgrade/dump.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2018-02-05 10:58:27 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2018-02-05 10:58:27 -0500
commita926eb84e07a604da6d059eca1fd87f919bb5d7a (patch)
tree5545d4df5477f7ae50455916f3348f4d78f6ac8a /src/bin/pg_upgrade/dump.c
parent3492a0af0bd37e7f23e27fd3f5537f414ee9ab9b (diff)
downloadpostgresql-a926eb84e07a604da6d059eca1fd87f919bb5d7a.tar.gz
postgresql-a926eb84e07a604da6d059eca1fd87f919bb5d7a.zip
Ensure that all temp files made during pg_upgrade are non-world-readable.
pg_upgrade has always attempted to ensure that the transient dump files it creates are inaccessible except to the owner. However, refactoring in commit 76a7650c4 broke that for the file containing "pg_dumpall -g" output; since then, that file was protected according to the process's default umask. Since that file may contain role passwords (hopefully encrypted, but passwords nonetheless), this is a particularly unfortunate oversight. Prudent users of pg_upgrade on multiuser systems would probably run it under a umask tight enough that the issue is moot, but perhaps some users are depending only on pg_upgrade's umask changes to protect their data. To fix this in a future-proof way, let's just tighten the umask at process start. There are no files pg_upgrade needs to write at a weaker security level; and if there were, transiently relaxing the umask around where they're created would be a safer approach. Report and patch by Tom Lane; the idea for the fix is due to Noah Misch. Back-patch to all supported branches. Security: CVE-2018-1053
Diffstat (limited to 'src/bin/pg_upgrade/dump.c')
-rw-r--r--src/bin/pg_upgrade/dump.c10
1 files changed, 0 insertions, 10 deletions
diff --git a/src/bin/pg_upgrade/dump.c b/src/bin/pg_upgrade/dump.c
index 8a662e9865d..def22c65211 100644
--- a/src/bin/pg_upgrade/dump.c
+++ b/src/bin/pg_upgrade/dump.c
@@ -18,7 +18,6 @@ void
generate_old_dump(void)
{
int dbnum;
- mode_t old_umask;
prep_status("Creating dump of global objects");
@@ -33,13 +32,6 @@ 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++)
{
@@ -74,8 +66,6 @@ generate_old_dump(void)
while (reap_child(true) == true)
;
- umask(old_umask);
-
end_progress_output();
check_ok();
}