Package: debianutils
Version: 4.3.2
Severity: normal

When I create a chroot the ischroot command fails to detect it and
returns an error code.  It is good to return an error but since the
purpose of ischroot is to detect if it is running in a chroot the
result is not useful.

To recreate the problem I recommend a throwaway VM instance because
the result is a slightly broken system due to an initscripts bug.

* Create a Squeeze chroot.

  # mkdir /srv/chroot
  # cd /srv/chroot
  # debootstrap squeeze squeeze-test http://ftp.us.debian.org/debian

* Configure policy-rc.d to avoid starting any daemons in the chroot.

  # cd squeeze-test
  # printf '#!/bin/sh\nexit 101\n' > ./usr/sbin/policy-rc.d
  # chmod a+x ./usr/sbin/policy-rc.d

* Ensure that it is up to date.

  # chroot $PWD su -
  # apt-get update
  # apt-get upgrade

* Upgrade it to Wheezy.

  # sed --in-place s/squeeze/wheezy/g /etc/apt/sources.list
  # apt-get update
  # apt-get upgrade
  # apt-get dist-upgrade

At this point the system has two problems.  One of them is that
'ischroot' cannot determine that it is in a chroot.

  # ischroot ; echo $?
  2

As to how to fix this I have no good ideas.  I did not look at the
ischroot source and do not know what method it uses.  I am only
chasing this due to the problem with the initscripts process for /run
migration and this is the earliest problem that I found.  (Hint to
others: To avoid the initscripts problem replace ischroot with
/bin/true between the upgrade and dist-upgrade steps.)

I can only think of using the inode of the root filesystem for
detection.

In the chroot:

  # ls -ldogi /
  126483 drwxr-xr-x 22 4096 Aug 15 23:30 /
  ^^^^^^-- inode number is not 2

On the host system outside any chroot:

  # ls -ldogi /
  2 drwxr-xr-x 21 4096 Aug 15 07:02 /
  ^-- inode number is usually 2

Outside the chroot the inode of the root filesystem is usually 2 for
traditional Unix filesystems and for ext2, ext3, ext4.  But I do not
know about others.

Thanks,
Bob


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to