From ceffc5bc20c1ab16c4d02e1d3ae8fcfb65557797 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sun, 29 Jan 2017 01:11:28 -0800 Subject: Try to protect firmware.sh against reentrant bugs. --- Library/firmware.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Library/firmware.sh b/Library/firmware.sh index afaae9a..d2f89eb 100755 --- a/Library/firmware.sh +++ b/Library/firmware.sh @@ -49,6 +49,12 @@ EOF } # }}} +before=$(stat -c '%i-%Y' status) + +output=$(mktemp status-tmp.XXXXXX) +xxxxxx=${output##status-tmp.} +rm -f status-tmp.!("${xxxxxx}") + { # Delete Old Packages {{{ @@ -135,9 +141,11 @@ EOF pseudo "cy+lib.corefoundation" "$(/usr/libexec/cydia/cfversion)" "virtual corefoundation dependency" -} >"${status}"_ +} >"${output}" -mv -f "${status}"{_,} +# XXX: this is a poor replacement for flock +test "${before}" = "$(stat -c '%i-%Y' status)" +mv -f "${output}" "${status}" if [[ ${cpu} == arm || ${cpu} == arm64 ]]; then if [[ ! -h /User && -d /User ]]; then -- cgit v1.2.3