openpty: use TIOCGPTPEER to open slave side fd
authorChristian Brauner <christian.brauner@ubuntu.com>
Sun, 8 Oct 2017 12:10:46 +0000 (14:10 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sun, 8 Oct 2017 15:47:58 +0000 (17:47 +0200)
commit645ac9aaf89e3311949828546df6334322f48933
treec3fcdd65127627d5f889060c145f238d953e2b1f
parent98e0742024d4c13c08a6076b3d119c250e7d0118
openpty: use TIOCGPTPEER to open slave side fd

Newer kernels expose the ioctl TIOCGPTPEER [1] call to userspace which allows to
safely allocate a file descriptor for a pty slave based solely on the master
file descriptor. This allows us to avoid path-based operations and makes this
function a lot safer in the face of devpts mounts in different mount namespaces.

[1]: https://patchwork.kernel.org/patch/9760743/

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
ChangeLog
login/openpty.c