From: "Daniel P. Berrange" <berrange@redhat.com>
To: Blue Swirl <blauwirbel@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] pty/tty functions for BSD too
Date: Mon, 18 Aug 2008 19:20:29 +0100 [thread overview]
Message-ID: <20080818182029.GA9392@redhat.com> (raw)
In-Reply-To: <f43fc5580808181108w4c7822b0k3817266413218419@mail.gmail.com>
On Mon, Aug 18, 2008 at 09:08:50PM +0300, Blue Swirl wrote:
> On 8/18/08, Blue Swirl <blauwirbel@gmail.com> wrote:
> > On 8/18/08, Daniel P. Berrange <berrange@redhat.com> wrote:
> > >
> > > [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.
Ok, I guess its safe enough in practice then.
Regards,
Daniel
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
next prev parent reply other threads:[~2008-08-18 18:20 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-18 10:59 [Qemu-devel] pty/tty functions for BSD too Samuel Thibault
2008-08-18 14:06 ` Anthony Liguori
2008-08-18 14:23 ` Samuel Thibault
2008-08-18 15:12 ` Warner Losh
2008-08-18 17:18 ` Anthony Liguori
2008-08-18 16:16 ` Blue Swirl
2008-08-18 16:26 ` Daniel P. Berrange
2008-08-18 16:57 ` Blue Swirl
2008-08-18 18:08 ` Blue Swirl
2008-08-18 18:20 ` Daniel P. Berrange [this message]
2008-08-18 19:42 ` Jamie Lokier
2008-08-19 10:33 ` Bernhard Reutner-Fischer
2008-08-19 11:21 ` François Revol
2008-08-19 11:40 ` Bernhard Reutner-Fischer
2008-08-19 12:55 ` Samuel Thibault
2008-08-19 19:17 ` Klaus Heinz
2008-08-21 18:16 ` Blue Swirl
2008-08-19 12:35 ` Todd T. Fries
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080818182029.GA9392@redhat.com \
--to=berrange@redhat.com \
--cc=blauwirbel@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.