about summary refs log tree commit diff
path: root/Makefile
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@parabola.nu>2017-11-15 20:36:44 +0100
committerChristian Brauner <christian.brauner@ubuntu.com>2017-11-15 20:47:12 +0100
commita09dfc19edcbac3f96d5410529b724db0a583879 (patch)
treebf4b8207f3ae7ae4a53802a67e092857d320b8b8 /Makefile
parent2fbce9c2031e70b6bd67876accfc34b0ec492878 (diff)
downloadglibc-a09dfc19edcbac3f96d5410529b724db0a583879.tar.gz
glibc-a09dfc19edcbac3f96d5410529b724db0a583879.tar.xz
glibc-a09dfc19edcbac3f96d5410529b724db0a583879.zip
linux ttyname{_r}: Don't bail prematurely [BZ #22145]
Commit 15e9a4f378c8607c2ae1aa465436af4321db0e23 introduced logic for ttyname()
sending back ENODEV to signal that we can't get a name for the TTY because we
inherited it from a different mount namespace.

However, just because we inherited it from a different mount namespace and it
isn't available at its original path, doesn't mean that its name is unknowable;
we can still try to find it by allowing the normal fall back on iterating
through devices.

An example scenario where this happens is with "/dev/console" in containers.
It's a common practice among container managers to allocate a PTY master/slave
pair in the host's mount namespace (the slave having a path like "/dev/pty/$X"),
bind mount the slave to "/dev/console" in the container's mount namespace, and
send the slave FD to a process in the container. Inside of the
container, the slave-end isn't available at its original path ("/dev/pts/$X"),
since the container mount namespace has a separate devpts instance from the host
(that path may or may not exist in the container; if it does exist, it's not the
 same PTY slave device). Currently ttyname{_r} sees that the file at the
original "/dev/pts/$X" path doesn't match the FD passed to it, and fails early
and gives up, even though if it kept searching it would find the TTY at
"/dev/console". Fix that; don't have the ENODEV path force an early return
inhibiting the fall-back search.

This change is based on the previous patch that adds use of is_mytty in
getttyname and getttyname_r. Without that change, this effectively reverts
15e9a4f, which made us disregard the false similarity of file pointed to by
"/proc/self/fd/$Y", because if it doesn't bail prematurely then that file
("/dev/pts/$X") will just come up again anyway in the fall-back search.

Reviewed-by: Christian Brauner <christian.brauner@ubuntu.com>
Diffstat (limited to 'Makefile')
0 files changed, 0 insertions, 0 deletions