Bug#347935: [Pkg-shadow-devel] Bug#347935: ccache support in pbuilder
is broken with 'su -p' not preserving PATH
Junichi Uekawa
dancer at netfort.gr.jp
Sun Jan 15 01:03:57 UTC 2006
Hi,
> > Methinks we will need to evaluate what needs to be fixed, and how
> > difficult the fix is, and then proceed further.
>
> Maybe, there is smth. wrong with .*rc of target user's shell?
> For example, I see that environment is preserved by `su -p`:
>
> > cherokee:~# echo $PATH
> > /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11
> > cherokee:~# export PATH=$PATH:/usr/games
> > cherokee:~# echo $PATH
> > /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games
> > cherokee:~# su -p root /usr/bin/env | grep PATH
> > PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games
>
> and not preserved without -p, as intended:
>
> > cherokee:~# su root /usr/bin/env | grep PATH
> > PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11
The main problem is that you are calling '/usr/bin/env'.
The default behavior of su without args specified has changed.
It's probably reading login.defs and setting it to:
ENV_SUPATH PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bi
even when -p is specified.
> P.S. you should do strace (-f) on your system to see what
> shell is being run and what rc file does it source...
>
root at dancer64:/# export PATH='/this-is-test':$PATH
login 1:4.0.13-7
root at dancer64:/# echo 'echo $PATH' | su
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11
root at dancer64:/# echo 'echo $PATH' | su -p
/this-is-test:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin
root at dancer64:/# echo 'echo $PATH' | su -p root
/this-is-test:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin
root at dancer64:/# su -p root /usr/bin/env | grep PATH
PATH=/this-is-test:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin
root at dancer64:/# su root /usr/bin/env | grep PATH
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11
login_1:4.0.14-2
root at dancer64:/# echo 'echo $PATH' | su -p root
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11
root at dancer64:/# echo 'echo $PATH' | su -p
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11
root at dancer64:/# echo 'echo $PATH' | su
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11
root at dancer64:/# su root /usr/bin/env | grep PATH
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11
root at dancer64:/# su -p root /usr/bin/env | grep PATH
PATH=/this-is-test:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin
I'm attaching the following files,
23 strace -f -o /tmp/log1 su -p root /usr/bin/env | grep PATH
26 echo 'echo $PATH' | strace -f -o /tmp/log2 su -p
-------------- next part --------------
A non-text attachment was scrubbed...
Name: log1
Type: application/octet-stream
Size: 35581 bytes
Desc: not available
Url : http://lists.alioth.debian.org/pipermail/pkg-shadow-devel/attachments/20060115/a079a03d/log1-0001.obj
-------------- next part --------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: log2
Type: application/octet-stream
Size: 33977 bytes
Desc: not available
Url : http://lists.alioth.debian.org/pipermail/pkg-shadow-devel/attachments/20060115/a079a03d/log2-0001.obj
-------------- next part --------------
regards,
junichi
--
dancer@{debian.org,netfort.gr.jp} Debian Project
More information about the Pkg-shadow-devel
mailing list