Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local echo disabled when emergency shell is entered after mount timeout during password prompt #144

Closed
nmeum opened this issue Apr 3, 2022 · 0 comments · Fixed by #146
Closed

Comments

@nmeum
Copy link
Contributor

nmeum commented Apr 3, 2022

While performing some tests with Booster on LUKS-encrypted system. I noticed that the BusyBox emergency shell does not have local echo enabled when it is started due to the mount_timeout option while Booster is prompting for a password.

This is due to the fact that the readPassword function correctly disables local echo:

booster/init/console.go

Lines 195 to 201 in 8666e7b

newState := *termios
newState.Lflag &^= unix.ECHO
newState.Lflag |= unix.ICANON | unix.ISIG
newState.Iflag |= unix.ICRNL
if err := unix.IoctlSetTermios(fd, unix.TCSETS, &newState); err != nil {
return nil, err
}

The function also restores local echo via defer:

defer unix.IoctlSetTermios(fd, unix.TCSETS, termios)

However, I believe on mount timeout this function will not return (since it is executed in a different goroutine) and thus the defer statement is not executed. Hence, I think the emergencyShell implementation needs to restore some sort of sane stty settings:

booster/init/main.go

Lines 790 to 796 in edeff4c

func emergencyShell() {
if _, err := os.Stat("/usr/bin/busybox"); !os.IsNotExist(err) {
if err := unix.Exec("/usr/bin/busybox", []string{"sh", "-I"}, nil); err != nil {
severe("Unable to start an emergency shell: %v", err)
}
}
}

This could either be achieved by executing something like busybox stty sane before spawing the shell (which would require the stty Busybox applet) or, alternatively, by manually modifying the termios settings accordingly (see readPassword code above).

nmeum added a commit to nmeum/booster that referenced this issue Apr 7, 2022
nmeum added a commit to nmeum/booster that referenced this issue Apr 7, 2022
nmeum added a commit to nmeum/booster that referenced this issue Apr 7, 2022
nmeum added a commit to nmeum/booster that referenced this issue Apr 7, 2022
nmeum added a commit to nmeum/booster that referenced this issue Apr 7, 2022
algitbot pushed a commit to alpinelinux/aports that referenced this issue Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant