From e0d2cb872d7ac928d149e688bfd00a4281d2f30d Mon Sep 17 00:00:00 2001 From: Josh Spicer Date: Wed, 6 Dec 2023 22:07:44 +0000 Subject: [PATCH 1/5] revert behavior of sourcing .profile in .zprofile https://github.com/devcontainers/features/pull/736/files#diff-3e71c0a0669a0410f7dd0d8f2b83f3b6bf6b525d3eabd354f19f32822da669fcR460-R463 --- src/common-utils/main.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/common-utils/main.sh b/src/common-utils/main.sh index a291f98e2..262a01cc7 100644 --- a/src/common-utils/main.sh +++ b/src/common-utils/main.sh @@ -459,10 +459,6 @@ fi # Optionally configure zsh and Oh My Zsh! if [ "${INSTALL_ZSH}" = "true" ]; then - if [ ! -f "${user_home}/.zprofile" ] || ! grep -Fxq 'source $HOME/.profile' "${user_home}/.zprofile" ; then - echo 'source $HOME/.profile' >> "${user_home}/.zprofile" - fi - if [ "${ZSH_ALREADY_INSTALLED}" != "true" ]; then if [ "${ADJUSTED_ID}" = "rhel" ]; then global_rc_path="/etc/zshrc" From 03398d845ccb10ee9f7ca6f968e13b70d7c30273 Mon Sep 17 00:00:00 2001 From: Josh Spicer Date: Wed, 6 Dec 2023 22:10:33 +0000 Subject: [PATCH 2/5] add test --- test/common-utils/configure_zsh_as_default_shell.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/common-utils/configure_zsh_as_default_shell.sh b/test/common-utils/configure_zsh_as_default_shell.sh index 01d15227e..a1d437568 100644 --- a/test/common-utils/configure_zsh_as_default_shell.sh +++ b/test/common-utils/configure_zsh_as_default_shell.sh @@ -11,5 +11,7 @@ check "default-shell-is-zsh" bash -c "getent passwd $(whoami) | awk -F: '{ print check "default-zshrc-is-dev-container-template" bash -c "cat ~/.zshrc | grep ZSH_THEME | grep devcontainers" check "zsh-path-contains-local-bin" zsh -l -c "echo $PATH | grep '/home/devcontainer/.local/bin'" +check "Ensure .zprofile is owned by remoteUser" bash -c "stat -c '%U' home/devcontainer/.zprofile | grep devcontainer" + # Report result reportResults From b1dbc0368056501d4d36d2458d5950281d1a4e5a Mon Sep 17 00:00:00 2001 From: Josh Spicer Date: Wed, 6 Dec 2023 22:10:52 +0000 Subject: [PATCH 3/5] increment version --- src/common-utils/devcontainer-feature.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common-utils/devcontainer-feature.json b/src/common-utils/devcontainer-feature.json index dc54e6918..329f8dec8 100644 --- a/src/common-utils/devcontainer-feature.json +++ b/src/common-utils/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "common-utils", - "version": "2.3.0", + "version": "2.3.1", "name": "Common Utilities", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/common-utils", "description": "Installs a set of common command line utilities, Oh My Zsh!, and sets up a non-root user.", From c3e721d205cbb6fa8b5f57d9fee208684cf769ce Mon Sep 17 00:00:00 2001 From: Josh Spicer Date: Wed, 6 Dec 2023 22:31:14 +0000 Subject: [PATCH 4/5] create empty .zprofile is not present, and fix test --- src/common-utils/main.sh | 5 +++++ test/common-utils/configure_zsh_as_default_shell.sh | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/common-utils/main.sh b/src/common-utils/main.sh index 262a01cc7..4dcdc16ee 100644 --- a/src/common-utils/main.sh +++ b/src/common-utils/main.sh @@ -459,6 +459,11 @@ fi # Optionally configure zsh and Oh My Zsh! if [ "${INSTALL_ZSH}" = "true" ]; then + if [ ! -f "${user_home}/.zprofile" ]; then + touch "${user_home}/.zprofile" + chown ${USERNAME}:${group_name} "${user_home}/.zprofile" + fi + if [ "${ZSH_ALREADY_INSTALLED}" != "true" ]; then if [ "${ADJUSTED_ID}" = "rhel" ]; then global_rc_path="/etc/zshrc" diff --git a/test/common-utils/configure_zsh_as_default_shell.sh b/test/common-utils/configure_zsh_as_default_shell.sh index a1d437568..21b12101e 100644 --- a/test/common-utils/configure_zsh_as_default_shell.sh +++ b/test/common-utils/configure_zsh_as_default_shell.sh @@ -11,7 +11,7 @@ check "default-shell-is-zsh" bash -c "getent passwd $(whoami) | awk -F: '{ print check "default-zshrc-is-dev-container-template" bash -c "cat ~/.zshrc | grep ZSH_THEME | grep devcontainers" check "zsh-path-contains-local-bin" zsh -l -c "echo $PATH | grep '/home/devcontainer/.local/bin'" -check "Ensure .zprofile is owned by remoteUser" bash -c "stat -c '%U' home/devcontainer/.zprofile | grep devcontainer" +check "Ensure .zprofile is owned by remoteUser" bash -c "stat -c '%U' /home/devcontainer/.zprofile | grep devcontainer" # Report result reportResults From 74984e32d9fc25ee6ae499485b1d6b5b972f3f3d Mon Sep 17 00:00:00 2001 From: Josh Spicer Date: Thu, 7 Dec 2023 18:29:08 +0000 Subject: [PATCH 5/5] temporarily add back .profile to .zprofile (only if file did not exist) --- src/common-utils/main.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common-utils/main.sh b/src/common-utils/main.sh index 4dcdc16ee..26f0a7512 100644 --- a/src/common-utils/main.sh +++ b/src/common-utils/main.sh @@ -461,6 +461,7 @@ fi if [ "${INSTALL_ZSH}" = "true" ]; then if [ ! -f "${user_home}/.zprofile" ]; then touch "${user_home}/.zprofile" + echo 'source $HOME/.profile' >> "${user_home}/.zprofile" # TODO: Reconsider adding '.profile' to '.zprofile' chown ${USERNAME}:${group_name} "${user_home}/.zprofile" fi