summaryrefslogtreecommitdiff
path: root/Build/source/texk/kpathsea
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/kpathsea')
-rw-r--r--Build/source/texk/kpathsea/ChangeLog4
-rwxr-xr-xBuild/source/texk/kpathsea/mktexlsr13
2 files changed, 16 insertions, 1 deletions
diff --git a/Build/source/texk/kpathsea/ChangeLog b/Build/source/texk/kpathsea/ChangeLog
index 519a539ee41..ad1756b462c 100644
--- a/Build/source/texk/kpathsea/ChangeLog
+++ b/Build/source/texk/kpathsea/ChangeLog
@@ -1,3 +1,7 @@
+2018-01-17 Norbert Preining <norbert@preining.info>
+
+ * mktexlsr (treefile): use mktemp with fallback option for temporary file.
+
2018-01-16 Karl Berry <karl@freefriends.org>
* kpathsea.pc.in (Cflags): remove -I${libdir} per Debian.
diff --git a/Build/source/texk/kpathsea/mktexlsr b/Build/source/texk/kpathsea/mktexlsr
index 8d4a38018f9..bd3eb50d6e4 100755
--- a/Build/source/texk/kpathsea/mktexlsr
+++ b/Build/source/texk/kpathsea/mktexlsr
@@ -73,7 +73,18 @@ if tty -s; then verbose=true; else verbose=false; fi
dry_run=false
trees=
-treefile="${TMPDIR-/tmp}/mktexlsrtrees$$.tmp"
+# initialize treefile by either mktemp or some random name
+# code taken from pdfjam and adjusted
+{
+ treefile=`
+ (umask 077 && mktemp "${TMPDIR-/tmp}/mktexlsrtrees.XXXXXXXXXX") 2>/dev/null
+ ` && test -n "$treefile" && test -f "$treefile"
+} || {
+ ## We'll use awk to make random number, for portability
+ random=`awk 'END { srand(); printf ("%d\n", rand()*1000000); }' /dev/null`
+ treefile="${TMPDIR-/tmp}/mktexlsrtrees$$.$random"
+} || exit $?
+
trap 'cd /; rm -f $treefile; test -z "$db_dir_tmp" || rm -rf "$db_dir_tmp";
exit' 0 1 2 3 7 13 15