Skip to content

Commit 274838b

Browse files
committed
Merge branch 'tmp-noexec'
Fixes #604
2 parents 29f1a19 + a4556a7 commit 274838b

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

bin/ruby-build

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,10 +1016,22 @@ else
10161016
TMP="${TMPDIR%/}"
10171017
fi
10181018

1019-
if [ ! -w "$TMP" ] || [ ! -x "$TMP" ]; then
1019+
# Check if TMPDIR is accessible and can hold executables.
1020+
tmp_executable="${TMP}/ruby-build-test.$$"
1021+
noexec=""
1022+
if mkdir -p "$TMP" && touch "$tmp_executable" 2>/dev/null; then
1023+
cat > "$tmp_executable" <<<"#!$BASH"
1024+
chmod +x "$tmp_executable"
1025+
else
10201026
echo "ruby-build: TMPDIR=$TMP is set to a non-accessible location" >&2
10211027
exit 1
10221028
fi
1029+
"$tmp_executable" 2>/dev/null || noexec=1
1030+
rm -f "$tmp_executable"
1031+
if [ -n "$noexec" ]; then
1032+
echo "ruby-build: TMPDIR=$TMP cannot hold executables (partition possibly mounted with \`noexec\`)" >&2
1033+
exit 1
1034+
fi
10231035

10241036
# Work around warnings building Ruby 2.0 on Clang 2.x:
10251037
# pass -Wno-error=shorten-64-to-32 if the compiler accepts it.

0 commit comments

Comments
 (0)