From f26b428f8edd27e0020a8efbf371832d8cef7f74 Mon Sep 17 00:00:00 2001 From: Nikolas Garofil Date: Wed, 22 Dec 2021 19:18:04 +0100 Subject: [PATCH] Fix(adduser): better returning to shell of original user --- plugins/adduser/adduser.plugin.zsh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/adduser/adduser.plugin.zsh b/plugins/adduser/adduser.plugin.zsh index 6df23bc77..35a8af16f 100644 --- a/plugins/adduser/adduser.plugin.zsh +++ b/plugins/adduser/adduser.plugin.zsh @@ -19,18 +19,17 @@ adduser() { #and also make sure that after the install script we are no longer the new user temp_installscript=$(mktemp) cat $path_installscript | \ - sed 's/exec zsh -l//' | sed 's/read -r opt/opt=y; echo "\n--- This time I am answering \\"yes\\" for you, but you will still have to type in the password of that user ---"/' \ > $temp_installscript chown ${@[$#]} $temp_installscript && chmod +x $temp_installscript #try installing with sudo or su when not available if [[ -x "$commands[sudo]" ]] ; then - sudo -u ${@[$#]} $temp_installscript + sudo -u ${@[$#]} RUNZSH=no $temp_installscript returncode=$? else if [[ -x "$commands[su]" ]] ; then - su -l ${@[$#]} -c $temp_installscript + su -l ${@[$#]} -c "$temp_installscript --unattended" returncode=$? else echo "You can't become ${@[$#]} (no 'sudo' or 'su' available)" > /dev/stderr;