aboutsummaryrefslogtreecommitdiffstats
path: root/main/abuild/0001-abuild-fix-race-when-stripping.patch
blob: b929c704cef573519234c7c06a947c23587480a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
From c0a862930c1bd033be30f2c48e91a6f7e76a5a58 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Thu, 31 May 2018 16:37:31 +0200
Subject: [PATCH] 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.
---
 abuild.in | 4 ++++
 1 file changed, 4 insertions(+)

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}"
-- 
2.17.1