<br><br><div class="gmail_quote">On Wed, Jan 19, 2011 at 15:07, Tim <span dir="ltr"><<a href="mailto:ignored_mailbox@yahoo.com.au">ignored_mailbox@yahoo.com.au</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">On Wed, 2011-01-19 at 14:34 -0800, Donald Russell wrote:<br>
> In /etc/profile.d/local.sh I'd like to modify the PATH env variable to<br>
> include /sbin /usr/sbin and /usr/local/sbin but only if the user has<br>
> sudo access.<br>
<br>
</div>Even if that person does have sudo access, there are probably times when<br>
they should use the command in /bin rather than /sbin, et cetera. There<br>
are, or used to be, various commands that had different versions in<br>
each.<br>
<br>
If you mean for that path to change depending on whether they had used<br>
the sudo command, that'd be a different thing, and would probably work<br>
without problems.<br></blockquote></div><br>hmmm, same program/command in different directories with different behaviour... <br>I guess the simplest thing is to let the people with sudo access adjust their own PATH in ~/.profile or the like.<br>
<br>But, to do as you suggest, only alter the path if the sudo command were used, would require a sudo function...<br><br>something like:<br>sudo() {<br> local oldath=${PATH}<br> PATH="/usr/local/sbin:/usr/sbin:/sbin:${PATH}"<br>
/usr/bin/sudo $@<br> local retval=$?<br> PATH=${oldpath}<br> return ${retval}<br>}<br><br>Interesting idea...<br>