diff options
author | Karl Berry <karl@freefriends.org> | 2016-11-02 21:34:11 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-11-02 21:34:11 +0000 |
commit | 1bcee5c5372991e01be888bcf448b8f41f030f93 (patch) | |
tree | 364144f61e7b9958b116ec27b5459fa6d276a8ec | |
parent | 22cdd18a2a6b8bfca945af635e646880edd2914e (diff) |
silent mkdir before reporting mkdir to try to work around race condition, https://bugs.debian.org/794228
git-svn-id: svn://tug.org/texlive/trunk@42425 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Build/source/texk/kpathsea/ChangeLog | 6 | ||||
-rwxr-xr-x | Build/source/texk/kpathsea/mktexdir | 19 |
2 files changed, 23 insertions, 2 deletions
diff --git a/Build/source/texk/kpathsea/ChangeLog b/Build/source/texk/kpathsea/ChangeLog index 28d3f05d360..dc328b8a5bc 100644 --- a/Build/source/texk/kpathsea/ChangeLog +++ b/Build/source/texk/kpathsea/ChangeLog @@ -1,3 +1,9 @@ +2016-11-02 Karl Berry <karl@tug.org> + + * mktexdir: try a silent mkdir before a non-silent mkdir, + to try to work around the inevitable race condition. + https://bugs.debian.org/794228. + 2016-08-04 Karl Berry <karl@tug.org> * texmf.cnf (max_strings.bibtex, et al.): increase to 100,000 diff --git a/Build/source/texk/kpathsea/mktexdir b/Build/source/texk/kpathsea/mktexdir index 27e00bccafa..b56bfab0ac8 100755 --- a/Build/source/texk/kpathsea/mktexdir +++ b/Build/source/texk/kpathsea/mktexdir @@ -1,10 +1,11 @@ #!/bin/sh -# mkinstalldirs (now mktexdir) -- make directory hierarchy. +# mktexdir (was mkinstalldirs) -- make directory hierarchy. # Author: Noah Friedman <friedman@prep.ai.mit.edu>, created: 1993-05-16. # Public domain. # # Modified for sticky directory creation, --help, --version, more, # by Thomas Esser, Karl Berry, Olaf Weber, et al. +# Maintained as part of TeX Live, http://tug.org/tex-live. version='$Id$' progname=`echo $0 | sed 's%.*/%%'` @@ -50,7 +51,18 @@ do pathcomp="$pathcomp$d" if test ! -d "./$pathcomp"; then - mkdir "./$pathcomp" || { errstatus=$?; break; } + # This shell stuff is not atomic, therefore ./$pathcomp + # may have been created in another process and this mkdir will + # fail despite the above test, so do it silently: + mkdir "./$pathcomp" >/dev/null 2>&1 + + # So, if ./$pathcomp is a directory now, call it good. + if test ! -d "./$pathcomp"; then + # Otherwise, presumably it's a real error. Do the mkdir again + # and let the error be seen, and quit the loop. + # (Report at https://bugs.debian.org/794228.) + mkdir "./$pathcomp" || { errstatus=$?; break; } + fi chmod `kpsestat ${MT_APPEND_MASK} "$pathcomp"/..` "./$pathcomp" fi @@ -59,3 +71,6 @@ do done exit $errstatus + +# P.S. We don't want to rely on mkdir -p, because of possible +# portability programs. See current mkinstalldirs source (in Automake). |