[Linux-disciples] Making sudo portable

Stephen R Laniel steve at laniels.org
Mon Oct 24 19:21:59 EDT 2005


I've been writing my scripts nowadays to be more portable,
for instance using '${HOME}' rather than '~' or
'/home/slaniel', using 'if [ ... ]' blocks specific to the
different OSes I run them on, etc.

But I just noticed one place where portability seems hard to
come by: sudo. I'd like to be able to say,

if( ${USER} is a sudoer ) {
	some stuff;
}
else {
	echo Some error;
}

The reason I would like this is that I have a script that
runs 'sudo apt-get upgrade', and I just now accidentally ran
it on a machine where I don't have sudoer privileges.

Is there any kind of portable isASudoer() function? 

-- 
Stephen R. Laniel
steve at laniels.org
+(617) 308-5571
http://laniels.org/
PGP key: http://laniels.org/slaniel.key
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.bostoncoop.net/pipermail/linux-disciples/attachments/20051024/7ca7812c/attachment.pgp


More information about the Linux-disciples mailing list