diff --git a/configure b/configure index e3e490d8f..b0b21aab7 100755 --- 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 : diff --git a/configure.ac b/configure.ac index 0e384dc79..546b98126 100644 --- a/configure.ac +++ b/configure.ac @@ -2518,16 +2518,12 @@ AC_CHECK_FUNCS(closefrom, [], [AC_LIBOBJ(closefrom) # include # include ]) ]) -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 diff --git a/include/sudo_compat.h b/include/sudo_compat.h index a314dc41a..09e60becf 100644 --- a/include/sudo_compat.h +++ b/include/sudo_compat.h @@ -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 diff --git a/lib/util/mktemp.c b/lib/util/mktemp.c index b1a3828bd..87ed760fa 100644 --- a/lib/util/mktemp.c +++ b/lib/util/mktemp.c @@ -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 */