From 3c0e6ed9a0f3a8fe15a7d485d61025e823012828 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Fri, 25 Nov 2022 19:22:35 +0000 Subject: [PATCH 1/4] Use sudo -iu instead of mutating $HOME This works because sudo executes as another user, and the -i makes it a login shell which sets the proper $HOME variables. $_REMOTE_USER variable is fromm a proposal to the devcontainers spec https://github.com/devcontainers/spec/blob/main/proposals/features-user-env-variables.md --- src/haskell/install.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/haskell/install.sh b/src/haskell/install.sh index 092db1fff..e307b9c2d 100644 --- a/src/haskell/install.sh +++ b/src/haskell/install.sh @@ -46,13 +46,15 @@ fi # The installation script is designed to be run by the non-root user # The files need to be in the remote user's ~/ home directory -ROOT_HOME="${HOME}" -export HOME="${_REMOTE_USER_HOME}" - -curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | $SHELL - -export HOME="${ROOT_HOME}" -chown -R "${_REMOTE_USER}:${_REMOTE_USER}" "${_REMOTE_USER_HOME}" +# So, how do we switch users? We use 'sudo -iu ' to get a +# login shell of another user! We use $_REMOTE_USER as defined in +# a spec proposal (but still implemented in Codespaces): https://github.com/devcontainers/spec/blob/main/proposals/features-user-env-variables.md +# Here's some more examples using it: https://github.com/search?q=org%3Adevcontainers+_REMOTE_USER&type=code +# We also use /bin/sh as defined in the script hash-bang line instead of $SHELL. +sudo -iu "$_REMOTE_USER" < Date: Sun, 27 Nov 2022 15:28:17 -0600 Subject: [PATCH 2/4] Actually use /bin/sh instead of just sh Shebang is (below), so we use that ```sh #!/bin/sh ``` --- src/haskell/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/haskell/install.sh b/src/haskell/install.sh index 191143e06..fafca9a69 100644 --- a/src/haskell/install.sh +++ b/src/haskell/install.sh @@ -53,7 +53,7 @@ fi # We also use /bin/sh as defined in the script hash-bang line instead of $SHELL. sudo -iu "$_REMOTE_USER" < Date: Sun, 27 Nov 2022 15:39:42 -0600 Subject: [PATCH 3/4] Change it back to install instructions after some consideration --- src/haskell/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/haskell/install.sh b/src/haskell/install.sh index fafca9a69..23b3f1328 100644 --- a/src/haskell/install.sh +++ b/src/haskell/install.sh @@ -52,8 +52,8 @@ fi # Here's some more examples using it: https://github.com/search?q=org%3Adevcontainers+_REMOTE_USER&type=code # We also use /bin/sh as defined in the script hash-bang line instead of $SHELL. sudo -iu "$_REMOTE_USER" < Date: Sun, 27 Nov 2022 15:46:45 -0600 Subject: [PATCH 4/4] Bump version as discussed in #85? https://github.com/devcontainers-contrib/features/issues/85#issuecomment-1328298600 --- src/haskell/devcontainer-feature.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/haskell/devcontainer-feature.json b/src/haskell/devcontainer-feature.json index d6b57f540..9dbc6d6b4 100644 --- a/src/haskell/devcontainer-feature.json +++ b/src/haskell/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "Haskell", "id": "haskell", - "version": "1.1.0", + "version": "2.0.0", "description": "Installs Haskell. An advanced, purely functional programming language", "documentationURL": "https://github.com/devcontainers-contrib/features/tree/main/src/haskell", "options": {