- don't use mktemp if mkstemp is available (#103850).
authorjbj <devnull@localhost>
Fri, 26 Dec 2003 17:36:38 +0000 (17:36 +0000)
committerjbj <devnull@localhost>
Fri, 26 Dec 2003 17:36:38 +0000 (17:36 +0000)
CVS patchset: 7012
CVS date: 2003/12/26 17:36:38

CHANGES
build.c
configure.ac

diff --git a/CHANGES b/CHANGES
index a8bed2e..aa5a006 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -9,6 +9,7 @@
        - fix: added index size wrong iff _transaction_color != 0/3 (#103865).
        - fix: escape '+' in regex patterns through RPMMIRE_DEFAULT (#103851).
        - RPMMIRE_DEFAULT is overkill, use RPMMIRE_STRCMP instead (#103851).
+       - don't use mktemp if mkstemp is available (#103850).
 
 4.2.1 -> 4.2.2:
        - unify signal handling in librpmio, use condvar to deliver signal.
diff --git a/build.c b/build.c
index fb32018..fc9df11 100644 (file)
--- a/build.c
+++ b/build.c
@@ -126,7 +126,7 @@ static int buildForTarget(rpmts ts, const char * arg, BTA_t ba)
     if (ba->buildMode == 't') {
        FILE *fp;
        const char * specDir;
-       const char * tmpSpecFile;
+       char * tmpSpecFile;
        char * cmd, * s;
        rpmCompressedMagic res = COMPRESSED_OTHER;
        /*@observer@*/ static const char *zcmds[] =
@@ -134,14 +134,12 @@ static int buildForTarget(rpmts ts, const char * arg, BTA_t ba)
 
        specDir = rpmGetPath("%{_specdir}", NULL);
 
-       /* XXX Using mkstemp is difficult here. */
-       /* XXX FWIW, default %{_specdir} is root.root 0755 */
-       {   char tfn[64];
-           strcpy(tfn, "rpm-spec.XXXXXX");
-           /*@-unrecog@*/
-           tmpSpecFile = rpmGetPath("%{_specdir}/", mktemp(tfn), NULL);
-           /*@=unrecog@*/
-       }
+       tmpSpecFile = rpmGetPath("%{_specdir}/", "rpm-spec.XXXXXX", NULL);
+#if defined(HAVE_MKSTEMP)
+       (void) close(mkstemp(tmpSpecFile));
+#else
+       (void) mktemp(tmpSpecFile);
+#endif
 
        (void) isCompressed(arg, &res);
 
index 8173264..849c264 100644 (file)
@@ -759,6 +759,8 @@ AC_CHECK_FUNCS(regcomp)
 
 AC_CHECK_FUNCS(ftok)
 
+AC_CHECK_FUNCS(mkstemp)
+
 dnl
 dnl XXX Regex replacement isn't known to be needed yet.
 dnl