aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common-utils/devcontainer-feature.json2
-rw-r--r--src/common-utils/main.sh8
-rw-r--r--test/common-utils/alpine-base-zsh-default.sh13
-rw-r--r--test/common-utils/scenarios.json13
4 files changed, 33 insertions, 3 deletions
diff --git a/src/common-utils/devcontainer-feature.json b/src/common-utils/devcontainer-feature.json
index aadc1bc..a924aa7 100644
--- a/src/common-utils/devcontainer-feature.json
+++ b/src/common-utils/devcontainer-feature.json
@@ -1,6 +1,6 @@
{
"id": "common-utils",
- "version": "2.0.10",
+ "version": "2.0.11",
"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.",
diff --git a/src/common-utils/main.sh b/src/common-utils/main.sh
index 144478e..6d5ac07 100644
--- a/src/common-utils/main.sh
+++ b/src/common-utils/main.sh
@@ -437,6 +437,14 @@ if [ "${INSTALL_ZSH}" = "true" ]; then
fi
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}
fi
diff --git a/test/common-utils/alpine-base-zsh-default.sh b/test/common-utils/alpine-base-zsh-default.sh
new file mode 100644
index 0000000..9fc00a2
--- /dev/null
+++ b/test/common-utils/alpine-base-zsh-default.sh
@@ -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
diff --git a/test/common-utils/scenarios.json b/test/common-utils/scenarios.json
index 21cb940..9800242 100644
--- a/test/common-utils/scenarios.json
+++ b/test/common-utils/scenarios.json
@@ -143,6 +143,7 @@
"build": {
"dockerfile": "Dockerfile"
},
+ "remoteUser": "vscode",
"features": {
"common-utils": {
"username": "vscode",
@@ -151,7 +152,15 @@
"upgradePackages": true,
"installZsh": true
}
- },
- "remoteUser": "vscode"
+ }
+ },
+ "alpine-base-zsh-default": {
+ "image": "mcr.microsoft.com/devcontainers/base:alpine",
+ "remoteUser": "vscode",
+ "features": {
+ "common-utils": {
+ "configureZshAsDefaultShell": true
+ }
+ }
}
}