[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] pty/tty functions for BSD too
From: |
Blue Swirl |
Subject: |
Re: [Qemu-devel] pty/tty functions for BSD too |
Date: |
Mon, 18 Aug 2008 21:08:50 +0300 |
On 8/18/08, Blue Swirl <address@hidden> wrote:
> On 8/18/08, Daniel P. Berrange <address@hidden> wrote:
> > On Mon, Aug 18, 2008 at 07:16:36PM +0300, Blue Swirl wrote:
> > > On 8/18/08, Samuel Thibault <address@hidden> wrote:
> > > > Anthony Liguori, le Mon 18 Aug 2008 09:06:41 -0500, a écrit :
> > > >
> > > > > Samuel Thibault wrote:
> > > > > >In Xen, pty/tty functions are enabled for BSD too, shouldn't we
> enable
> > > > > >them in upstream qemu too, as patched below?
> > > > > >
> > > > >
> > > > > And you're sure that these functions compile/work on
> NetBSD/OpenBSD?
> > > >
> > > >
> > > > The defines are explicit in Xen, so I guess somebody tested it. I
> > > > haven't myself. I wonder why there is no FreeBSD however.
> > >
> > > The patch does not work on OpenBSD, because while openpty() is
> > > available, ptsname() isn't.
> > >
> > > I tested the attached version on OpenBSD and Linux, pty name is
> > > printed correctly.
> >
> >
> > Passing a non-NULL value to openpty()'s name parameter is not safe
> >
> > [quote openpty(1)]
> > BUGS
> > Nobody knows how much space should be reserved for name. So, call-
> > ing openpty() or forkpty() with non-NULL name may not be secure.
> > [/quote]
>
>
> Maybe in theory, but in practice the name will be
> /dev/pty[0-9a-z][a-z] or /dev/pts/[0-9]* or something similar. Even if
> they are not, PATH_MAX should be enough.
>
>
> > If BSD has no other way to determine the PTY name, then at least it
> > should be conditionalized so that systems with ptsname() use it, only
> > falling back to using the 'name' arg to openpty() for OS lacking ptsname
>
>
> I'm not convinced (yet?) this will be worth it.
Glibc uses an internal PATH_MAX buffer. If the name does not fit, the
buffer will be doubled in size:
http://sourceware.org/cgi-bin/cvsweb.cgi/libc/login/openpty.c?rev=1.8&content-type=text/x-cvsweb-markup&cvsroot=glibc
But in practice the pty will be allocated using getpt(), which uses
hard coded ptmx name:
http://sourceware.org/cgi-bin/cvsweb.cgi/libc/sysdeps/unix/sysv/linux/getpt.c?rev=1.10&content-type=text/x-cvsweb-markup&cvsroot=glibc
And ptsname() is used to get the pty name, which uses either hard
coded buffer length of _PATH_DEVPTS or _PATH_TTY:
http://sourceware.org/cgi-bin/cvsweb.cgi/libc/sysdeps/unix/sysv/linux/ptsname.c?rev=1.15&content-type=text/x-cvsweb-markup&cvsroot=glibc
OpenBSD forces the name to be in format "/dev/ptyXX":
http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libutil/pty.c?rev=1.15&content-type=text/x-cvsweb-markup
NetBSD is similar, except also /dev/ttyXX is possible:
http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libutil/pty.c?rev=1.29&content-type=text/x-cvsweb-markup
I still maintain that in reality, PATH_MAX should be enough.
- [Qemu-devel] pty/tty functions for BSD too, Samuel Thibault, 2008/08/18
- Re: [Qemu-devel] pty/tty functions for BSD too, Anthony Liguori, 2008/08/18
- Re: [Qemu-devel] pty/tty functions for BSD too, Samuel Thibault, 2008/08/18
- Re: [Qemu-devel] pty/tty functions for BSD too, Blue Swirl, 2008/08/18
- Re: [Qemu-devel] pty/tty functions for BSD too, Daniel P. Berrange, 2008/08/18
- Re: [Qemu-devel] pty/tty functions for BSD too, Blue Swirl, 2008/08/18
- Re: [Qemu-devel] pty/tty functions for BSD too,
Blue Swirl <=
- Re: [Qemu-devel] pty/tty functions for BSD too, Daniel P. Berrange, 2008/08/18
- Re: [Qemu-devel] pty/tty functions for BSD too, Jamie Lokier, 2008/08/18
- Re: [Qemu-devel] pty/tty functions for BSD too, Bernhard Reutner-Fischer, 2008/08/19
- Re: [Qemu-devel] pty/tty functions for BSD too, François Revol, 2008/08/19
- Re: [Qemu-devel] pty/tty functions for BSD too, Bernhard Reutner-Fischer, 2008/08/19
- Re: [Qemu-devel] pty/tty functions for BSD too, Samuel Thibault, 2008/08/19
- Re: [Qemu-devel] pty/tty functions for BSD too, Klaus Heinz, 2008/08/19
- Re: [Qemu-devel] pty/tty functions for BSD too, Blue Swirl, 2008/08/21
- Re: [Qemu-devel] pty/tty functions for BSD too, Todd T. Fries, 2008/08/19