After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 670758 - Add support for allocating BSD PTYs through openpty(3)
Add support for allocating BSD PTYs through openpty(3)
Status: RESOLVED FIXED
Product: vte
Classification: Core
Component: general
0.30.x
Other OpenBSD
: Normal normal
: ---
Assigned To: VTE Maintainers
VTE Maintainers
[fixed-next]
Depends on:
Blocks:
 
 
Reported: 2012-02-24 17:49 UTC by Martin Pieuchot
Modified: 2015-12-15 13:15 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Diff against vte-0.30 implementing the openpty "backend" (5.21 KB, patch)
2012-02-24 17:49 UTC, Martin Pieuchot
none Details | Review
implement a backend for openpty() (5.21 KB, patch)
2012-03-06 10:59 UTC, Antoine Jacoutot
none Details | Review
openpty backend without configure switch (4.87 KB, patch)
2012-03-08 16:51 UTC, Martin Pieuchot
none Details | Review

Description Martin Pieuchot 2012-02-24 17:49:54 UTC
Created attachment 208368 [details] [review]
Diff against vte-0.30 implementing the openpty "backend"

The diff attached allow systems like OpenBSD, that does not implement the Unix98 PTY family of functions, to allocate pseudo-tty using the openpty(3) BSD function instead of relying on the gnome-pty-helper.

For the moment, to use the openpty "backend" instead of the getpt/ptsname/grantpt/unlock one, the packager should specify the '--enable-bsd-pty' option at configure time.
Comment 1 Antoine Jacoutot 2012-02-24 18:17:25 UTC
This patch has been committed to the OpenBSD ports tree and the vte package will use bsd-pty by default now.
I'm been running with it for several days, it works great and allows us to get rid of the pty-helper.
Comment 2 Antoine Jacoutot 2012-03-06 10:55:43 UTC
Can anyone review this please.
I would like to push it since it's a great improvement for us not having to rely on the pty-helper.

Thanks.
Comment 3 Antoine Jacoutot 2012-03-06 10:59:03 UTC
Created attachment 209061 [details] [review]
implement a backend for openpty()

Amended from op's patch to fix indent.
Comment 4 Christian Persch 2012-03-06 16:31:40 UTC
I don't like the configure switch to enable this. Instead, the code should be structured so that openpty is used if _vte_pty_getpt will always return -1 (that is, neither HAVE_PTSNAME_R, HAVE_PTSNAME nor TIOCGPTN are defined, but HAVE_OPENPTY is defined.

Does openpty do all the stuff with the slave fd that _vte_pty_open_unix98() does manually? Or is that not relevant for bsd?
Comment 5 Martin Pieuchot 2012-03-08 16:51:47 UTC
Created attachment 209262 [details] [review]
openpty backend without configure switch

(In reply to comment #4)
> I don't like the configure switch to enable this. Instead, the code should be
> structured so that openpty is used if _vte_pty_getpt will always return -1
> (that is, neither HAVE_PTSNAME_R, HAVE_PTSNAME nor TIOCGPTN are defined, but
> HAVE_OPENPTY is defined.

New diff attached doing this.

> Does openpty do all the stuff with the slave fd that _vte_pty_open_unix98()
> does manually? Or is that not relevant for bsd?

Yes it does, here's an extract from its man page:

     The openpty() function works in the following way: first it attempts to
     allocate the pseudo-tty through the /dev/ptm device (see pty(4) for
     details) and if that fails it searches for a free pseudo-tty by iterating
     through all existing pseudo-tty devices in /dev.  When a free pseudo-tty
     is found, its ownership is changed to the UID of the caller, permissions
     are set to correct values, and all earlier uses of that device are
     revoked (see revoke(2) for details).

Is it OK like this, or am I missing something else?
Comment 6 Christian Persch 2012-03-08 21:01:23 UTC
That should cover it, thanks! I modified the patch a bit an pushed to vte-0-32; can you check that I didn't break it :-)
Comment 7 Antoine Jacoutot 2012-03-09 06:43:40 UTC
Nothing broke, works just fine here. Thanks ;)
Comment 8 Christian Persch 2015-12-12 16:45:16 UTC
According to bug 759346 comment 0, openbsd now has posix_openpt [http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man3/posix_openpt.3]. So is the openpty() code path still necessary, or can it be removed and *BSD use the posix_openpt code path like linux?
Comment 9 Martin Pieuchot 2015-12-15 13:15:53 UTC
FWIW libvte now uses posix_openpt() on OpenBSD so I'd guess that removing the openpty() backend won't hurt anyone.

Here's what I get on a -current system:
$ nm /usr/local/lib/libvte.so.14.1 |grep openpt
         U posix_openpt