summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2018-05-31 16:37:31 +0200
committerNatanael Copa <ncopa@alpinelinux.org>2018-05-31 16:37:31 +0200
commitc0a862930c1bd033be30f2c48e91a6f7e76a5a58 (patch)
tree86c2e3d14634575ef5c4a6f6a73ae668103c1139
parent75b8cacaf0468470c502314560a436b80b7fe9af (diff)
downloadabuild-c0a862930c1bd033be30f2c48e91a6f7e76a5a58.tar.bz2
abuild-c0a862930c1bd033be30f2c48e91a6f7e76a5a58.tar.xz
abuild: fix race when stripping
scanelf may pick up tempfiles created by strip or setfattr since it runs in spearate process and pipes the out to a subshell. This causes a race and may lead to the while loop attempt to strip seomthing that no longer exists. We fix that by test if file exists before try manipulate it. We could have written he file list to a temp file first, but this way we benefit from multiple cores working in parallel.
-rw-r--r--abuild.in4
1 files changed, 4 insertions, 0 deletions
diff --git a/abuild.in b/abuild.in
index a669f65..d52c0bf 100644
--- a/abuild.in
+++ b/abuild.in
@@ -2247,6 +2247,10 @@ stripbin() {
msg "Stripping binaries"
scanelf --recursive --nobanner --osabi --etype "ET_DYN,ET_EXEC" . \
| while read type osabi filename; do
+
+ # scanelf may have picked up a temp file so verify that file still exists
+ [ -e "$filename" ] || continue
+
[ "$osabi" != "STANDALONE" ] || continue
local XATTR=$(getfattr --match="" --dump "${filename}")
"${stripcmd}" "${filename}"