summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2017-01-29 01:11:28 -0800
committerJay Freeman (saurik) <saurik@saurik.com>2017-01-29 01:11:28 -0800
commitceffc5bc20c1ab16c4d02e1d3ae8fcfb65557797 (patch)
tree5ee557d7d626e66684110f9f447686f85a26c6a5
parent109355f19df80de62ab05eec18df8ae15ad423ec (diff)
Try to protect firmware.sh against reentrant bugs.v1.1.28%b6
-rwxr-xr-xLibrary/firmware.sh12
1 files 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