1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-05-28 16:21:30 +03:00
Luke Shumaker a09dfc19ed
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>
2017-11-15 20:47:12 +01:00
..
2017-11-09 05:10:03 -08:00
2017-11-09 05:10:03 -08:00
2017-11-09 05:10:03 -08:00
2017-11-09 05:10:03 -08:00
2017-11-09 05:10:03 -08:00
2017-11-09 05:10:03 -08:00
2017-11-09 05:10:03 -08:00
2017-11-09 05:10:03 -08:00
2017-11-09 05:10:03 -08:00
2017-11-09 05:10:03 -08:00
2017-11-09 05:10:03 -08:00
2017-11-09 05:10:03 -08:00
2017-11-09 05:10:03 -08:00
2017-11-09 05:10:03 -08:00
2017-11-09 05:10:03 -08:00
2017-08-18 18:38:55 -03:00
2017-05-11 17:27:27 -03:00
2017-08-31 16:10:34 -03:00
2017-05-18 18:06:47 -03:00
2017-05-18 18:06:47 -03:00
2017-08-31 16:10:34 -03:00
2017-08-17 16:50:35 -03:00
2017-08-17 16:50:35 -03:00
2017-08-22 14:25:03 -03:00
2017-05-03 10:36:01 -03:00
2017-05-09 14:05:09 +00:00
2017-08-18 10:31:16 -03:00
2017-10-01 15:54:10 -07:00
2017-03-09 15:22:06 +01:00
2017-03-09 15:22:06 +01:00
2017-03-28 12:29:27 -03:00
2017-03-28 12:29:27 -03:00
2017-03-09 15:22:06 +01:00
2017-08-18 10:53:47 -03:00
2017-10-01 15:54:10 -07:00