Sudoers list?

Erik Christiansen erik at dd.nec.com.au
Wed Apr 5 03:19:51 UTC 2006


On Tue, Apr 04, 2006 at 10:14:05PM +0100, Daniel Carrera wrote:
> Chris Bannister wrote:
> >>I don't want to force people to run this script as root. Running stuff 
> >>as root is a really bad habit. I want this script to be as non-root 
> >>friendly as possible. There is only one step that *might* warrant root 
> >>access and that's if the destination directory belongs to root.
> >
> >Just run gksudo and test for whatever error code it gives if the user 
> >isn't in the sudoers file / gives the wrong password.
> 
> The problem with that is that is that the user still gets a password 
> prompt even if they are not sudoers.

But not if doing only "sudo -l" (or -v). I just tried it.
Then the return value can be tested, as already suggested, can't it?:

erik at dvalin:~$ sudo -v
erik at dvalin:~$ echo $?
0

> I guess I'll just assume that the user is a sudoer and give them the 
> prompt...

Hopefully not. :-)

Erik




More information about the ubuntu-users mailing list