[buildd-tools-devel] Bug#633671: Bug#633671: schroot behaves differently depending on cwd
Roger Leigh
rleigh at codelibre.net
Tue Jul 12 19:33:23 UTC 2011
On Tue, Jul 12, 2011 at 08:41:53PM +0200, Thibaut VARENE wrote:
> While debugging the old 'create-chroot.sh' script from pkern that was having hickups, I finally realized that schroot behaves
> apparently inconsistently depending on the cwd:
>
> This works:
> buildd at envy:~$ schroot -c sid-ia64-sbuild -u root -- apt-get update
> Hit http://debian.ens-cachan.fr sid InRelease
> [...]
>
> This doesn't work:
> buildd at envy:~/chroots$ schroot -c sid-ia64-sbuild -u root -- apt-get update
> E: Failed to change to directory '/home/buildd/chroots': No such file or directory
>
> >From what I can tell, trying to run schroot from any directory /below/ the home directory fails with the above error.
> Running from "higher" directories (such as /, or /tmp) works.
>
> I've traced both schroot invocations with -v, there is absolutely no difference (save of course for the session UUID) in the outputs.
This is known and expected behaviour. The reason is that when you
enter the chroot, schroot will change you into the /same directory/
inside the chroot that you were in on the host system. When you
run a login shell, it will try a set of fallback directories; but
when you run a command it's not possible to do that (see below).
If you're in a location present in both the chroot and on the host,
e.g. /, /usr, /tmp etc., it will work just fine. If you don't
bind mount /home and you're in /home/$user or in /srv/foobar, then
the same path won't exist in the chroot, and schroot will bail out.
The solution is to run schroot with the -d|--directory option to
explictly specify the path you want inside the chroot. In this
case, you can simply use "-d /" to run in the root.
The reason we don't implement a fallback is because it would make
the behaviour unpredictable. The exact logic is as follows:
Chdir fallback behaviour:
schroot [login shell]
CWD → CWD Normal behaviour
CWD → $HOME If CWD nonexistent and -p used
CWD → passwd pw_dir If CWD nonexistent (or -p used and no $HOME exists)
CWD → / None of the above exist
*FAIL* If / nonexistent
schroot [command]
CWD → CWD Normal behaviour
*FAIL* If CWD nonexistent
No fallbacks should exist under any circumstances.
schroot [--directory used]
CWD → DIR Normal behaviour
*FAIL* If DIR nonexistent
No fallbacks should exist under any circumstances.
dchroot [login shell or command]
CWD → passwd pw_dir Normal behaviour (not if -d used)
CWD → CWD If -d used
CWD → / If CWD nonexistent and -d used
*FAIL* If / nonexistent
dchroot [--directory used]
CWD → DIR Normal behaviour
*FAIL* If DIR nonexistent
No fallbacks should exist under any circumstances.
dchroot-dsa [login shell or command]
CWD → passwd pw_dir Normal behaviour
CWD → / If no passwd_pw dir
*FAIL* If / nonexistent
dchroot-dsa [--directory used]
CWD → DIR Normal behaviour
*FAIL* If DIR nonexistent
No fallbacks should exist under any circumstances.
Note that --debug=notice will show the internal fallback list
computed for the session.
Regards,
Roger
--
.''`. Roger Leigh
: :' : Debian GNU/Linux http://people.debian.org/~rleigh/
`. `' Printing on GNU/Linux? http://gutenprint.sourceforge.net/
`- GPG Public Key: 0x25BFB848 Please GPG sign your mail.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/buildd-tools-devel/attachments/20110712/110809ab/attachment.pgp>
More information about the Buildd-tools-devel
mailing list