]> granicus.if.org Git - sudo/commitdiff
If a system lacks mkdtemp() or mkstemps(), use our own mkdtemp()
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 29 Oct 2014 19:03:39 +0000 (13:03 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 29 Oct 2014 19:03:39 +0000 (13:03 -0600)
and mkstemps().  Previously we only exposed the missing one but
since the guts are the same we might as well use them.

configure
configure.ac
include/sudo_compat.h
lib/util/mktemp.c

index e3e490d8f95ff89134368835c65b0800281aa5c6..b0b21aab7058b5411aa1f97dd6d996e31ea5b9a0 100755 (executable)
--- a/configure
+++ b/configure
@@ -18395,6 +18395,8 @@ if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
 
+else
+  break
 fi
 done
 
@@ -18417,22 +18419,13 @@ done
  ;;
 esac
 
-    if test X"$ac_cv_func_mkstemps" = X"no"; then
+    # If either mkdtemp() or mkstemps() is missing, replace both.
 
-    for _sym in sudo_mkstemps; do
+    for _sym in sudo_mkdtemp sudo_mkstemps; do
        COMPAT_EXP="${COMPAT_EXP}${_sym}
 "
     done
 
-    fi
-    if test X"$ac_cv_func_mkdtemp" = X"no"; then
-
-    for _sym in sudo_mkdtemp; do
-       COMPAT_EXP="${COMPAT_EXP}${_sym}
-"
-    done
-
-    fi
 fi
 for ac_func in snprintf vsnprintf
 do :
index 0e384dc79912514a29f5051250357d8d89e9ddb0..546b981267f981b9c11f7596c4924c86271fadce 100644 (file)
@@ -2518,16 +2518,12 @@ AC_CHECK_FUNCS(closefrom, [], [AC_LIBOBJ(closefrom)
 #      include <limits.h>
 #      include <fcntl.h> ])
 ])
-AC_CHECK_FUNCS(mkstemps mkdtemp)
+AC_CHECK_FUNCS(mkstemps mkdtemp, [], [break])
 if test X"$ac_cv_func_mkstemps$ac_cv_func_mkdtemp" != X"yesyes"; then
     AC_CHECK_FUNCS(random lrand48, [break])
     AC_LIBOBJ(mktemp)
-    if test X"$ac_cv_func_mkstemps" = X"no"; then
-       SUDO_APPEND_COMPAT_EXP(sudo_mkstemps)
-    fi
-    if test X"$ac_cv_func_mkdtemp" = X"no"; then
-       SUDO_APPEND_COMPAT_EXP(sudo_mkdtemp)
-    fi
+    # If either mkdtemp() or mkstemps() is missing, replace both.
+    SUDO_APPEND_COMPAT_EXP(sudo_mkdtemp sudo_mkstemps)
 fi
 AX_FUNC_SNPRINTF
 if test X"$ac_cv_have_working_snprintf$ac_cv_have_working_vsnprintf" = X"yesyes"; then
index a314dc41aa7e9c80039b2d0233a9760adc35a260..09e60becf105cbaaec8492ac3192c061a405cf19 100644 (file)
@@ -433,16 +433,14 @@ __dso_public errno_t sudo_memset_s(void *v, rsize_t smax, int c, rsize_t n);
 # undef memset_s
 # define memset_s(_a, _b, _c, _d) sudo_memset_s((_a), (_b), (_c), (_d))
 #endif /* HAVE_MEMSET_S */
-#ifndef HAVE_MKDTEMP
+#if !defined(HAVE_MKDTEMP) || !defined(HAVE_MKSTEMPS)
 __dso_public char *sudo_mkdtemp(char *path);
 # undef mkdtemp
 # define mkdtemp(_a) sudo_mkdtemp((_a))
-#endif /* HAVE_MKDTEMP */
-#ifndef HAVE_MKSTEMPS
 __dso_public int sudo_mkstemps(char *path, int slen);
 # undef mkstemps
 # define mkstemps(_a, _b) sudo_mkstemps((_a), (_b))
-#endif /* HAVE_MKSTEMPS */
+#endif /* !HAVE_MKDTEMP || !HAVE_MKSTEMPS */
 #ifndef HAVE_PW_DUP
 __dso_public struct passwd *sudo_pw_dup(const struct passwd *pw);
 # undef pw_dup
index b1a3828bdb62fb14e6e771c07828ed79895cd4e2..87ed760fa214d203e2fe412c90582c91a65dd1a0 100644 (file)
@@ -142,15 +142,12 @@ mktemp_internal(char *path, int slen, int mode)
        return -1;
 }
 
-#ifndef HAVE_MKSTEMPS
 int
 sudo_mkstemps(char *path, int slen)
 {
        return mktemp_internal(path, slen, MKTEMP_FILE);
 }
-#endif /* HAVE_MKSTEMPS */
 
-#ifndef HAVE_MKDTEMP
 char *
 sudo_mkdtemp(char *path)
 {
@@ -158,5 +155,4 @@ sudo_mkdtemp(char *path)
                return NULL;
        return path;
 }
-#endif /* HAVE_MKDTEMP */
 #endif /* !HAVE_MKSTEMPS || !HAVE_MKDTEMP */