Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfe491fb

Browse files
committed
On Win32, use loop to create pg_dump temporary tar file in the current
directory, not in device root, for permission reasons.Backpatch to 8.1.X.
1 parent560feb4 commitfe491fb

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

‎src/bin/pg_dump/pg_backup_tar.c

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
*
1818
* IDENTIFICATION
19-
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.52 2006/06/07 22:24:44 momjian Exp $
19+
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.53 2006/06/27 01:16:58 momjian Exp $
2020
*
2121
*-------------------------------------------------------------------------
2222
*/
@@ -359,7 +359,35 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode)
359359
{
360360
tm=calloc(1,sizeof(TAR_MEMBER));
361361

362+
#ifndefWIN32
362363
tm->tmpFH=tmpfile();
364+
#else
365+
/*
366+
*On WIN32, tmpfile() generates a filename in the root directory,
367+
*which requires administrative permissions on certain systems.
368+
*Loop until we find a unique file name we can create.
369+
*/
370+
while (1)
371+
{
372+
char*name;
373+
intfd;
374+
375+
name=_tempnam(NULL,"pg_temp_");
376+
if (name==NULL)
377+
break;
378+
fd=open(name,O_RDWR |O_CREAT |O_EXCL |O_BINARY |
379+
O_TEMPORARY,S_IREAD |S_IWRITE);
380+
free(name);
381+
382+
if (fd!=-1)/* created a file */
383+
{
384+
tm->tmpFH=fdopen(fd,"w+b");
385+
break;
386+
}
387+
elseif (errno!=EEXIST)/* failure other than file exists */
388+
break;
389+
}
390+
#endif
363391

364392
if (tm->tmpFH==NULL)
365393
die_horribly(AH,modulename,"could not generate temporary file name: %s\n",strerror(errno));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp