NetBSD-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: sudo from qemu serial console: no input from stdin
bad%bsd.de@localhost (Christoph Badura) writes:
>And it hangs there. ^C and ^T work, though. It's just that nothing
>happens when pressing ENTER, ^M, ^J, or ^D.
>My GSoC student just reported that after "sudo pkgin install vim"
>it prints "proceed ? [Y/n]" and after entering "y" and ENTER nothing
>happens.
>This doesn't happen when logging in via ssh.
>Does anyone else see this?
That is probably a sudo issue. By default sudo acts as a tty
emulator like:
|-+= 01407 root login
| \-+= 00692 root -sh
| \-+= 00975 root sudo -s
| \-+= 00983 root sudo -s
| \--= 00989 root /bin/sh
Where the outer sudo reads raw tty input and should pass input
to the started command. However:
USER CMD PID FD MOUNT INUM MODE SZ|DV R/W
root sudo 975 0 / 284552 crw------- constty rw
root sudo 975 1 / 284552 crw------- constty rw
root sudo 975 2 / 284552 crw------- constty rw
root sudo 975 9 / 284563 crw-rw-rw- tty rw
root sudo 975 11 /dev/pts 6 crw-rw-rw- ptc,1 rw
root sudo 975 14 / 284552 crw------- constty rw
root sudo 975 15 / 284552 crw------- constty rw
root sudo 975 16 / 284552 crw------- constty rw
root sudo 983 0 / 284552 crw------- constty rw
root sudo 983 1 / 284552 crw------- constty rw
root sudo 983 2 / 284552 crw------- constty rw
root sudo 983 12 /dev/pts 5 crw--w---- pts/1 rw
root sh 989 0 / 284552 crw------- constty rw
root sh 989 1 / 284552 crw------- constty rw
root sh 989 2 / 284552 crw------- constty rw
root sh 989 12 / 284563 crw-rw-rw- tty rw
The started command (sh) has only open file handles to the console.
The outer sudo process reads from constty and passes it to the pty,
it also reads back the echo and writes it back to constty.
Neither the innner sudo process nor the command see any input, except
for ctrl-c, where the command sees the signal, and prints the new
prompt directly to constty.
989 989 sh SIGINT caught handler=0x1c1c1df40 mask=0x0 code=0x0
989 989 sh __sigprocmask14(0x3, 0x7f7fffea3ff0, 0) = 0
989 989 sh emul(netbsd)
989 989 sh write(0x2, 0x715c5c94f000, 0x1) = 1
"\n"
989 989 sh __wait450(0xffffffff, 0x7f7fffea449c, 0x13, 0) Err#10 ECHILD
989 989 sh __stat50("/var/mail/root", 0x7f7fffea4450) Err#2 ENOENT
989 989 sh write(0x2, 0x715c5c94f000, 0x2) = 2
"# "
In the ssh case:
-+= 00942 root -sh
\-+= 01631 root sudo -s
\-+= 01528 root sudo -s
\--= 00977 root /bin/sh
USER CMD PID FD MOUNT INUM MODE SZ|DV R/W
root sudo 1631 0 /dev/pts 7 crw--w---- pts/2 rw
root sudo 1631 1 /dev/pts 7 crw--w---- pts/2 rw
root sudo 1631 2 /dev/pts 7 crw--w---- pts/2 rw
root sudo 1631 9 / 284563 crw-rw-rw- tty rw
root sudo 1631 11 /dev/pts 10 crw-rw-rw- ptc,3 rw
root sudo 1528 0 /dev/pts 7 crw--w---- pts/2 rw
root sudo 1528 1 /dev/pts 7 crw--w---- pts/2 rw
root sudo 1528 2 /dev/pts 7 crw--w---- pts/2 rw
root sudo 1528 12 /dev/pts 9 crw--w---- pts/3 rw
root sh 977 0 /dev/pts 9 crw--w---- pts/3 rw
root sh 977 1 /dev/pts 9 crw--w---- pts/3 rw
root sh 977 2 /dev/pts 9 crw--w---- pts/3 rw
root sh 977 12 / 284563 crw-rw-rw- tty rw
The started command is connected to the new pty opened by sudo and
receives the data that the outer sudo writes to it.
N.B. you could avoid this by disabling the pty mode in sudoers.
Home |
Main Index |
Thread Index |
Old Index