Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a crash in sandbox.sh when the XDG cache directory does not exist #4278

Merged
merged 4 commits into from
Jul 20, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/state/shellscripts/bwrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,18 @@ add_ccache_mount() {
done
CCACHE_DIR=${CCACHE_DIR-$HOME/.ccache}
ccache_dir=${ccache_dir-$CCACHE_DIR}
add_mounts rw $ccache_dir
add_mounts rw "$ccache_dir"
fi
}

add_dune_cache_mount() {
u_cache=${XDG_CACHE_HOME:-$HOME/.cache}
u_dune_cache=$u_cache/dune
cache=$(readlink -f "$u_cache")
cache=$(readlink -m "$u_cache")
dune_cache=$cache/dune
dune_cache=$(readlink -f $u_dune_cache)
mkdir -p ${dune_cache}
add_mount rw $u_dune_cache $dune_cache
dune_cache=$(readlink -m "$u_dune_cache")
mkdir -p "${dune_cache}"
add_mount rw "$u_dune_cache" "$dune_cache"
}

# This case-switch should remain identical between the different sandbox implems
Expand All @@ -91,7 +91,7 @@ case "$COMMAND" in
build)
# mount unusual path in ro
if [ -n "${OPAM_USER_PATH_RO-}" ]; then
add_mounts ro $(echo ${OPAM_USER_PATH_RO} | sed 's|:| |g')
add_mounts ro $(echo "${OPAM_USER_PATH_RO}" | sed 's|:| |g')
fi
add_mounts ro "$OPAM_SWITCH_PREFIX"
add_mounts rw "$PWD"
Expand All @@ -101,7 +101,7 @@ case "$COMMAND" in
install)
# mount unusual path in ro
if [ -n "${OPAM_USER_PATH_RO-}" ]; then
add_mounts ro $(echo ${OPAM_USER_PATH_RO} | sed 's|:| |g')
add_mounts ro $(echo "${OPAM_USER_PATH_RO}" | sed 's|:| |g')
fi
add_mounts rw "$OPAM_SWITCH_PREFIX"
add_mounts ro "$OPAM_SWITCH_PREFIX/.opam-switch"
Expand All @@ -110,7 +110,7 @@ case "$COMMAND" in
remove)
# mount unusual path in ro
if [ -n "${OPAM_USER_PATH_RO-}" ]; then
add_mounts ro $(echo ${OPAM_USER_PATH_RO} | sed 's|:| |g')
add_mounts ro $(echo "${OPAM_USER_PATH_RO}" | sed 's|:| |g')
fi
add_mounts rw "$OPAM_SWITCH_PREFIX"
add_mounts ro "$OPAM_SWITCH_PREFIX/.opam-switch"
Expand Down
12 changes: 6 additions & 6 deletions src/state/shellscripts/sandbox_exec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ if [ -z ${TMPDIR+x} ]; then
# 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
TMP=$(getconf DARWIN_USER_TEMP_DIR)
add_mounts rw "$TMP"
fi
else
add_mounts rw $TMPDIR
add_mounts rw "$TMPDIR"
fi

# C compilers using `ccache` will write to a shared cache directory
Expand All @@ -44,14 +44,14 @@ add_ccache_mount() {
done
CCACHE_DIR=${CCACHE_DIR-$HOME/.ccache}
ccache_dir=${ccache_dir-$CCACHE_DIR}
add_mounts rw $ccache_dir
add_mounts rw "$ccache_dir"
fi
}

add_dune_cache_mount() {
DUNE_CACHE=${XDG_CACHE_HOME:-$HOME/.cache}/dune
mkdir -p ${DUNE_CACHE}
add_mounts rw $DUNE_CACHE
mkdir -p "${DUNE_CACHE}"
add_mounts rw "$DUNE_CACHE"
}

# This case-switch should remain identical between the different sandbox implems
Expand Down