determining sudo access

Donald Russell russell.don at gmail.com
Thu Jan 20 17:43:11 UTC 2011


On Wed, Jan 19, 2011 at 15:07, Tim <ignored_mailbox at yahoo.com.au> wrote:

> On Wed, 2011-01-19 at 14:34 -0800, Donald Russell wrote:
> > In /etc/profile.d/local.sh I'd like to modify the PATH env variable to
> > include /sbin /usr/sbin and /usr/local/sbin but only if the user has
> > sudo access.
>
> Even if that person does have sudo access, there are probably times when
> they should use the command in /bin rather than /sbin, et cetera.  There
> are, or used to be, various commands that had different versions in
> each.
>
> If you mean for that path to change depending on whether they had used
> the sudo command, that'd be a different thing, and would probably work
> without problems.
>

hmmm, same program/command in different directories with different
behaviour...
I guess the simplest thing is to let the people with sudo access adjust
their own PATH in ~/.profile or the like.

But, to do as you suggest, only alter the path if the sudo command were
used, would require a sudo function...

something like:
sudo() {
    local oldath=${PATH}
    PATH="/usr/local/sbin:/usr/sbin:/sbin:${PATH}"
    /usr/bin/sudo $@
    local retval=$?
    PATH=${oldpath}
    return ${retval}
}

Interesting idea...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.fedoraproject.org/pipermail/users/attachments/20110120/9caca176/attachment.html 


More information about the users mailing list