From owner-freebsd-ports@FreeBSD.ORG Thu Nov 17 19:54:13 2011 Return-Path: Delivered-To: freebsd-ports@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 33134106566C; Thu, 17 Nov 2011 19:54:13 +0000 (UTC) (envelope-from david@catwhisker.org) Received: from albert.catwhisker.org (m209-73.dsl.rawbw.com [198.144.209.73]) by mx1.freebsd.org (Postfix) with ESMTP id 020C98FC0C; Thu, 17 Nov 2011 19:54:12 +0000 (UTC) Received: from albert.catwhisker.org (localhost [127.0.0.1]) by albert.catwhisker.org (8.14.5/8.14.5) with ESMTP id pAHJiCkZ031680; Thu, 17 Nov 2011 11:44:12 -0800 (PST) (envelope-from david@albert.catwhisker.org) Received: (from david@localhost) by albert.catwhisker.org (8.14.5/8.14.5/Submit) id pAHJiCEV031679; Thu, 17 Nov 2011 11:44:12 -0800 (PST) (envelope-from david) Date: Thu, 17 Nov 2011 11:44:12 -0800 From: David Wolfskill To: ehaupt@FreeBSD.org Message-ID: <20111117194412.GP1706@albert.catwhisker.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="aC33ObtQAkNdOZ6b" Content-Disposition: inline User-Agent: Mutt/1.4.2.3i Cc: freebsd-ports@FreeBSD.org Subject: Support for running xterm within a jail? X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Nov 2011 19:54:13 -0000 --aC33ObtQAkNdOZ6b Content-Type: multipart/mixed; boundary="8WA4ILJSyYAmUzbY" Content-Disposition: inline --8WA4ILJSyYAmUzbY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable At $WORK, we have recently been reminded that xterm doesn't cope all that well with being invoked in an environment that returns ENOENT on xterm's attempt to open /dev/tty (in main.c). (The environment in question is a jailed 32-bit FreeBSD running on a FreeBSD/amd64 host. Developers need to build in the jail; apparently they also want to run things like emacs in the jails.) In looking at the xterm sources, I found that there's some code (near main.c:3311 - 3329) to take evasive action if the attempt to open /dev/tty fails. There's even a bit to effectively ignore ENOENT -- if __CYGWIN__ is defined. But that's not our case -- and we don't want to be defining __CYGWIN__ when we're building xterm for FreeBSD. Given that FreeBSD (with devfs) *can* return ENOENT to the attempt to open /dev/tty, it isn't clear to me why that aprticular "error" condition isn't ignored unconditionally (in a FreeBSD environment, at least). Accordingly, I cobbled up a patch (attached), and a colleague has verified that it avoids the issue we were encountering: it allows xterm to run in the jail. Do you think the xterm folks would be receptive to either making the "ignore ENOENT" unconditional or conditioning it on (say) "__CYGWIN_" being defined or "__FREEBSD__" being defined? Failing that (or in the mean time) would you be receptive to a patch to the FreeBSD xterm port to patch xterm in a way similar to the attached patch? (I realize we're approaching 9.0-RELEASE; I'm not asking anyone to make changes before that release date.) Thanks! Peace, david --=20 David H. Wolfskill david@catwhisker.org Depriving a girl or boy of an opportunity for education is evil. See http://www.catwhisker.org/~david/publickey.gpg for my public key. --8WA4ILJSyYAmUzbY Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="xterm_ENOENT.diff" --- main.c.orig 2011-09-04 11:04:33.000000000 -0700 +++ main.c 2011-11-14 20:12:29.000000000 -0800 @@ -3311,19 +3311,18 @@ * necessary. ENXIO is what is normally returned if there is * no controlling terminal, but some systems (e.g. SunOS 4.0) * seem to return EIO. Solaris 2.3 is said to return EINVAL. - * Cygwin returns ENOENT. + * Cygwin returns ENOENT. FreeBSD can return ENOENT, especially + * if xterm is run within a jail. */ #if USE_NO_DEV_TTY no_dev_tty = False; #endif if (ttyfd < 0) { if (tty_got_hung || errno == ENXIO || errno == EIO || + errno == ENOENT || #ifdef ENODEV errno == ENODEV || #endif -#ifdef __CYGWIN__ - errno == ENOENT || -#endif errno == EINVAL || errno == ENOTTY || errno == EACCES) { #if USE_NO_DEV_TTY no_dev_tty = True; --8WA4ILJSyYAmUzbY-- --aC33ObtQAkNdOZ6b Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (FreeBSD) iEYEARECAAYFAk7FZAsACgkQmprOCmdXAD29sACfWc6m5hTq3HfLitIG2/wE3XSk iWoAnjNjLrYr1wCqk3lCEYB5j27D/TNn =f/Xo -----END PGP SIGNATURE----- --aC33ObtQAkNdOZ6b--