mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-04-17 04:29:14 +02:00
fix(installer): handle sudo shims that don't support -k flag
On Alpine Linux with doas-sudo-shim, `sudo -k` fails because the shim doesn't support the -k option. Fall back to running sudo without -k when it fails. Fixes #13475
This commit is contained in:
parent
52d93f18d6
commit
f32a853583
1 changed files with 4 additions and 1 deletions
|
|
@ -473,7 +473,10 @@ EOF
|
||||||
# be prompted for the password either way, so this shouldn't cause any issues.
|
# be prompted for the password either way, so this shouldn't cause any issues.
|
||||||
#
|
#
|
||||||
if user_can_sudo; then
|
if user_can_sudo; then
|
||||||
sudo -k chsh -s "$zsh" "$USER" # -k forces the password prompt
|
# Use -k to invalidate cached credentials (forces password prompt).
|
||||||
|
# Some sudo shims (e.g. doas-sudo-shim on Alpine) don't support -k,
|
||||||
|
# so fall back to running without it.
|
||||||
|
sudo -k chsh -s "$zsh" "$USER" 2>/dev/null || sudo chsh -s "$zsh" "$USER"
|
||||||
else
|
else
|
||||||
chsh -s "$zsh" "$USER" # run chsh normally
|
chsh -s "$zsh" "$USER" # run chsh normally
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue