You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
configure: Place all temporary files in one separate directory
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: Diego Biurrun <diego@biurrun.de>
This commit is contained in:
committed by
Diego Biurrun
parent
11e225db31
commit
7848982207
14
configure
vendored
14
configure
vendored
@@ -2959,19 +2959,23 @@ if ! check_cmd mktemp -u XXXXXX; then
|
|||||||
# simple replacement for missing mktemp
|
# simple replacement for missing mktemp
|
||||||
# NOT SAFE FOR GENERAL USE
|
# NOT SAFE FOR GENERAL USE
|
||||||
mktemp(){
|
mktemp(){
|
||||||
echo "${2%%XXX*}.${HOSTNAME}.${UID}.$$"
|
tmpname="${2%%XXX*}.${HOSTNAME}.${UID}.$$"
|
||||||
|
echo "$tmpname"
|
||||||
|
mkdir "$tmpname"
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
AVTMPDIR=$(mktemp -d "${TMPDIR}/avconf.XXXXXXXX" 2> /dev/null) ||
|
||||||
|
die "Unable to create temporary directory in $TMPDIR."
|
||||||
|
|
||||||
tmpfile(){
|
tmpfile(){
|
||||||
tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
|
tmp="${AVTMPDIR}/test"$2
|
||||||
(set -C; exec > $tmp) 2> /dev/null ||
|
(set -C; exec > $tmp) 2> /dev/null ||
|
||||||
die "Unable to create temporary file in $TMPDIR."
|
die "Unable to create temporary file in $AVTMPDIR."
|
||||||
append TMPFILES $tmp
|
|
||||||
eval $1=$tmp
|
eval $1=$tmp
|
||||||
}
|
}
|
||||||
|
|
||||||
trap 'rm -f -- $TMPFILES' EXIT
|
trap 'rm -rf -- "$AVTMPDIR"' EXIT
|
||||||
|
|
||||||
tmpfile TMPASM .asm
|
tmpfile TMPASM .asm
|
||||||
tmpfile TMPC .c
|
tmpfile TMPC .c
|
||||||
|
Reference in New Issue
Block a user