Make use of openpty(3) to allocate a pseudo-tty instead of the

gnome-pty-helper.

ok ajacoutot@, landry@
This commit is contained in:
mpi 2012-02-24 10:44:55 +00:00
parent e6b6e3aaee
commit 60973badf6
10 changed files with 285 additions and 156 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.95 2012/02/06 22:07:09 espie Exp $
# $OpenBSD: Makefile,v 1.96 2012/02/24 10:44:55 mpi Exp $
# Don't pull in x11/py-gtk2 on these archs; build fails with binutils 2.15
NOT_FOR_ARCHS-python= mips64 mips64el
@ -14,7 +14,7 @@ SHARED_LIBS+= vte 14.1 # 2609.0
FULLPKGNAME-main= vte-${GNOME_VERSION}
FULLPKGNAME-python= py-${DISTNAME}
REVISION-main = 5
REVISION-main = 6
REVISION-python = 3
CATEGORIES= devel
@ -39,7 +39,7 @@ WANTLIB += Xi Xinerama Xrandr Xrender Xxf86vm atk-1.0 cairo drm
WANTLIB += expat ffi fontconfig freetype gdk_pixbuf-2.0 gio-2.0
WANTLIB += glib-2.0 gmodule-2.0 gobject-2.0 gthread-2.0 m ncurses
WANTLIB += pango-1.0 pangocairo-1.0 pangoft2-1.0 pcre pixman-1
WANTLIB += png pthread-stubs xcb xcb-render xcb-shm z
WANTLIB += png pthread-stubs stdc++ util xcb xcb-render xcb-shm z
MODPY_RUNDEP= No
@ -63,8 +63,13 @@ CONFIGURE_ARGS+= --enable-python
MODGNOME_TOOLS= goi
CONFIGURE_STYLE= gnu
AUTOCONF_VERSION= 2.68
AUTOMAKE_VERSION= 1.11
CONFIGURE_STYLE= autoconf
CONFIGURE_ARGS+= --disable-Bsymbolic \
--disable-gnome-pty-helper \
--enable-bsd-pty \
--with-gtk=2.0 \
--program-suffix=2

View File

