summaryrefslogtreecommitdiffstats
path: root/functions
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2017-02-20 09:22:07 (GMT)
committerCyril Brulebois <kibi@debian.org>2017-03-09 22:24:37 (GMT)
commitc997b80c064c6c1d36ec69da1850722f795f43e4 (patch)
tree3d443985b6c7afa584d9200769fd36092110458b /functions
parent026923842da1815c687f1db80cba472c161119d4 (diff)
downloaddebootstrap-c997b80c064c6c1d36ec69da1850722f795f43e4.zip
debootstrap-c997b80c064c6c1d36ec69da1850722f795f43e4.tar.gz
debootstrap-c997b80c064c6c1d36ec69da1850722f795f43e4.tar.bz2
Don't make /dev/ptmx a symlink to pts/ptmx if we don't have to
In a plain chroot or on real hardware, it is preferable to use mknod to create /dev/ptmx. This works as intended with older chroot managers such as sbuild and pbuilder, which were designed for the semantics of "legacy" /dev/pts (a single non-virtualized pty subsystem per kernel) and so mount /dev/pts without the newinstance option. It also works in newer kernels where /dev/pts always behaves as though the newinstance option was given, because on those kernels, opening a (c,5,2) device node automatically looks for an adjacent pts directory and uses its ptmx device node instead. However, if we are running debootstrap inside a restricted container such as lxc or systemd-nspawn, mknod ptmx c 5 2 might not be allowed. If so, fall back to a symlink with a warning. This mode is fine if the debootstrap will be used with systemd-nspawn or lxc, or if a devtmpfs will be mounted over its /dev, but will not work for older chroot managers like sbuild or pbuilder, because those chroot managers leave the ptmxmode mount option at its default 000, causing permission to open the pts/ptmx device node to be denied. Bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=817236 Signed-off-by: Simon McVittie <smcv@debian.org>
Diffstat (limited to 'functions')
-rw-r--r--functions7
1 files changed, 6 insertions, 1 deletions
diff --git a/functions b/functions
index 6cbbd3b..4a4f2f9 100644
--- a/functions
+++ b/functions
@@ -1173,7 +1173,12 @@ setup_devices_simple () {
mknod -m 666 $TARGET/dev/urandom c 1 9
mknod -m 666 $TARGET/dev/tty c 5 0
mkdir $TARGET/dev/pts/ $TARGET/dev/shm/
- ln -s pts/ptmx $TARGET/dev/ptmx
+ # Inside a container, we might not be allowed to create /dev/ptmx.
+ # If not, do the next best thing.
+ if ! mknod -m 666 $TARGET/dev/ptmx c 5 2; then
+ warning MKNOD "Could not create /dev/ptmx, falling back to symlink. This chroot will require /dev/pts mounted with ptmxmode=666"
+ ln -s pts/ptmx $TARGET/dev/ptmx
+ fi
ln -s /proc/self/fd $TARGET/dev/fd
ln -s /proc/self/fd/0 $TARGET/dev/stdin
ln -s /proc/self/fd/1 $TARGET/dev/stdout