Jan Wieck wrote: > On 6/9/2004 9:36 AM, Bruce Momjian wrote: > > > Jan Wieck wrote: > >> I am wondering why thread_test.c is checking for mktemp()? That function > >> is nowhere used in the libpq. > > > > Uh, it isn't checking for mktemp, it is using it, and it is using it > > because someone didn't like hard-coded paths I was using in the past. > > Is there something wrong with using mktemp? I have heard of no > > portability problems, except some need six X's, and we updated that. > > There seems to be a portability issue here. Stefan Kaltenbrunner > reported a configure failure on sparc64-unknown-openbsd3.5 and the > config.log says: > > /tmp//ccx22029.o: In function `main': > /tmp//ccx22029.o(.text+0x8c): warning: mktemp() possibly used unsafely; > consider > using mkstemp()
Yes, I was wondering how mktemp was going to guard against concurrent access. I have applied the following patch to use mkstemp(). > Which is only a warning at this time, it fails later on getpwuid(). Oh, I will need to hear more about that failure. -- Bruce Momjian | http://candle.pha.pa.us [EMAIL PROTECTED] | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073
Index: src/tools/thread/thread_test.c =================================================================== RCS file: /cvsroot/pgsql-server/src/tools/thread/thread_test.c,v retrieving revision 1.30 diff -c -c -r1.30 thread_test.c *** src/tools/thread/thread_test.c 28 May 2004 18:37:10 -0000 1.30 --- src/tools/thread/thread_test.c 9 Jun 2004 15:03:29 -0000 *************** *** 104,110 **** { pthread_t thread1, thread2; ! if (argc > 1) { fprintf(stderr, "Usage: %s\n", argv[0]); --- 104,111 ---- { pthread_t thread1, thread2; ! int fd; ! if (argc > 1) { fprintf(stderr, "Usage: %s\n", argv[0]); *************** *** 120,130 **** /* Make temp filenames, might not have strdup() */ temp_filename_1 = malloc(strlen(TEMP_FILENAME_1) + 1); strcpy(temp_filename_1, TEMP_FILENAME_1); ! mktemp(temp_filename_1); temp_filename_2 = malloc(strlen(TEMP_FILENAME_2) + 1); strcpy(temp_filename_2, TEMP_FILENAME_2); ! mktemp(temp_filename_2); #if !defined(HAVE_GETADDRINFO) && !defined(HAVE_GETHOSTBYNAME_R) if (gethostname(myhostname, MAXHOSTNAMELEN) != 0) --- 121,133 ---- /* Make temp filenames, might not have strdup() */ temp_filename_1 = malloc(strlen(TEMP_FILENAME_1) + 1); strcpy(temp_filename_1, TEMP_FILENAME_1); ! fd = mkstemp(temp_filename_1); ! close(fd); temp_filename_2 = malloc(strlen(TEMP_FILENAME_2) + 1); strcpy(temp_filename_2, TEMP_FILENAME_2); ! fd = mkstemp(temp_filename_2); ! close(fd); #if !defined(HAVE_GETADDRINFO) && !defined(HAVE_GETHOSTBYNAME_R) if (gethostname(myhostname, MAXHOSTNAMELEN) != 0)
---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html