Skip to content

Commit 245903c

Browse files
committed
Fix locking permissions in get function
1 parent 8d8f975 commit 245903c

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/scripts/unix.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,18 @@ release_lock() {
107107
sudo rm -rf "$lock_path"
108108
}
109109

110+
# Function to get the SHA256 hash of a string.
111+
get_sha256() {
112+
local input=$1
113+
if command -v sha256sum >/dev/null; then
114+
printf '%s' "$input" | sha256sum | cut -d' ' -f1
115+
elif command -v shasum >/dev/null; then
116+
printf '%s' "$input" | shasum -a 256 | cut -d' ' -f1
117+
elif command -v openssl >/dev/null; then
118+
printf '%s' "$input" | openssl dgst -sha256 | cut -d' ' -f2
119+
fi
120+
}
121+
110122
# Function to download a file using cURL.
111123
# mode: -s pipe to stdout, -v save file and return status code
112124
# execute: -e save file as executable
@@ -120,7 +132,7 @@ get() {
120132
sudo curl "${curl_opts[@]}" "${links[0]}"
121133
else
122134
if [ "$runner" = "self-hosted" ]; then
123-
lock_path="$file_path.lock"
135+
lock_path="/tmp/sp-lck-$(get_sha256 "$file_path")"
124136
acquire_lock "$lock_path"
125137
if [ "$execute" = "-e" ]; then
126138
until [ -z "$(fuser "$file_path" 2>/dev/null)" ]; do

0 commit comments

Comments
 (0)