Fix: common-utils configureZshAsDefaultShell option not working on alpine linux image (#557)
* alpine defaultZsh fix * common-utils: replace pam.d/chsh permission with `sufficient` * common-utils: revert match auth sufficient * common-utils: append auth string instead of replacing a whole file * fix grep 2nd param * fix: line checking condition
This commit is contained in:
parent
836ea1e9fa
commit
685fa2e0f1
4 changed files with 33 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"id": "common-utils",
|
"id": "common-utils",
|
||||||
"version": "2.0.10",
|
"version": "2.0.11",
|
||||||
"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.",
|
||||||
|
|
|
@ -437,6 +437,14 @@ if [ "${INSTALL_ZSH}" = "true" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${CONFIGURE_ZSH_AS_DEFAULT_SHELL}" == "true" ]; then
|
if [ "${CONFIGURE_ZSH_AS_DEFAULT_SHELL}" == "true" ]; then
|
||||||
|
# Fixing chsh always asking for a password on alpine linux
|
||||||
|
# ref: https://askubuntu.com/questions/812420/chsh-always-asking-a-password-and-get-pam-authentication-failure.
|
||||||
|
if [ ! -f "/etc/pam.d/chsh" ] || ! grep -Eq '^auth(.*)pam_rootok\.so$' /etc/pam.d/chsh; then
|
||||||
|
echo "auth sufficient pam_rootok.so" >> /etc/pam.d/chsh
|
||||||
|
elif [[ -n "$(awk '/^auth(.*)pam_rootok\.so$/ && !/^auth[[:blank:]]+sufficient[[:blank:]]+pam_rootok\.so$/' /etc/pam.d/chsh)" ]]; then
|
||||||
|
awk '/^auth(.*)pam_rootok\.so$/ { $2 = "sufficient" } { print }' /etc/pam.d/chsh > /tmp/chsh.tmp && mv /tmp/chsh.tmp /etc/pam.d/chsh
|
||||||
|
fi
|
||||||
|
|
||||||
chsh --shell /bin/zsh ${USERNAME}
|
chsh --shell /bin/zsh ${USERNAME}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
13
test/common-utils/alpine-base-zsh-default.sh
Normal file
13
test/common-utils/alpine-base-zsh-default.sh
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Optional: Import test library
|
||||||
|
source dev-container-features-test-lib
|
||||||
|
|
||||||
|
# Definition specific tests
|
||||||
|
check "alpine default shell zsh" \
|
||||||
|
bash -c "getent passwd $(whoami) | awk -F : '{ print $7 }' | grep '/bin/zsh'"
|
||||||
|
|
||||||
|
# Report result
|
||||||
|
reportResults
|
|
@ -143,6 +143,7 @@
|
||||||
"build": {
|
"build": {
|
||||||
"dockerfile": "Dockerfile"
|
"dockerfile": "Dockerfile"
|
||||||
},
|
},
|
||||||
|
"remoteUser": "vscode",
|
||||||
"features": {
|
"features": {
|
||||||
"common-utils": {
|
"common-utils": {
|
||||||
"username": "vscode",
|
"username": "vscode",
|
||||||
|
@ -151,7 +152,15 @@
|
||||||
"upgradePackages": true,
|
"upgradePackages": true,
|
||||||
"installZsh": true
|
"installZsh": true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"remoteUser": "vscode"
|
"alpine-base-zsh-default": {
|
||||||
|
"image": "mcr.microsoft.com/devcontainers/base:alpine",
|
||||||
|
"remoteUser": "vscode",
|
||||||
|
"features": {
|
||||||
|
"common-utils": {
|
||||||
|
"configureZshAsDefaultShell": true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue