[sudo-users] Can I use the value of an environment variable in a sudoers rule ?

Andy Cowley Andy.Cowley at uwe.ac.uk
Tue Nov 17 13:47:04 EST 2009


I want to do something like

ALL ALL=/bin/mount -o loop -t ext3  $HOME/* $HOME/*

to allow users to loopback mount a filesystem image, but only in their
own home directory.
by doing, for example

$ sudo /bin/mount -o loop -t ext3 $HOME/imagefile $HOME/mountpoint

That one passes the value of $HOME to sudo and rule doesn't match.
Single quoting $HOME to avoid shell interpretation passes $HOME to
/bin/mount whichfails to understand.

I have set my /etc/sudoers to preserve the value of $HOME.
It will work with '/bin/bash' inserted but that seems wide open to
abuse.
Is there any way to get sudo to use the value of $HOME in a rule?


Please reply to mailto:andy.cowley at uwe.ac.uk as I'm not subscribed (yet).
best

Andy


This email was independently scanned for viruses by McAfee anti-virus software and none were found


More information about the sudo-users mailing list