Index: bin/pg_dump/pg_backup_tar.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v retrieving revision 1.50 diff -c -r1.50 pg_backup_tar.c *** bin/pg_dump/pg_backup_tar.c 12 Feb 2006 06:11:50 -0000 1.50 --- bin/pg_dump/pg_backup_tar.c 21 Apr 2006 09:22:00 -0000 *************** *** 362,368 **** --- 362,388 ---- { tm = calloc(1, sizeof(TAR_MEMBER)); + #ifndef WIN32 tm->tmpFH = tmpfile(); + #else + /* on win32, tmpfile() generates a filename in the root directory, which requires + * administrative permissions to write to. */ + while (1) + { + char *tmpname; + int fd; + + tmpname = _tempnam(NULL, "pg_temp_"); + if (tmpname == NULL) + break; + fd = _open(tmpname, _O_RDWR | _O_CREAT | _O_EXCL | _O_BINARY | _O_TEMPORARY, _S_IREAD | _S_IWRITE); + free(tmpname); + if (fd == -1 && errno == EEXIST) + continue; /* Try again with a new name if file exists */ + if (fd != -1) + tm->tmpFH = _fdopen(fd, "w+b"); + break; + } + #endif if (tm->tmpFH == NULL) die_horribly(AH, modulename, "could not generate temporary file name: %s\n", strerror(errno));