This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][BZ #14516] Don't make ttyname fail if procfs is unavailable


Hi,

SSH chroot using pam_chroot.so does not work when there is no
mounted /proc inside the chroot. The ssh server throws the following
error in /var/log/secure:

Aug 24 13:26:06 rawhide sshd[11735]: fatal: openpty returns device for
which ttyname fails.

while the client shows the following error and disconnects:

Connection to localhost closed by remote host.
Connection to localhost closed.

This failure occurs because sshd calls ttyname() and fails due to /proc
not being present inside the chroot by returning -1 and setting errno
to EBADF. Thanks to Masahiro Matsuya <mmatsuya@redhat.com> for
isolating the root cause of this problem.

Steps to reproduce this are mentioned in the bugzilla. Attached patch
removes the failure path and allows ttyname() to fall back to
traversing /dev/pts/ for the file descriptor if /proc is unavailable.

I have tested this on Fedora rawhide x86_64 and found no regressions
resulting from this fix.

Regards,
Siddhesh

ChangeLog:

	[BZ #14516]
	* sysdeps/unix/sysv/linux/ttyname.c (ttyname): Don't return
	failure if reading from procfs failed.
diff --git a/sysdeps/unix/sysv/linux/ttyname.c b/sysdeps/unix/sysv/linux/ttyname.c
index 3dacd40..d3070c3 100644
--- a/sysdeps/unix/sysv/linux/ttyname.c
+++ b/sysdeps/unix/sysv/linux/ttyname.c
@@ -148,12 +148,6 @@ ttyname (int fd)
     }
 
   ssize_t len = __readlink (procname, ttyname_buf, buflen);
-  if (__builtin_expect (len == -1 && errno == ENOENT, 0))
-    {
-      __set_errno (EBADF);
-      return NULL;
-    }
-
   if (__builtin_expect (len != -1, 1))
     {
       if ((size_t) len >= buflen)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]