Avoid root when prefix is writable
Previously if the prefix was non-existent we would switch to root even if the user does have the permissions to create the directory. Fixes #3585
This commit is contained in:
parent
6045fdd3ac
commit
3339853c26
|
@ -24,6 +24,24 @@ jobs:
|
||||||
- name: Test code-server
|
- name: Test code-server
|
||||||
run: yarn test:standalone-release code-server
|
run: yarn test:standalone-release code-server
|
||||||
|
|
||||||
|
alpine:
|
||||||
|
name: Test installer on Alpine
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: "alpine:3.14"
|
||||||
|
steps:
|
||||||
|
- name: Checkout repo
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install curl
|
||||||
|
run: apk add curl
|
||||||
|
|
||||||
|
- name: Add user
|
||||||
|
run: adduser coder --disabled-password
|
||||||
|
|
||||||
|
# Standalone should work without root.
|
||||||
|
- name: Test standalone to a non-existent prefix
|
||||||
|
run: su coder -c "./install.sh --method standalone --prefix /tmp/does/not/yet/exist"
|
||||||
|
|
||||||
macos:
|
macos:
|
||||||
name: Test installer on macOS
|
name: Test installer on macOS
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
|
|
|
@ -132,7 +132,6 @@ main() {
|
||||||
unset \
|
unset \
|
||||||
DRY_RUN \
|
DRY_RUN \
|
||||||
METHOD \
|
METHOD \
|
||||||
STANDALONE_INSTALL_PREFIX \
|
|
||||||
OPTIONAL \
|
OPTIONAL \
|
||||||
ALL_FLAGS \
|
ALL_FLAGS \
|
||||||
RSH_ARGS \
|
RSH_ARGS \
|
||||||
|
@ -381,6 +380,10 @@ install_standalone() {
|
||||||
fetch "https://github.com/cdr/code-server/releases/download/v$VERSION/code-server-$VERSION-$OS-$ARCH.tar.gz" \
|
fetch "https://github.com/cdr/code-server/releases/download/v$VERSION/code-server-$VERSION-$OS-$ARCH.tar.gz" \
|
||||||
"$CACHE_DIR/code-server-$VERSION-$OS-$ARCH.tar.gz"
|
"$CACHE_DIR/code-server-$VERSION-$OS-$ARCH.tar.gz"
|
||||||
|
|
||||||
|
# -w only works if the directory exists so try creating it first. If this
|
||||||
|
# fails we can ignore the error as the -w check will then swap us to sudo.
|
||||||
|
sh_c mkdir -p "$STANDALONE_INSTALL_PREFIX" 2> /dev/null || true
|
||||||
|
|
||||||
sh_c="sh_c"
|
sh_c="sh_c"
|
||||||
if [ ! -w "$STANDALONE_INSTALL_PREFIX" ]; then
|
if [ ! -w "$STANDALONE_INSTALL_PREFIX" ]; then
|
||||||
sh_c="sudo_sh_c"
|
sh_c="sudo_sh_c"
|
||||||
|
|
Loading…
Reference in New Issue