This is quite tricky I guess, or at least not desired very often.
What I am not after is:
Disabling password with
user ALL=(ALL) NOPASSWD: ALL
Or a similar trick.
I know how to read sudo password from
stdin, and this is working fine
but you still get the prompt:
$ echo $PW | sudo -S whoami [sudo] password for oz123: root
The man page shows I can use
$ echo $PW | sudo -S -p "foo " whoami foo root $ echo $PW | sudo -S -p " " whoami root
A single space works.
Passing an empty string does not seem to work ...
$ echo $PW | sudo -S -p "" whoami [sudo] password for oz123: root
So the question is:
How do you define an empty string as a valid value for
update - sudo version
$ sudo --version Sudo version 1.8.21p2 Sudoers policy plugin version 1.8.21p2 Sudoers file grammar version 46 Sudoers I/O plugin version 1.8.21p2
(on ubuntu 18.04)