how to confirm non-root user is a qualified sudo user in a (perl) script?
ken.wolcott at med.ge.com
Thu Mar 18 16:27:31 EST 2004
Thank you very much for your response.
However, just like telnet and ftp and a multitude of other user
applications that are usually meant for interactive use that do require
authentication, the password prompt is at the tty layer, not in the
STDIN layer. So just redirecting the input, output and stderr, as your
example code does, is not sufficient. It looks like I need to use
expect, which handles the tty layer, or expect within perl. I was
hoping that there was something in the usage that I was missing with
sudo that would not prompt me for a password, and would just silently
fail (nonzero error code response) and/or a simple stderr error msg.
Your code snippet constantly and consistently fails (at least for me) in
spite of whether the user who runs it is authorized to run sudo or not.
I even inserted a benign command for the user to execute with sudo (eg:
/bin/ls) and it still fails. Doing the equivalent from the command line
directly also fails as the password is still displayed.
On Thu, 2004-03-18 at 13:32, Todd C. Miller wrote:
> You could do something like:
> system("sudo -S -v </dev/null >/dev/null 2>&1");
> die "$0: You are not authorized!\n" if $?;
> - todd
More information about the sudo-users