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.
---
configure | 26 +++++++++++---------------
1 file changed, 11 insertions(+), 15 deletions(-)
diff --git a/configure b/configure
index 81e1d3f..753893d 100755
--- a/configure
+++ b/configure
@@ -2584,24 +2584,22 @@ 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}.$$"
- }
-fi
+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
+: ${SUBTMPDIR:=${TMPDIR}/ffconf.${HOSTNAME}.${UID}.$$}
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
@@ -2611,8 +2609,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