aboutsummaryrefslogtreecommitdiff
path: root/src/common-utils/main.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/common-utils/main.sh')
-rw-r--r--src/common-utils/main.sh8
1 files changed, 8 insertions, 0 deletions
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