[Piuparts-devel] [Git][debian/piuparts][ptmx] Create /dev/ptmx like debootstrap does (Closes: #911334)

Mathieu Parent gitlab at salsa.debian.org
Thu Oct 18 20:29:29 BST 2018


Mathieu Parent pushed to branch ptmx at Debian / piuparts


Commits:
bd7d6fb7 by Mathieu Parent at 2018-10-18T19:29:09Z
Create /dev/ptmx like debootstrap does (Closes: #911334)

When using piuparts on a chroot without /dev/ptmx [noptmx],
scripts/pre_remove_50_find_bad_permissions fails with:

    ERROR: BAD PERMISSIONS
    crw-rw-rw-. 1 root root 5, 2 Oct 16 03:49 /dev/ptmx

In this case, piuparts does something like this:

    touch /dev/ptmx
    mount -o bind /dev/pts/ptmx /dev/ptmx

The kernel doc [devpts.txt] recommends instead:

    mknod /dev/ptmx c 5 2

And this is what debootstrap does [debootstrap].

This change maps the piuparts behavior with debootstrap's.

[noptmx]: This is the case when chroot comes from the debian:unstable Docker image
[devpts.txt]: https://www.kernel.org/doc/Documentation/filesystems/devpts.txt
[debootstrap] https://salsa.debian.org/installer-team/debootstrap/blob/6f3f6f8b76e2d1a24ddbf05f065439412c3b81a1/functions#L1263-1268, introduced by https://salsa.debian.org/installer-team/debootstrap/commit/c997b80c064c6c1d36ec69da1850722f795f43e4

- - - - -


2 changed files:

- debian/changelog
- piuparts.py


Changes:

=====================================
debian/changelog
=====================================
@@ -46,6 +46,14 @@ piuparts (0.93) UNRELEASED; urgency=medium
   * htdocs/bug_howto.tpl: some improvements, it's been some years.
   * htdocs/news.tpl: confirm #582630 has been fixed.
 
+  [ Mathieu Parent ]
+  * Create /dev/ptmx like debootstrap does (Closes: #911334): When the chroot is
+    created from the Docker image debian:unstable, /dev/ptmx is missing.
+    Piuparts was creating it with a bindmount to ptx/ptmx which leads
+    scripts/pre_remove_50_find_bad_permissions to complain about
+    "BAD PERMISSIONS" on /dev/ptmx. Now created with mknod, failing back to a
+    symlink
+
  -- Holger Levsen <holger at debian.org>  Sat, 22 Sep 2018 15:32:55 +0200
 
 piuparts (0.92) unstable; urgency=medium


=====================================
piuparts.py
=====================================
@@ -1755,11 +1755,13 @@ class Chroot:
             os.symlink("../proc/mounts", etcmtab)
         self.mount("devpts", "/dev/pts", fstype="devpts", opts="newinstance,noexec,nosuid,gid=5,mode=0620,ptmxmode=0666")
         dev_ptmx_rel_path = self.relative("dev/ptmx")
-        if not os.path.islink(dev_ptmx_rel_path):
-            if not os.path.exists(dev_ptmx_rel_path):
-                with open(dev_ptmx_rel_path, 'w'):
-                    pass
-            self.mount(self.relative("dev/pts/ptmx"), "/dev/ptmx", opts="bind", no_mkdir=True)
+        if not os.path.exists(dev_ptmx_rel_path):
+            try:
+                os.mknod(dev_ptmx_rel_path, 0666 | stat.S_IFCHR, os.makedev(5, 2))
+            except:
+                logging.error(
+                    'WARN: Could not create /dev/ptmx, falling back to symlink. This chroot will require /dev/pts mounted with ptmxmode=666')
+                os.symlink("pts/ptmx", dev_ptmx_rel_path)
         p = subprocess.Popen(["tty"], stdout=subprocess.PIPE)
         stdout, _ = p.communicate()
         current_tty = stdout.strip()



View it on GitLab: https://salsa.debian.org/debian/piuparts/commit/bd7d6fb7bef3b03ce3e6e609805d1a03bf92b6cf

-- 
View it on GitLab: https://salsa.debian.org/debian/piuparts/commit/bd7d6fb7bef3b03ce3e6e609805d1a03bf92b6cf
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/piuparts-devel/attachments/20181018/2c3c797e/attachment-0001.html>


More information about the Piuparts-devel mailing list