Re: Should I redefine PATH in my shell scripts

Francis Moreau <francis.moro@xxxxxxxxx> writes:

Maxwell Lol <nospam@xxxxxxxxxxx> writes:

Francis Moreau <francis.moro@xxxxxxxxx> writes:

Actually I've been hit when trying to run a script through sudo. It
fails because the PATH is changed by sudo and external tools couldn't
be called anymore.

This sounds like a good thing. If you let sudo run any external tool,
you risk the danger of someone being able to break into the root

Fair enough but some of my scripts are intended to be run as root

And if I log to root account by using 'su -' then it works fine. But
if I used "sudo" then it fails.

But if it is run by sudo, then it is invoked by a non-root user. And
if you get an error, then perhaps your script is not secure.