From: Michał Górny <[email protected]> Place all temporary files within a single, quasi-atomically created temporary directory rather than relying on unsafe 'mktemp -u'. This prevents possible race conditions in case two parallel 'mktemp -u' calls returned the same path. Additionally, it reduces TMPDIR pollution by keeping all test files in a single subdirectory.
Signed-off-by: Luca Barbato <[email protected]> --- configure | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/configure b/configure index a7b3c55..a967181 100755 --- a/configure +++ b/configure @@ -2585,24 +2585,25 @@ HOSTEXESUF=$(exesuf $host_os) : ${TMPDIR:=$TMP} : ${TMPDIR:=/tmp} -if ! check_cmd mktemp -u XXXXXX; then - # simple replacement for missing mktemp - # NOT SAFE FOR GENERAL USE - mktemp(){ - echo "${2%%XXX*}.${HOSTNAME}.${UID}.$$" - } +SUBTMPDIR= + +trap '[ -n "${SUBTMPDIR}" ] && rm -r -f "${SUBTMPDIR}"' EXIT + +SUBTMPDIR=$(mktemp -d "${TMPDIR}/ffconf.XXXXXXXX" 2>/dev/null) +# simple replacement for missing mktemp +# NOT SAFE FOR GENERAL USE +if test -z "${SUBTMPDIR}"; then + SUBTMPDIR="${TMPDIR}/ffconf.${HOSTNAME}.${UID}.$$" + mkdir -p "${SUBTMPDIR}" fi tmpfile(){ - tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 && - (set -C; exec > $tmp) 2>/dev/null || + tmp="${SUBTMPDIR}/test$2" + (set -C; exec > "$tmp") 2>/dev/null || die "Unable to create temporary file in $TMPDIR." - append TMPFILES $tmp - eval $1=$tmp + eval $1="\$tmp" } -trap 'rm -f -- $TMPFILES' EXIT - tmpfile TMPASM .asm tmpfile TMPC .c tmpfile TMPE $EXESUF @@ -2612,8 +2613,6 @@ tmpfile TMPS .S tmpfile TMPSH .sh tmpfile TMPV .ver -unset -f mktemp - chmod +x $TMPE # make sure we can execute files in $TMPDIR -- 2.1.0 _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
