Closed holme-r closed 1 year ago
The problem is that sudo cannot easily tell that the command is being run in the background when it is run from a shell script where there is no job control. A workaround is to add set -m
to the script which will result in sudo being run in its own (background) process group. I'm testing a new heuristic to handle this case that will hopefully make it into sudo 1.9.13.
This should be fixed in sudo 1.9.13.
I managed to fix the issue by turning off the
use_pty
option in/etc/sudoers
For anyone coming here later, please note that turning off use_pty
could expose you to privilege escalation via TIOCSTI
or TIOCLINUX
based command injection, depending e.g. on how your kernel is configured. ttyjack can be used to see that in action.
After running the following innocuous looking shell script, the terminal stops working correctly and I have to type 'reset' to recover it:
I ran the script as a non-root user without sudo (i.e. just
./my-script
, notsudo ./my-script
) On a fresh install of Ubuntu 22.10, after running the script, the terminal stops echoing characters that you type. On Ubuntu 22.04, carriage returns don't result in correct placement of characters (you see zig zag lines of text instead of columns).I managed to fix the issue by turning off the use-pty option in /etc/sudoers
On Ubuntu 22.10: Sudo version 1.9.11p3 Sudoers policy plugin version 1.9.11p3 Sudoers file grammar version 48 Sudoers I/O plugin version 1.9.11p3 Sudoers audit plugin version 1.9.11p3