We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
1 parentba51774 commit8346218Copy full SHA for 8346218
src/bin/pg_dump/pg_backup_tar.c
@@ -379,8 +379,18 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode)
379
}
380
else
381
{
382
+intold_umask;
383
+
384
tm=pg_malloc0(sizeof(TAR_MEMBER));
385
386
+/*
387
+ * POSIX does not require, but permits, tmpfile() to restrict file
388
+ * permissions. Given an OS crash after we write data, the filesystem
389
+ * might retain the data but forget tmpfile()'s unlink(). If so, the
390
+ * file mode protects confidentiality of the data written.
391
+ */
392
+old_umask=umask(S_IRWXG |S_IRWXO);
393
394
#ifndefWIN32
395
tm->tmpFH=tmpfile();
396
#else
@@ -415,6 +425,8 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode)
415
425
if (tm->tmpFH==NULL)
416
426
exit_horribly(modulename,"could not generate temporary file name: %s\n",strerror(errno));
417
427
428
+umask(old_umask);
429
418
430
#ifdefHAVE_LIBZ
419
431
420
432
if (AH->compression!=0)