SudoHelper broken for sudo versions newer than 1.8.7 (released 2013)
In version 1.8.8 of the sudo utility the description of the -S flag was changed from "causes sudo to read the password from the standard input instead of the terminal device" to "write the prompt to the standard error and read the password from the standard input instead of using the terminal device" (emphasis mine), which is documented at https://www.sudo.ws/man.html between the man pages for those two versions.
Inside the SudoHelper class, a listener to the effect of when(partial: prompt, from: standardOutput) exists to wait for the sudo command to present a prompt asking the user for a password. Since it listens on stdout, but modern sudo writes that prompt to stderr, the listener will hang forever until terminated.
Writing a bytecode patch to the groovy ssh library that changed nothing except replacing that occurrence of standardOutput with standardError allowed sudo executions to proceed perfectly on every machine I had available to me to test.
Environment info
groovy-ssh-2.10.1 java_1.8.0_242-8u242-b08-0ubuntu3~18.04-b08 First encountered on Ubuntu kernel 4.15.0-76, later verified on a variety of linux machines
Steps to reproduce
- connect to a machine with a version of sudo newer than 1.8.7 using username/password authentication
- attempt to execute a command as sudo