]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Build and use roken's mkstemp
authorSimon Wilkinson <sxw@your-file-system.com>
Wed, 1 Dec 2010 17:42:23 +0000 (17:42 +0000)
committerDerrick Brashear <shadow@dementia.org>
Wed, 1 Dec 2010 21:09:27 +0000 (13:09 -0800)
Add roken's mkstemp to the build on all platforms, either through
configure (Unix) or explicitly (Windows). Change all callers so
that mkstemp is used unconditionally, rather than falling back
to more risky alternatives.

This is based on original change from Russ Allbery submitted as
http://gerrit.openafs.org/2146

Change-Id: Ia1def41e438e6517b3e7cd5790df3c99eddb8ef6
Reviewed-on: http://gerrit.openafs.org/3398
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
acinclude.m4
src/bucoord/ubik_db_if.c
src/budb/db_text.c
src/butc/tcudbprocs.c
src/roken/Makefile.in
src/roken/NTMakefile
src/roken/afsroken.def
src/roken/librokenafs.map

index 3165f1dde84dafa78c9300525745f084d1b7971a..8375ed8b01b70dcd59c308f9b249854ab75d71a6 100644 (file)
@@ -1336,6 +1336,7 @@ AC_REPLACE_FUNCS([ \
        errx \
        getopt \
        getprogname \
+       mkstemp \
        strcasecmp \
        strlcat \
        strnlen \
index 45aa8ef943353fc8dbbd53851e27cf78c148cb30..1c0a917d1387171f74324e16f76f42d5773c6884 100644 (file)
@@ -1219,9 +1219,7 @@ int
 bc_openTextFile(udbClientTextP ctPtr, char *tmpFileName)
 {
     int code = 0;
-#ifdef HAVE_MKSTEMP
     int fd;
-#endif
 
     if (ctPtr->textStream != NULL) {
        fclose(ctPtr->textStream);
@@ -1229,15 +1227,10 @@ bc_openTextFile(udbClientTextP ctPtr, char *tmpFileName)
     }
 
     sprintf(tmpFileName, "%s/bu_XXXXXX", gettmpdir());
-#ifdef HAVE_MKSTEMP
     fd = mkstemp(tmpFileName);
     if (fd == -1)
        ERROR(BUDB_INTERNALERROR);
     ctPtr->textStream = fdopen(fd, "w+");
-#else
-    mktemp(tmpFileName);
-    ctPtr->textStream = fopen(tmpFileName, "w+");
-#endif
     if (ctPtr->textStream == NULL)
        ERROR(BUDB_INTERNALERROR);
 
index 72060d61032e8ef056aa16d7c62536d79c0bcafe..c5ceed68dfd3f35959f2a33582f9537c969bf59c 100644 (file)
@@ -486,31 +486,3 @@ saveTextToFile(struct ubik_trans *ut, struct textBlock *tbPtr)
     printf("wrote debug file %s\n", filename);
 }
 
-
-#if (defined(AFS_HPUX_ENV)) || defined(AFS_NT40_ENV)
-
-/* mkstemp
- * entry:
- *     st - string containing template for a tmp file name
- * exit:
- *     -1 - failed
- *     0-n - open file descriptor
- * notes:
- *     1) missing in Ultrix, HP/UX and AIX 221 environment
- *      2) iterate some number of times to alleviate the race?
- */
-
-int
-mkstemp(char *st)
-{
-    int retval = -1;
-
-#ifdef AFS_LINUX20_ENV
-    retval = open(mkstemp(st), O_RDWR | O_CREAT | O_EXCL, 0600);
-#else
-    retval = open(mktemp(st), O_RDWR | O_CREAT | O_EXCL, 0600);
-#endif
-
-    return (retval);
-}
-#endif
index e51625cc906fe79ac1d70e8014100f88303fb1d5..1dcaf90f822fd621d96fa460555b8f7647dcc276 100644 (file)
@@ -1455,11 +1455,7 @@ restoreText(struct butm_tapeInfo *tapeInfo,
 
     /* open the text file */
     sprintf(filename, "%s/bu_XXXXXX", gettmpdir());
-#if defined (HAVE_MKSTEMP)
     fid = mkstemp(filename);
-#else
-    fid = open(mktemp(filename), O_RDWR | O_CREAT | O_EXCL, 0600);
-#endif
     if (fid < 0) {
        ErrorLog(0, rstTapeInfoPtr->taskId, errno, 0,
                 "Can't open temporary text file: %s\n", filename);
index 86788dba39c45ede101e9f85be92829ff3e31156..6a0215801b98ab31475e47b8d0b996ea65f50b29 100644 (file)
@@ -111,6 +111,9 @@ hex.o: ${UPSTREAM}/hex.c
 issuid.o: ${UPSTREAM}/issuid.c
        $(AFS_CCRULE) $(UPSTREAM)/issuid.c
 
+mkstemp.o: ${UPSTREAM}/mkstemp.c
+       $(AFS_CCRULE) $(UPSTREAM)/mkstemp.c
+
 net_read.o: ${UPSTREAM}/net_read.c
        $(AFS_CCRULE) $(UPSTREAM)/net_read.c
 
index 6fa465105cd9c3427b39f52204b3d18955656c17..0a2f690ef8e0c9a1523ed04c938683ce0bcbdfb8 100644 (file)
@@ -37,6 +37,7 @@ ROKEN_OBJS = \
        $(OUT)\hex.obj \
         $(OUT)\issuid.obj \
        $(OUT)\localtime_r.obj \
+       $(OUT)\mkstemp.obj \
        $(OUT)\net_read.obj \
        $(OUT)\net_write.obj \
        $(OUT)\snprintf.obj \
index 257b510172ed75a8fef8a7b2a795b07f50cdf4db..43d598c4068248576def5b9a9587405b266e59f0 100644 (file)
@@ -30,3 +30,5 @@ EXPORTS
         rk_optarg               @34 DATA
         rk_optind               @35 DATA
         rk_opterr               @36 DATA
+       rk_mkstemp              @37
+
index d5a5704ab87f8cf3167db108169396054c5f210b..f2abfce0dfc3e12ade87e0ab0e01adb1e0ae9b31 100644 (file)
@@ -17,6 +17,7 @@
                rk_emalloc;
                rk_erealloc;
                rk_hex_encode;
+               rk_mkstemp;
                rk_print_version;
                rk_socket;
                rk_strcasecmp;