View Full Version : sudo Path not working
05-15-2002, 11:46 PM
Recently, sudo stopped working correctly on my Powerbook. If I just type "sudo ls," it will ask me for my password, then give me a command not found error. But, if I type "sudo /bin/ls," it will find it and work correctly. Everything works fine when I am logged in as a regular user.
Obviously, something is screwed up in some path setting somewhere, but I can't find it anywhere. Anybody seen this problem before?
05-16-2002, 12:14 AM
hmm, that's curious. well, what's your path before and during sudo?
% echo $PATH
blah blah blah
% sudo echo $PATH
05-16-2002, 12:25 AM
Ahh...didn't think of using echo. Here are the results:
> echo $PATH
> sudo echo $PATH
sudo: echo: command not found
> sudo /bin/echo $PATH
Hmmm...I guess my hunch about the paths was incorrect. Now I am really stumped.
05-16-2002, 12:44 AM
i'm stumped too. can you issue a sudo -s and carefully poke around a little?
what shell do you run?
05-16-2002, 12:59 AM
sudo -s works exactly as expected.
su also works as expected.
It only seems to be a problem when I use sudo with no arguements as in sudo echo $PATH.
I normally run tcsh. I just tried switching over to sh and sudo worked fine, but it is broken in csh and tcsh. This leads me back to thinking that it might be something in my .cshrc file. I will go through and comment out parts of the file and see if that helps.
05-16-2002, 01:12 AM
I got it.
Under my ~/Library/init/tcsh/path file, I had the following line:
setenv PATH="($path /usr/X11R6/bin)"
Commenting out that line took care of the problem. Thank you for pointing me in the right direction!
05-16-2002, 01:27 AM
hmm, so if you contaminate the csh $PATH or $path variables, you get trashed. but why didn't it manifest itself in your base shell?
anyhow, glad you're back in business.
05-16-2002, 09:45 AM
I don't understand how path variables work very well, so I am not really sure why it is behaving the way it is.
The strange thing is, that after I deleted the reference to usr/X11R6/bin in my Path file, I still had usr/X11R6/bin in my regular path variable. So, it looks like I was duplicating that reference. It would stand to reason that a duplication would trash my entire regular user path variable and not just affect sudo.
If you look in man sudo, the docs have a few paragraphs discussing security and user paths. It must have something to do with this. Maybe a duplication or inconsistency causes sudo to not recognize paths.
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.