This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH][BZ #14516] Don't make ttyname fail if procfs is unavailable
- From: Carlos O'Donell <carlos_odonell at mentor dot com>
- To: Siddhesh Poyarekar <siddhesh at redhat dot com>
- Cc: <libc-alpha at sourceware dot org>, Masahiro Matsuya <mmatsuya at redhat dot com>
- Date: Fri, 24 Aug 2012 09:10:11 -0400
- Subject: Re: [PATCH][BZ #14516] Don't make ttyname fail if procfs is unavailable
- References: <20120824145037.4611785a@spoyarek>
On 8/24/2012 5:20 AM, Siddhesh Poyarekar wrote:
> 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.
>
This looks good to me.
I see no reason why we should fail if we fail to open /proc.
This is a change in behaviour though and you should write a NEWS
entry for this e.g.
~~~
Use of ttyname now falls back on /dev/pts if /proc is unreadable;
this facilitates using chroots without /proc.
~~~
Cheers,
Carlos.
--
Carlos O'Donell
Mentor Graphics / CodeSourcery
carlos_odonell@mentor.com
carlos@codesourcery.com
+1 (613) 963 1026