Hi Andreas,

Le mer. 24 oct. 2018 à 10:29, Andreas Beckmann <a...@debian.org> a écrit :
>
> So the underlying problem is
>
> # mkdir foo
> # touch foo/file
> # mknod foo/null c 1 3
> # touch foo/bindmntoverfile
> # mount --bind foo/null foo/bindmntoverfile
> # ls -lis foo
> total 0
> 3857271640 0 crw-r--r-- 1 root root 1, 3 Oct 24 07:50 bindmntoverfile
> 3857120264 0 -rw-r--r-- 1 root root    0 Oct 24 07:49 file
> 3857271640 0 crw-r--r-- 1 root root 1, 3 Oct 24 07:50 null
> # find foo -type f -ls
> 3857271640      0 crw-r--r--   1 root     root       1,   3 Oct 24 07:50 
> foo/bindmntoverfile
> 3857120264      0 -rw-r--r--   1 root     root            0 Oct 24 07:49 
> foo/file
>
> please find/file a bug against findutils
>
> and the commit message should not mention debootstrap but
> something like
> """
> p: use mknod instead of touch to create missing /dev/ptmx mountpoint
>
> working around findutils bug #xxxxxx
>
> mkdir foo
> mknod foo/null c 1 3
> touch foo/bindmntoverfile
> mount --bind foo/null foo/bindmntoverfile
> find foo -type f -ls
> 3857271640      0 crw-r--r--   1 root     root       1,   3 Oct 24 07:50 
> foo/bindmntoverfile
> """

Thanks. I've done the findutils bug (#912180, with even a patch) and
I've updated the MR (see also the attached patch).

If the commit message is too verbose, you can amend it.

Regards
-- 
Mathieu Parent
From a99ecade05aeb855c5e17528403956300ee280c7 Mon Sep 17 00:00:00 2001
From: Mathieu Parent <sath...@debian.org>
Date: Wed, 17 Oct 2018 04:49:18 +0000
Subject: [PATCH] p: use mknod instead of touch to create missing /dev/ptmx
 mountpoint (Closes: #911334)

Working around findutils bug #912180:

    mkdir foo
    mknod foo/null c 1 3
    touch foo/bindmntoverfile
    mount --bind foo/null foo/bindmntoverfile
    find foo -type f -ls
    3857271640      0 crw-r--r--   1 root     root       1,   3 Oct 24 07:50 foo/bindmntoverfile

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 # if not exists
    mount -o bind /dev/pts/ptmx /dev/ptmx # if dev/ptmx was not a symlink

The kernel doc [devpts.txt] recommends instead:

    mknod /dev/ptmx c 5 2

And this is what debootstrap does [debootstrap].

After this change, piuparts will do:

    mknod /dev/ptmx c 5 2 # if not exists
    mount -o bind /dev/pts/ptmx /dev/ptmx # if dev/ptmx was not a symlink

The behavior of piuparts called after debootstrap will not change.
The only behavior changing is when dev/ptmx doesn't exist at all.

[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
---
 debian/changelog | 4 ++++
 piuparts.py      | 3 +--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 308905e4..1d174cd5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -14,6 +14,10 @@ piuparts (0.94) UNRELEASED; urgency=medium
     - Handle /etc/nsswitch.conf stretch -> buster upgrade if modifications
       from libnss-myhostname and friends are present.
 
+  [ Mathieu Parent ]
+  * piuparts.py: Use mknod instead of touch to create missing /dev/ptmx
+    mountpoint, working around findutils bug #912180 (Closes: #911334)
+
  -- Holger Levsen <hol...@debian.org>  Sun, 21 Oct 2018 14:03:22 +0200
 
 piuparts (0.93) unstable; urgency=medium
diff --git a/piuparts.py b/piuparts.py
index a6279e4e..a8400fb6 100644
--- a/piuparts.py
+++ b/piuparts.py
@@ -1755,8 +1755,7 @@ class Chroot:
         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
+                os.mknod(dev_ptmx_rel_path, 0666 | stat.S_IFCHR, os.makedev(5, 2))
             self.mount(self.relative("dev/pts/ptmx"), "/dev/ptmx", opts="bind", no_mkdir=True)
         p = subprocess.Popen(["tty"], stdout=subprocess.PIPE)
         stdout, _ = p.communicate()
-- 
2.11.0

Reply via email to