Re: No /sbin PATH after sudo in Fedora 12 even after the PATH is added in .bash_profile

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5 February 2010 01:14, Ed Greshko <Ed.Greshko@xxxxxxxxxxx> wrote:
> suvayu ali wrote:
>> On 4 February 2010 16:13, Tom Horsley <tom.horsley@xxxxxxx> 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?

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


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux