Bug 964

Summary: sudo -S does not read password from stdin
Product: Sudo Reporter: buzo <buzo+sudo>
Component: SudoAssignee: Todd C. Miller <Todd.Miller>
Status: RESOLVED WORKSFORME    
Severity: normal    
Priority: low    
Version: 1.9.5   
Hardware: PC   
OS: Linux   

Description buzo 2021-02-11 06:33:22 MST
«sudo -S» does not read the password from stdin any more. Instead, the -S is completely ignored and the regular password input happens, if connected to a terminal. If not, these two lines are printed:

sudo: no password was provided
sudo: a password is required

This is a regression in 1.9.5p2. It used to work till 1.9.5p1.
Comment 1 Todd C. Miller 2021-02-11 08:39:59 MST
I'm unable to reproduce your problem and there weren't any changes between 1.9.5p1 and 1.9.5p2 that would explain it.  Here's what I see with 1.9.5p2 on Ubuntu 20.04.2:

$ echo test123 | sudo -Sk id
[sudo] password for testuser: 
uid=0(root) gid=0(root) groups=0(root)

And here it is with no tty:

$ tty
not a tty
$ echo test123 | sudo -Sk id
[sudo] password for testuser: 
uid=0(root) gid=0(root) groups=0(root)

Are you using pre-built packages or did you compile sudo yourself?
Comment 2 buzo 2021-02-12 05:35:38 MST
Sorry for wasting your time, it was a bug in my script, not in sudo. I somehow managed to call ssh with the -n option, which obviously does not let the password through to sudo. :(