Fix .zprofile is owned by root (#775)

* revert behavior of sourcing .profile in .zprofile

https://github.com/devcontainers/features/pull/736/files#diff-3e71c0a0669a0410f7dd0d8f2b83f3b6bf6b525d3eabd354f19f32822da669fcR460-R463

* add test

* increment version

* create empty .zprofile is not present, and fix test

* temporarily add back .profile to .zprofile (only if file did not exist)
This commit is contained in:
Josh Spicer 2023-12-07 10:49:18 -08:00 committed by GitHub
parent def3a41f57
commit 3ea4d6bbd7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View file

@ -1,6 +1,6 @@
{ {
"id": "common-utils", "id": "common-utils",
"version": "2.3.0", "version": "2.3.1",
"name": "Common Utilities", "name": "Common Utilities",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/common-utils", "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.", "description": "Installs a set of common command line utilities, Oh My Zsh!, and sets up a non-root user.",

View file

@ -459,8 +459,10 @@ fi
# Optionally configure zsh and Oh My Zsh! # Optionally configure zsh and Oh My Zsh!
if [ "${INSTALL_ZSH}" = "true" ]; then if [ "${INSTALL_ZSH}" = "true" ]; then
if [ ! -f "${user_home}/.zprofile" ] || ! grep -Fxq 'source $HOME/.profile' "${user_home}/.zprofile" ; then if [ ! -f "${user_home}/.zprofile" ]; then
echo 'source $HOME/.profile' >> "${user_home}/.zprofile" 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 fi
if [ "${ZSH_ALREADY_INSTALLED}" != "true" ]; then if [ "${ZSH_ALREADY_INSTALLED}" != "true" ]; then

View file

@ -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 "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 "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 # Report result
reportResults reportResults