Bug#374713: [Buildd-tools-devel] Bug#374713: Aborts if cd fails but seems to use pwd -P

Roger Leigh rleigh at whinlatter.ukfsn.org
Wed Jun 21 21:58:30 UTC 2006


Christian Hammers <ch at lathspell.de> writes:

>> Thanks for the long explanation but the rationale why it tries to
>> be in the same path as before when running non-interactively is
>> clear to me - what I wondered is why it seems to have *changed* the
>> behaviour regarding the return of getcwd().
>
> Ok, I've just debugged it a bit. dchroot has indeed completely changed the
> source.
>
> In the old version dchroot-0.13 it jumped to the home directory as specified 
> in /etc/passwd *always*, regardless of the actual cwd of the calling user.
> It did this by executing e.g. "/bin/su - ch -c foobar".
>
> My suggestion would be to change the code to do something like:
>   p = popen("/bin/sh -c 'pwd'", "r");
>   target_dir = fgets(p);
>   ... chroot() ...
>   chdir(target_dir);

getenv("PWD") will be easier, since in practice that's all the shell
function will return.  Since this code runs as root, $PWD is a
security risk (it could be set to somewhere sensitive).  But given the
requirement to be compatible with the original dchroot, I don't think
we should attempt to preserve the CWD unless we are preserving the
environment.

It needs to fit into sbuild::session::run_child() in

http://svn.debian.org/wsvn/buildd-tools/trunk/schroot/schroot/sbuild-session.cc?op=file&rev=0&sc=0

This code will need some reworking to do this (it needs teaching about
schroot, dchroot and dchroot-dsa compatibility modes).  It might mean
addition of some virtual methods to the derived
dchroot::dchroot_session type to do this cleanly.

I'll have to think on that overnight.


Regards,
Roger

-- 
Roger Leigh
                Printing on GNU/Linux?  http://gutenprint.sourceforge.net/
                Debian GNU/Linux        http://www.debian.org/
                GPG Public Key: 0x25BFB848.  Please sign and encrypt your mail.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
Url : http://lists.alioth.debian.org/pipermail/buildd-tools-devel/attachments/20060621/4e7c0d19/attachment.pgp


More information about the Buildd-tools-devel mailing list