summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2014-09-21 11:38:25 +0200
committerDiego Biurrun <diego@biurrun.de>2017-01-29 20:17:46 +0100
commit78489822074096e3ae0f3c3b70accace955086f6 (patch)
treef7fa28dbff75a5ed230c6e18a923b36ee7f2fdcc
parent11e225db31dcad57e2219ad8dfae2ac027af53d6 (diff)
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>
-rwxr-xr-xconfigure16
1 files changed, 10 insertions, 6 deletions
diff --git a/configure b/configure
index f183544ae6..a46e670ecd 100755
--- a/configure
+++ b/configure
@@ -2959,19 +2959,23 @@ if ! check_cmd mktemp -u XXXXXX; then
# simple replacement for missing mktemp
# NOT SAFE FOR GENERAL USE
mktemp(){
- echo "${2%%XXX*}.${HOSTNAME}.${UID}.$$"
+ tmpname="${2%%XXX*}.${HOSTNAME}.${UID}.$$"
+ echo "$tmpname"
+ mkdir "$tmpname"
}
fi
+AVTMPDIR=$(mktemp -d "${TMPDIR}/avconf.XXXXXXXX" 2> /dev/null) ||
+ die "Unable to create temporary directory in $TMPDIR."
+
tmpfile(){
- tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
- (set -C; exec > $tmp) 2>/dev/null ||
- die "Unable to create temporary file in $TMPDIR."
- append TMPFILES $tmp
+ tmp="${AVTMPDIR}/test"$2
+ (set -C; exec > $tmp) 2> /dev/null ||
+ die "Unable to create temporary file in $AVTMPDIR."
eval $1=$tmp
}
-trap 'rm -f -- $TMPFILES' EXIT
+trap 'rm -rf -- "$AVTMPDIR"' EXIT
tmpfile TMPASM .asm
tmpfile TMPC .c