FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Fedora User

 
 
LinkBack Thread Tools
 
Old 02-05-2010, 12:14 AM
Ed Greshko
 
Default No /sbin PATH after sudo in Fedora 12 even after the PATH is added in .bash_profile

suvayu ali wrote:
> On 4 February 2010 16:13, Tom Horsley <tom.horsley@att.net> wrote:
>
>> On Thu, 4 Feb 2010 16:00:39 -0800
>> suvayu ali wrote:
>>
>>
>>> As far as I understand this, sudo still uses your (the regular user's)
>>> $PATH.
>>>
>> Nope, that's merely what the docs claim. In fact, the security geeks
>> decided sudo absolutely needed to have a hard coded PATH and as far
>> as I know the only way to fix that is to rebuild it from source. It
>> has been like this for a while now.
>>
>
> Are you sure? I tried this after your post on my lab machine (not
> Fedora though, its Ubuntu 9.04)
>
> $ sudo echo $PATH
> [sudo] password for suvayu:
> /home/suvayu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/suvayu/root/bin
>
> I see two different directories that I add to $PATH in my
> .bash_profile and .bashrc
>
>
>> https://bugzilla.redhat.com/show_bug.cgi?id=475990
>>
>> Maybe you could create an alias that runs sudo env PATH=$PATH "$@"
>> or something to sneak the path back into the sudo'ed command...
>>
>
> That Bugzilla says updates have been pushed to F10. Shouldn't that
> mean its fixed in F11 and F12?
>
>
I think you miss one thing....

When you do "sudo echo $PATH" $PATH is expanded before the sudo command
is executed since it is an argument to the sudo command.

To demonstrate what Tom is saying you need to prevent $PATH from being
expanded by using sudo sh -c 'echo $PATH'

As in...

[egreshko@f12 ~]$ sudo sh -c 'echo $PATH'
/sbin:/bin:/usr/sbin:/usr/bin

--
The FALAFEL SANDWICH lands on my HEAD and I become a VEGETARIAN... is a
barbecued OYSTER! Yum!

--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines
 
Old 02-05-2010, 12:53 AM
Ed Greshko
 
Default No /sbin PATH after sudo in Fedora 12 even after the PATH is added in .bash_profile

Sam Sharpe wrote:
> On 5 February 2010 01:14, Ed Greshko <Ed.Greshko@greshko.com> wrote:
>
>> suvayu ali wrote:
>>
>>> On 4 February 2010 16:13, Tom Horsley <tom.horsley@att.net> wrote:
>>>
>>>
>>>> On Thu, 4 Feb 2010 16:00:39 -0800
>>>> suvayu ali wrote:
>>>>
>>>>
>>>>
>>>>> As far as I understand this, sudo still uses your (the regular user's)
>>>>> $PATH.
>>>>>
>>>>>
>>>> Nope, that's merely what the docs claim. In fact, the security geeks
>>>> decided sudo absolutely needed to have a hard coded PATH and as far
>>>> as I know the only way to fix that is to rebuild it from source. It
>>>> has been like this for a while now.
>>>>
>>>>
>>> Are you sure? I tried this after your post on my lab machine (not
>>> Fedora though, its Ubuntu 9.04)
>>>
>>> $ sudo echo $PATH
>>> [sudo] password for suvayu:
>>> /home/suvayu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/suvayu/root/bin
>>>
>>> I see two different directories that I add to $PATH in my
>>> .bash_profile and .bashrc
>>>
>>>
>>>
>>>> https://bugzilla.redhat.com/show_bug.cgi?id=475990
>>>>
>>>> Maybe you could create an alias that runs sudo env PATH=$PATH "$@"
>>>> or something to sneak the path back into the sudo'ed command...
>>>>
>>>>
>>> That Bugzilla says updates have been pushed to F10. Shouldn't that
>>> mean its fixed in F11 and F12?
>>>
>>>
>>>
>> I think you miss one thing....
>>
>> When you do "sudo echo $PATH" $PATH is expanded before the sudo command
>> is executed since it is an argument to the sudo command.
>>
>> To demonstrate what Tom is saying you need to prevent $PATH from being
>> expanded by using sudo sh -c 'echo $PATH'
>>
>> As in...
>>
>> [egreshko@f12 ~]$ sudo sh -c 'echo $PATH'
>> /sbin:/bin:/usr/sbin:/usr/bin
>>
>
> What about this then?
>
> [sam@samlap ~]$ echo $PATH
> /usr/lib64/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/real/RealPlayer:/home/sam/.bin:/opt/real/RealPlayer:/home/sam/.bin
>
> [sam@samlap ~]$ sudo sh -c 'echo $PATH'
> /usr/bin:/bin
>
> [sam@samlap ~]$ which lvdisplay
> /sbin/lvdisplay
>
> [sam@samlap ~]$ sudo lvdisplay
> --- Logical volume ---
> LV Name /dev/VolGroup00/LogVol00
> VG Name VolGroup00
> LV UUID BPwrBK-v6IM-7mkX-pywX-amSI-nACz-xizvzL
> LV Write Access read/write
> LV Status available
> # open 1
> LV Size 109.62 GB
> Current LE 3508
> Segments 1
> Allocation inherit
> Read ahead sectors auto
> - currently set to 256
> Block device 253:0
>
> --- Logical volume ---
> LV Name /dev/VolGroup00/LogVol01
> VG Name VolGroup00
> LV UUID F0Nil4-F0Nf-fDX1-5YxX-QEyc-jPGf-kOiRcy
> LV Write Access read/write
> LV Status available
> # open 1
> LV Size 1.94 GB
> Current LE 62
> Segments 1
> Allocation inherit
> Read ahead sectors auto
> - currently set to 256
> Block device 253:1
>
> How can I run lvdisplay via Sudo, if it has a hard-coded path which
> doesn't include /sbin? (but it is in *my* PATH). Am I being an idiot?
>
>
Try running....

sudo sh -c 'lvdisplay'




--
Mene, mene, tekel, upharsen.

--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines
 
Old 02-05-2010, 06:09 AM
Ed Greshko
 
Default No /sbin PATH after sudo in Fedora 12 even after the PATH is added in .bash_profile

Ed Greshko wrote:
> Sam Sharpe wrote:
>
>>
>> What about this then?
>>
>> [sam@samlap ~]$ echo $PATH
>> /usr/lib64/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/real/RealPlayer:/home/sam/.bin:/opt/real/RealPlayer:/home/sam/.bin
>>
>> [sam@samlap ~]$ sudo sh -c 'echo $PATH'
>> /usr/bin:/bin
>>
>> [sam@samlap ~]$ which lvdisplay
>> /sbin/lvdisplay
>>
>> [sam@samlap ~]$ sudo lvdisplay
>> --- Logical volume ---
>> LV Name /dev/VolGroup00/LogVol00
>> VG Name VolGroup00
>> LV UUID BPwrBK-v6IM-7mkX-pywX-amSI-nACz-xizvzL
>> LV Write Access read/write
>> LV Status available
>> # open 1
>> LV Size 109.62 GB
>> Current LE 3508
>> Segments 1
>> Allocation inherit
>> Read ahead sectors auto
>> - currently set to 256
>> Block device 253:0
>>
>> --- Logical volume ---
>> LV Name /dev/VolGroup00/LogVol01
>> VG Name VolGroup00
>> LV UUID F0Nil4-F0Nf-fDX1-5YxX-QEyc-jPGf-kOiRcy
>> LV Write Access read/write
>> LV Status available
>> # open 1
>> LV Size 1.94 GB
>> Current LE 62
>> Segments 1
>> Allocation inherit
>> Read ahead sectors auto
>> - currently set to 256
>> Block device 253:1
>>
>> How can I run lvdisplay via Sudo, if it has a hard-coded path which
>> doesn't include /sbin? (but it is in *my* PATH). Am I being an idiot?
>>
>>
>>
> Try running....
>
> sudo sh -c 'lvdisplay'
>
>
>
I was more brief than I should have been...and maybe a bit inaccurate.

I should have said....

Try running

sudo sh -c 'lvdisplay'

and think about it a moment and look at the following.....

[gnomer@f12 ~]$ echo $PATH
/usr/lib/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/lib/ccache:/usr/local/bin:
/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/gnomer/bin

[gnomer@f12 ~]$ which ifconfig
/usr/bin/which: no ifconfig in
(/usr/lib/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/lib/ccache:/usr/local/bin:
/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/gnomer/bin)

[gnomer@f12 ~]$ sudo echo $PATH
/usr/lib/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/lib/ccache:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:
/usr/sbin:/home/gnomer/bin

[gnomer@f12 ~]$ sudo sh -c 'echo $PATH'
/sbin:/bin:/usr/sbin:/usr/bin

[gnomer@f12 ~]$ sudo ifconfig lo
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:64 errors:0 dropped:0 overruns:0 frame:0
TX packets:64 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:5808 (5.6 KiB) TX bytes:5808 (5.6 KiB)

but....

A script is in /home/gnomer/bin called xmee which executes another
program called iko. iko is located in /usr/local/bin.

[gnomer@f12 ~]$ cat bin/xmee
iko

[gnomer@f12 ~]$ cat /usr/local/bin/iko
echo "I'm in usr local bin"

[gnomer@f12 ~]$ xmee
I'm in usr local bin

[gnomer@f12 ~]$ sudo xmee
sudo: xmee: command not found



--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines
 

Thread Tools




All times are GMT. The time now is 08:43 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org