Skip to content

Commit c69e7d5

Browse files
committed
Skip recently-added umask() call on Windows.
Symbols S_IRWXG and S_IRWXO became available to Windows builds in commit 1319002, so PostgreSQL 9.0 cannot use them in platform-independent code. Rewrite commit 24aed21 to not change Windows builds. The new umask() call had no effect on Windows, anyway. Per buildfarm.
1 parent 68e83c1 commit c69e7d5

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/bin/pg_dump/pg_backup_tar.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -375,20 +375,23 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode)
375375
}
376376
else
377377
{
378-
int old_umask;
379-
380378
tm = calloc(1, sizeof(TAR_MEMBER));
381379

382-
/*
383-
* POSIX does not require, but permits, tmpfile() to restrict file
384-
* permissions. Given an OS crash after we write data, the filesystem
385-
* might retain the data but forget tmpfile()'s unlink(). If so, the
386-
* file mode protects confidentiality of the data written.
387-
*/
388-
old_umask = umask(S_IRWXG | S_IRWXO);
389-
390380
#ifndef WIN32
391-
tm->tmpFH = tmpfile();
381+
{
382+
int old_umask;
383+
384+
/*
385+
* POSIX does not require, but permits, tmpfile() to restrict file
386+
* permissions. Given an OS crash after we write data, the
387+
* filesystem might retain the data but forget tmpfile()'s
388+
* unlink(). If so, the file mode protects confidentiality of the
389+
* data written.
390+
*/
391+
old_umask = umask(S_IRWXG | S_IRWXO);
392+
tm->tmpFH = tmpfile();
393+
umask(old_umask);
394+
}
392395
#else
393396

394397
/*
@@ -421,8 +424,6 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode)
421424
if (tm->tmpFH == NULL)
422425
die_horribly(AH, modulename, "could not generate temporary file name: %s\n", strerror(errno));
423426

424-
umask(old_umask);
425-
426427
#ifdef HAVE_LIBZ
427428

428429
if (AH->compression != 0)

0 commit comments

Comments
 (0)