sudo-project/sudo

In version 1.8.29, executing sudoedit -S will freeze the terminal.

rtczza opened this issue · 4 comments

Version information:

Version 1.8.29 of Sudo
Sudoers Policy plug-in version 1.8.29
Sudoers file syntax version 46
Sudoers I/O plugin version 1.8.29

Implementation status:

[test@localhost sudo]$ echo "Passwd123" | sudoedit  -S test/test.txt
Vim: Warning: Input is not coming from terminal (keyboard)
Vim: Read error, exiting...
Vim: preserving files...
Vim: Finished.
sudoedit: test/test.txt unchanged
[test@localhost 0913]$ sudo -k
[test@localhost sudo]$ echo "Passwd123" | sudoedit  -S test/test.txt
[sudo] test password: Vim: Warning: Input is not coming from terminal (keyboard)
[test@localhost sudo]$

The content in test/test.txt can be modified normally, but the terminal is blocked after the modification.


Add the following at the end of the '/etc/sudoers' file

Defaults log_output
Defaults! /usr/bin/utsudoreplay ! log_output
Defaults! /sbin/reboot ! log_output

Then perform the above -S operation, and the terminal will not be jammed.

It is not clear why the above problem occurs.

A screen-oriented editor like vim cannot function with the standard input redirected like this which is why you get:

Vim: Warning: Input is not coming from terminal (keyboard)

I don't think there is a way to use sudoedit -S with a screen-oriented editor like vim or emacs. It should be possible to use a GUI version, however.

After testing, using the GUI editor, there is indeed no problem of jamming. For example VsCode

Now one question is, if sudoedit -S cannot be used with a screen-oriented editor, what is the use case for sudoedit -S?

Looking forward to your reply.

sudoedit is just another name for sudo, which is why it too has a -S option. In most cases, sudo -S is used for non-interactive commands so it is not usually a good fit for an editor, unless the editor is graphical or scripted.

Thanks for explaining!

sudo-S is really convenient. For interactive operations, we don't expect much from sudoedit -S.

we use sudoedit -S for non-interactive commands.

Thanks again.