sudo-project / sudo

Utility to execute a command as another user
https://www.sudo.ws
Other
1.15k stars 208 forks source link

Use of "-l" and stdout redirected to /dev/null hangs sudo #335

Closed vincentbernat closed 7 months ago

vincentbernat commented 7 months ago

Hey!

Since 1.9.15, sudo -l ls > /dev/null locks the sudo process on fcntl(1, F_SETLKW, {l_type=F_WRLCK, l_whence=SEEK_CUR, l_start=0, l_len=0}). I believe this is because of the tentative to avoid multiple sudo processes to modify the terminal settings.

millert commented 7 months ago

Locking /dev/null on Linux always seems to block, which is an interesting choice. Only locking if the fd is actually a tty fixes the problem.

millert commented 7 months ago

The fix is present in sudo 1.9.15p3