1834009 Members
1744 Online
110063 Solutions
New Discussion

Check sudo Rights?

 
Justin Willoughby
Regular Advisor

Check sudo Rights?

Hello All!

I would like to check via a script if the user running the script has rights to sudo (at all). I setup a script to do this originally using a version that could take the password from stdin. However the version I have on the system I am not using does not have this option. sudo version 1.6.2b1

Before I could just `echo "" | sudo -l -S` and check the exit code/status. If it was 0 they the user has rights to some sudo'ing, otherwise they did not.

There is not a precompiled binary of the newest version that has the -S option for HP/UX 11.00 that I know of.

This there any why to get the same thing using sudo version 1.6.2b1?

Without the -S option sudo always prompts for the password for users who do not have any sudo rights. I want it to just fail and allow me to check via the exit status.

- Justin