Skip to content

Commit

Permalink
Sandboxing on MacOS: considering the possibility that TMPDIR in unset (
Browse files Browse the repository at this point in the history
…#3597)

We then use `getconf` to get the per-user temporary directory.
  • Loading branch information
herbelin authored and rjbou committed Oct 17, 2018
1 parent f2e8e6d commit bdeecda
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/state/shellscripts/sandbox_exec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,20 @@ add_mounts() {
esac
}

add_mounts rw "${TMPDIR:-/tmp}"
if [ -z ${TMPDIR+x} ]; then
# If $TMPDIR is not set, some applications use /tmp, so
# /tmp must be made readable/writable
add_mounts rw /tmp
# However, others applications obtain the per-user temporary
# directory differently; the latter should be made readable/writable
# too and getconf seems to be a robust way to get it
if [ -z /usr/bin/getconf ]; then
TMP=`getconf DARWIN_USER_TEMP_DIR`
add_mounts rw $TMP
fi
else
add_mounts rw $TMPDIR
fi

# C compilers using `ccache` will write to a shared cache directory
# that remain writeable. ccache seems widespread in some Fedora systems.
Expand Down

0 comments on commit bdeecda

Please sign in to comment.