@ -0,0 +1,51 @@
$OpenBSD: patch-configure_in,v 1.1 2012/02/24 10:44:55 mpi Exp $
Support for the openpty(3) backend.
--- configure.in
+++ configure.in
@@ -313,7 +313,7 @@ AC_SUBST(VTE_DEFAULT_EMULATION)
AM_CONDITIONAL(VTE_DEFAULT_EMULATION, [test "$emulation" != xterm])
# Check for headers.
-AC_CHECK_HEADERS(sys/select.h sys/syslimits.h sys/termios.h sys/un.h sys/wait.h stropts.h termios.h wchar.h)
+AC_CHECK_HEADERS(sys/select.h sys/syslimits.h sys/termios.h sys/un.h sys/wait.h stropts.h termios.h util.h wchar.h)
AC_HEADER_TIOCGWINSZ
# Check for PTY handling functions.
@@ -324,6 +324,7 @@ AC_CHECK_FUNCS([cfmakeraw fork setsid setpgid getpgid getpt grantpt unlockpt pts
AC_CHECK_FUNC(socket,[have_socket=1],AC_CHECK_LIB(socket,socket,[have_socket=1; LIBS="$LIBS -lsocket"]))
AC_CHECK_FUNC(socketpair,[have_socketpair=1],AC_CHECK_LIB(socket,socketpair,[have_socketpair=1; LIBS="$LIBS -lsocket"]))
AC_CHECK_FUNC(recvmsg,[have_recvmsg=1],AC_CHECK_LIB(socket,recvmsg,[have_recvmsg=1; LIBS="$LIBS -lsocket -lnsl"]))
+AC_CHECK_FUNC(openpty,[have_openpty=1],AC_CHECK_LIB(util,openpty,[have_openpty=1; LIBS="$LIBS -lutil"]))
if test x$have_socket = x1 ; then
AC_DEFINE(HAVE_SOCKET,1,[Define if you have the socket function.])
fi
@@ -333,6 +334,9 @@ fi
if test x$have_recvmsg = x1 ; then
AC_DEFINE(HAVE_RECVMSG,1,[Define if you have the recvmsg function.])
fi
+if test x$have_openpty = x1 ; then
+ AC_DEFINE(HAVE_OPENPTY,1,[Define if you have the openpty function.])
+fi
AC_CHECK_FUNC(floor,,AC_CHECK_LIB(m,floor,LIBS=["$LIBS -lm"]))
AC_CHECK_FUNCS([ceil floor])
@@ -423,6 +427,17 @@ fi
AM_CONDITIONAL(BUILD_GNOME_PTY_HELPER,[test "$enable_gnome_pty_helper" != no])
################################################################################
+# BSD PTY
+################################################################################
+
+AC_ARG_ENABLE(bsd-pty, [AS_HELP_STRING(--enable-bsd-pty,Support bsd rather than unix98 ptys [default=no])], enable_bsd_pty="$enableval", enable_bsd_pty=yes)
+if test "$enable_bsd_pty" != no; then
+ AC_DEFINE(VTE_USE_BSD_PTY,1,[Define if you intend to use bsd-pty.])
+ AC_CONFIG_SUBDIRS(bsd-pty)
+fi
+AM_CONDITIONAL(BUILD_BSD_PTY,[test "$enable_bsd_pty" != no])
+
+################################################################################
# Glade catalogue
################################################################################

View File

@ -1,16 +0,0 @@
$OpenBSD: patch-gnome-pty-helper_Makefile_in,v 1.6 2011/09/26 14:25:09 jasper Exp $
Don't bother calling install-exec-hook. We already adjust
permissions in PLIST.
--- gnome-pty-helper/Makefile.in.orig Mon Sep 26 15:48:00 2011
+++ gnome-pty-helper/Makefile.in Mon Sep 26 15:49:08 2011
@@ -580,7 +580,7 @@ install-dvi-am:
install-exec-am: install-libexecPROGRAMS
@$(NORMAL_INSTALL)
- $(MAKE) $(AM_MAKEFLAGS) install-exec-hook
+ $(MAKE) $(AM_MAKEFLAGS)
install-html: install-html-am
install-html-am:

View File

@ -1,94 +1,90 @@
$OpenBSD: patch-src_pty_c,v 1.9 2011/09/26 14:25:09 jasper Exp $
$OpenBSD: patch-src_pty_c,v 1.10 2012/02/24 10:44:55 mpi Exp $
- Party revert to previous behaviour of returning -1, instead of failing
to compile.
Use openpty(3) backend instead of gnome-pty-helper
- Adjust gnome-pty-helper2 binary name.
--- src/pty.c.orig Tue Aug 16 23:52:48 2011
+++ src/pty.c Mon Sep 26 15:44:22 2011
@@ -795,7 +795,8 @@ _vte_pty_ptsname(int master,
"%s failed: %s", "ioctl(TIOCGPTN)", g_strerror(errno));
return NULL;
#else
-#error no ptsname implementation for this platform
+#warning no ptsname implementation for this platform
+ return NULL;
--- src/pty.c
+++ src/pty.c
@@ -54,6 +54,9 @@
#include <termios.h>
#endif
}
@@ -903,7 +904,8 @@ _vte_pty_unlockpt(int fd,
}
return TRUE;
#else
-#error no unlockpt implementation for this platform
+#warning no unlockpt implementation for this platform
+ return -1;
#include <unistd.h>
+#ifdef HAVE_UTIL_H
+#include <util.h>
+#endif
#ifdef HAVE_STROPTS_H
#include <stropts.h>
#endif
}
@@ -1181,8 +1183,8 @@ _vte_pty_start_helper(GError **error)
close(tunnel);
close(_vte_pty_helper_tunnel);
/* Exec our helper. */
- execl(LIBEXECDIR "/gnome-pty-helper",
- "gnome-pty-helper", NULL);
+ execl(LIBEXECDIR "/gnome-pty-helper2",
+ "gnome-pty-helper2", NULL);
/* Bail. */
_exit(1);
@@ -734,6 +737,7 @@ vte_pty_get_size(VtePty *pty,
}
@@ -1197,7 +1199,7 @@ failure:
}
g_set_error(error, VTE_PTY_ERROR,
VTE_PTY_ERROR_PTY_HELPER_FAILED,
- "Failed to start gnome-pty-helper: %s",
+ "Failed to start gnome-pty-helper2: %s",
g_strerror (errsv));
+#ifndef VTE_USE_BSD_PTY
/*
* _vte_pty_ptsname:
* @master: file descriptor to the PTY master
@@ -951,6 +955,44 @@ _vte_pty_open_unix98(VtePty *pty,
return TRUE;
}
if (tmp[0] != -1)
@@ -1285,7 +1287,7 @@ _vte_pty_open_with_helper(VtePty *pty,
&ops, sizeof(ops)) != sizeof(ops)) {
g_set_error (error, VTE_PTY_ERROR,
VTE_PTY_ERROR_PTY_HELPER_FAILED,
- "Failed to send request to gnome-pty-helper: %s",
+ "Failed to send request to gnome-pty-helper2: %s",
g_strerror(errno));
return FALSE;
}
@@ -1295,7 +1297,7 @@ _vte_pty_open_with_helper(VtePty *pty,
&ret, sizeof(ret)) != sizeof(ret)) {
g_set_error (error, VTE_PTY_ERROR,
VTE_PTY_ERROR_PTY_HELPER_FAILED,
- "Failed to read response from gnome-pty-helper: %s",
+ "Failed to read response from gnome-pty-helper2: %s",
g_strerror(errno));
return FALSE;
}
@@ -1304,7 +1306,7 @@ _vte_pty_open_with_helper(VtePty *pty,
if (ret == 0) {
g_set_error_literal (error, VTE_PTY_ERROR,
VTE_PTY_ERROR_PTY_HELPER_FAILED,
- "gnome-pty-helper failed to open pty");
+ "gnome-pty-helper2 failed to open pty");
return FALSE;
}
_vte_debug_print(VTE_DEBUG_PTY, "Helper returns success.\n");
@@ -1313,7 +1315,7 @@ _vte_pty_open_with_helper(VtePty *pty,
&tag, sizeof(tag)) != sizeof(tag)) {
g_set_error (error, VTE_PTY_ERROR,
VTE_PTY_ERROR_PTY_HELPER_FAILED,
- "Failed to read tag from gnome-pty-helper: %s",
+ "Failed to read tag from gnome-pty-helper2: %s",
g_strerror(errno));
return FALSE;
}
@@ -1330,7 +1332,7 @@ _vte_pty_open_with_helper(VtePty *pty,
+#else
+/*
+ * _vte_pty_open_bsd:
+ * @pty: a #VtePty
+ * @error: a location to store a #GError, or %NULL
+ *
+ * Opens new file descriptors to a new PTY master and slave.
+ *
+ * Returns: %TRUE on success, %FALSE on failure with @error filled in
+ */
+static gboolean
+_vte_pty_open_bsd(VtePty *pty,
+ GError **error)
+{
+#ifdef HAVE_OPENPTY
+ VtePtyPrivate *priv = pty->priv;
+ int parentfd, childfd;
+
+ if (openpty(&parentfd, &childfd, NULL, NULL, NULL) != 0) {
+ int errsv = errno;
+ g_set_error(error, VTE_PTY_ERROR, VTE_PTY_ERROR_PTY98_FAILED,
+ "%s failed: %s", "openpty", g_strerror(errsv));
+ errno = errsv;
+ return FALSE;
+ }
+
+ priv->pty_fd = parentfd;
+ priv->child_setup_data.mode = TTY_OPEN_BY_FD;
+ priv->child_setup_data.tty.fd = childfd;
+ priv->using_helper = FALSE;
+
+ return TRUE;
+#else
+#error no openpty implementation for this platform
+#endif
+}
+#endif /* VTE_USE_BSD_PTY */
+
#ifdef VTE_USE_GNOME_PTY_HELPER
#ifdef HAVE_RECVMSG
static void
@@ -1511,7 +1553,7 @@ vte_pty_initable_init (GInitable *initable,
}
g_set_error (error, VTE_PTY_ERROR,
VTE_PTY_ERROR_PTY_HELPER_FAILED,
- "Failed to read master or slave pty from gnome-pty-helper: %s",
+ "Failed to read master or slave pty from gnome-pty-helper2: %s",
g_strerror(errsv));
errno = errsv;
return FALSE;
g_error_free(err);
- /* Fall back to unix98 PTY */
+ /* Fall back to unix98 or bsd PTY */
}
#else
if (priv->flags & VTE_PTY_NO_FALLBACK) {
@@ -1521,7 +1563,11 @@ vte_pty_initable_init (GInitable *initable,
}
#endif /* VTE_USE_GNOME_PTY_HELPER */
+#ifndef VTE_USE_BSD_PTY
ret = _vte_pty_open_unix98(pty, error);
+#else
+ ret = _vte_pty_open_bsd(pty, error);
+#endif /* VTE_USE_BSD_PTY */
out:
_vte_debug_print(VTE_DEBUG_PTY,

View File

@ -1,4 +1,4 @@
@comment $OpenBSD: PLIST-main,v 1.19 2012/02/06 22:07:09 espie Exp $
@comment $OpenBSD: PLIST-main,v 1.20 2012/02/24 10:44:55 mpi Exp $
@conflict vte-ptyhelper-*
@pkgpath devel/vte
@pkgpath devel/vte,-main,gtk2
@ -21,11 +21,6 @@ lib/libvte.la
@lib lib/libvte.so.${LIBvte_VERSION}
lib/pkgconfig/vte.pc
lib/python${MODPY_VERSION}/site-packages/gtk-2.0/
@mode g+s
@group utmp
@bin libexec/gnome-pty-helper2
@mode
@group
share/gir-1.0/Vte-0.0.gir
share/gtk-doc/html/vte-0.0/
share/gtk-doc/html/vte-0.0/VteReaper.html

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.11 2012/02/21 22:36:43 sthen Exp $
# $OpenBSD: Makefile,v 1.12 2012/02/24 10:44:55 mpi Exp $
COMMENT= terminal emulation library
@ -6,7 +6,7 @@ GNOME_PROJECT= vte
GNOME_VERSION= 0.30.1
PKGNAME= vte3-${GNOME_VERSION}
REVISION= 2
REVISION= 3
SHARED_LIBS += vte2_90 1.0 # 3009.0
@ -38,7 +38,12 @@ LIB_DEPENDS= x11/gtk+3
MODGNOME_TOOLS= goi
CONFIGURE_STYLE= gnu
AUTOCONF_VERSION= 2.68
AUTOMAKE_VERSION= 1.11
CONFIGURE_STYLE= autoconf
CONFIGURE_ARGS+= --disable-Bsymbolic \
--disable-gnome-pty-helper \
--enable-bsd-pty
.include <bsd.port.mk>

View File

@ -0,0 +1,51 @@
$OpenBSD: patch-configure_in,v 1.1 2012/02/24 10:44:55 mpi Exp $
Support for the openpty(3) backend.
--- configure.in
+++ configure.in
@@ -313,7 +313,7 @@ AC_SUBST(VTE_DEFAULT_EMULATION)
AM_CONDITIONAL(VTE_DEFAULT_EMULATION, [test "$emulation" != xterm])
# Check for headers.
-AC_CHECK_HEADERS(sys/select.h sys/syslimits.h sys/termios.h sys/un.h sys/wait.h stropts.h termios.h wchar.h)
+AC_CHECK_HEADERS(sys/select.h sys/syslimits.h sys/termios.h sys/un.h sys/wait.h stropts.h termios.h util.h wchar.h)
AC_HEADER_TIOCGWINSZ
# Check for PTY handling functions.
@@ -324,6 +324,7 @@ AC_CHECK_FUNCS([cfmakeraw fork setsid setpgid getpgid getpt grantpt unlockpt pts
AC_CHECK_FUNC(socket,[have_socket=1],AC_CHECK_LIB(socket,socket,[have_socket=1; LIBS="$LIBS -lsocket"]))
AC_CHECK_FUNC(socketpair,[have_socketpair=1],AC_CHECK_LIB(socket,socketpair,[have_socketpair=1; LIBS="$LIBS -lsocket"]))
AC_CHECK_FUNC(recvmsg,[have_recvmsg=1],AC_CHECK_LIB(socket,recvmsg,[have_recvmsg=1; LIBS="$LIBS -lsocket -lnsl"]))
+AC_CHECK_FUNC(openpty,[have_openpty=1],AC_CHECK_LIB(util,openpty,[have_openpty=1; LIBS="$LIBS -lutil"]))
if test x$have_socket = x1 ; then
AC_DEFINE(HAVE_SOCKET,1,[Define if you have the socket function.])
fi
@@ -333,6 +334,9 @@ fi
if test x$have_recvmsg = x1 ; then
AC_DEFINE(HAVE_RECVMSG,1,[Define if you have the recvmsg function.])
fi
+if test x$have_openpty = x1 ; then
+ AC_DEFINE(HAVE_OPENPTY,1,[Define if you have the openpty function.])
+fi
AC_CHECK_FUNC(floor,,AC_CHECK_LIB(m,floor,LIBS=["$LIBS -lm"]))
AC_CHECK_FUNCS([ceil floor])
@@ -423,6 +427,17 @@ fi
AM_CONDITIONAL(BUILD_GNOME_PTY_HELPER,[test "$enable_gnome_pty_helper" != no])
################################################################################
+# BSD PTY
+################################################################################
+
+AC_ARG_ENABLE(bsd-pty, [AS_HELP_STRING(--enable-bsd-pty,Support bsd rather than unix98 ptys [default=no])], enable_bsd_pty="$enableval", enable_bsd_pty=yes)
+if test "$enable_bsd_pty" != no; then
+ AC_DEFINE(VTE_USE_BSD_PTY,1,[Define if you intend to use bsd-pty.])
+ AC_CONFIG_SUBDIRS(bsd-pty)
+fi
+AM_CONDITIONAL(BUILD_BSD_PTY,[test "$enable_bsd_pty" != no])
+
+################################################################################
# Glade catalogue
################################################################################

View File

@ -1,16 +0,0 @@
$OpenBSD: patch-gnome-pty-helper_Makefile_in,v 1.1.1.1 2011/09/26 14:31:33 jasper Exp $
Don't bother calling install-exec-hook. We already adjust
permissions in PLIST.
--- gnome-pty-helper/Makefile.in.orig Mon Sep 26 15:48:00 2011
+++ gnome-pty-helper/Makefile.in Mon Sep 26 15:49:08 2011
@@ -580,7 +580,7 @@ install-dvi-am:
install-exec-am: install-libexecPROGRAMS
@$(NORMAL_INSTALL)
- $(MAKE) $(AM_MAKEFLAGS) install-exec-hook
+ $(MAKE) $(AM_MAKEFLAGS)
install-html: install-html-am
install-html-am:

View File

@ -1,27 +1,90 @@
$OpenBSD: patch-src_pty_c,v 1.1.1.1 2011/09/26 14:31:33 jasper Exp $
$OpenBSD: patch-src_pty_c,v 1.2 2012/02/24 10:44:55 mpi Exp $
Party revert to previous behaviour of returning -1, instead of failing
to compile.
Use openpty(3) backend instead of gnome-pty-helper
--- src/pty.c.orig Mon Aug 29 13:16:26 2011
+++ src/pty.c Mon Sep 26 15:46:55 2011
@@ -795,7 +795,8 @@ _vte_pty_ptsname(int master,
"%s failed: %s", "ioctl(TIOCGPTN)", g_strerror(errno));
return NULL;
#else
-#error no ptsname implementation for this platform
+#warning no ptsname implementation for this platform
+ return NULL;
--- src/pty.c
+++ src/pty.c
@@ -54,6 +54,9 @@
#include <termios.h>
#endif
#include <unistd.h>
+#ifdef HAVE_UTIL_H
+#include <util.h>
+#endif
#ifdef HAVE_STROPTS_H
#include <stropts.h>
#endif
@@ -734,6 +737,7 @@ vte_pty_get_size(VtePty *pty,
}
}
@@ -903,7 +904,8 @@ _vte_pty_unlockpt(int fd,
}
+#ifndef VTE_USE_BSD_PTY
/*
* _vte_pty_ptsname:
* @master: file descriptor to the PTY master
@@ -951,6 +955,44 @@ _vte_pty_open_unix98(VtePty *pty,
return TRUE;
#else
-#error no unlockpt implementation for this platform
+#warning no unlockpt implementation for this platform
+ return -1;
#endif
}
+#else
+/*
+ * _vte_pty_open_bsd:
+ * @pty: a #VtePty
+ * @error: a location to store a #GError, or %NULL
+ *
+ * Opens new file descriptors to a new PTY master and slave.
+ *
+ * Returns: %TRUE on success, %FALSE on failure with @error filled in
+ */
+static gboolean
+_vte_pty_open_bsd(VtePty *pty,
+ GError **error)
+{
+#ifdef HAVE_OPENPTY
+ VtePtyPrivate *priv = pty->priv;
+ int parentfd, childfd;
+
+ if (openpty(&parentfd, &childfd, NULL, NULL, NULL) != 0) {
+ int errsv = errno;
+ g_set_error(error, VTE_PTY_ERROR, VTE_PTY_ERROR_PTY98_FAILED,
+ "%s failed: %s", "openpty", g_strerror(errsv));
+ errno = errsv;
+ return FALSE;
+ }
+
+ priv->pty_fd = parentfd;
+ priv->child_setup_data.mode = TTY_OPEN_BY_FD;
+ priv->child_setup_data.tty.fd = childfd;
+ priv->using_helper = FALSE;
+
+ return TRUE;
+#else
+#error no openpty implementation for this platform
+#endif
+}
+#endif /* VTE_USE_BSD_PTY */
+
#ifdef VTE_USE_GNOME_PTY_HELPER
#ifdef HAVE_RECVMSG
static void
@@ -1511,7 +1553,7 @@ vte_pty_initable_init (GInitable *initable,
}
g_error_free(err);
- /* Fall back to unix98 PTY */
+ /* Fall back to unix98 or bsd PTY */
}
#else
if (priv->flags & VTE_PTY_NO_FALLBACK) {
@@ -1521,7 +1563,11 @@ vte_pty_initable_init (GInitable *initable,
}
#endif /* VTE_USE_GNOME_PTY_HELPER */
+#ifndef VTE_USE_BSD_PTY
ret = _vte_pty_open_unix98(pty, error);
+#else
+ ret = _vte_pty_open_bsd(pty, error);
+#endif /* VTE_USE_BSD_PTY */
out:
_vte_debug_print(VTE_DEBUG_PTY,

View File

@ -1,4 +1,4 @@
@comment $OpenBSD: PLIST,v 1.7 2012/02/06 22:07:09 espie Exp $
@comment $OpenBSD: PLIST,v 1.8 2012/02/24 10:44:55 mpi Exp $
@conflict vte-<0.28.2p3
@conflict vte-ptyhelper-*
@bin bin/vte2_90
@ -19,11 +19,6 @@ lib/libvte2_90.la
@lib lib/libvte2_90.so.${LIBvte2_90_VERSION}
lib/pkgconfig/
lib/pkgconfig/vte-2.90.pc
@mode g+s
@group utmp
@bin libexec/gnome-pty-helper
@mode
@group
share/gir-1.0/
share/gir-1.0/Vte-2.90.gir
share/gtk-doc/