From owner-freebsd-questions@freebsd.org Wed Oct 9 16:08:09 2019 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 959B614F668 for ; Wed, 9 Oct 2019 16:08:09 +0000 (UTC) (envelope-from freebsd@qeng-ho.org) Received: from bede.qeng-ho.org (bede.qeng-ho.org [217.155.128.241]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 46pJzC4kj2z4btN for ; Wed, 9 Oct 2019 16:08:07 +0000 (UTC) (envelope-from freebsd@qeng-ho.org) Received: from arthur.home.qeng-ho.org (arthur.home.qeng-ho.org [172.23.1.2]) by bede.qeng-ho.org (Postfix) with ESMTP id BEBD710669; Wed, 9 Oct 2019 17:07:58 +0100 (BST) Subject: Re: accessing the host's X server from inside chroot To: Per Hedeland , Kostas Oikonomou Cc: freebsd-questions@freebsd.org References: <0f7f3a8c-9b5d-c9cf-2bed-9f534216a441@hedeland.org> From: Arthur Chance Message-ID: <4c51f911-3bc7-7f50-45ba-c6f78af1b5ee@qeng-ho.org> Date: Wed, 9 Oct 2019 17:07:58 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:68.0) Gecko/20100101 Thunderbird/68.1.0 MIME-Version: 1.0 In-Reply-To: <0f7f3a8c-9b5d-c9cf-2bed-9f534216a441@hedeland.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 46pJzC4kj2z4btN X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of freebsd@qeng-ho.org designates 217.155.128.241 as permitted sender) smtp.mailfrom=freebsd@qeng-ho.org X-Spamd-Result: default: False [-4.70 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; RCPT_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:217.155.128.240/29]; FROM_HAS_DN(0.00)[]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_LAST(0.00)[]; DMARC_NA(0.00)[qeng-ho.org]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; TO_MATCH_ENVRCPT_SOME(0.00)[]; IP_SCORE(-2.40)[ip: (-7.31), ipnet: 217.155.0.0/16(-3.65), asn: 13037(-0.95), country: GB(-0.08)]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:13037, ipnet:217.155.0.0/16, country:GB]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Oct 2019 16:08:09 -0000 On 09/10/2019 14:18, Per Hedeland wrote: > On 2019-10-09 01:45, Kostas Oikonomou wrote: >> I am running FreeBSD 12.0p10.  Using chroot, I am trying to run a browser >> (palemoon) located in /opt/devuan, which contains a Devuan Linux >> distribution >> installed with 'debootstrap'.  My objective is for the browser to use >> the host's >> (FreeBSD) >> X server, not the Devuan one. >> >> I've added my FreeBSD user name as a Devuan user, home in >> /opt/devuan/home. >> Now I try things like >> >> sudo chroot -u /opt/devuan home/palemoon/palemoon >> >> but I cannot get past the error >> >> Error: cannot open display: :0.0 > > The display name :0.0 corresponds to a unix domain socket, typically > /tmp/.X11-unix/X0, which you of course can't reach after a chroot. By > setting the environment $DISPLAY to localhost:0.0, a TCP connection > should be made instead, but these days the X server doesn't listen for > TCP connections by default. If you start X with startx(1), it should > be possible to pass it '-- -listen tcp' to make the server listen for > TCP connections, see the respective man pages. > > Doing this has some security implications though, since the X server > will then listen on the wildcard address, and it will thus be possible > to connect to it over the network - I didn't see a way to make it > listen only on the localhost/loopback address. Authorization is still > required to actually do anything with the server - unless, of course, > you turn it off with "xhost +". If you run the host X server with -listen tcp and and set the DISPLAY variable in the chroot to localhost:0.0 I think you should be able to connect if you either 1) copy the FreeBSD level home directory's .Xauthority to the chroot's home directory or 2) run "xhost +localhost" at the host level before connecting. -- What do we want? A time machine! When do we want it? Errm ...