From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Thompson Subject: [PATCH] build: container: Setup /dev/console. Date: Fri, 04 Sep 2015 19:59:52 -0400 Message-ID: <87oahhybuv.fsf@izanagi.i-did-not-set--mail-host-address--so-tickle-me> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:32779) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZY0tf-0000mX-4z for guix-devel@gnu.org; Fri, 04 Sep 2015 19:59:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZY0te-0008SE-2Z for guix-devel@gnu.org; Fri, 04 Sep 2015 19:59:55 -0400 Received: from mail.fsf.org ([208.118.235.13]:41582) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZY0td-0008SA-VY for guix-devel@gnu.org; Fri, 04 Sep 2015 19:59:54 -0400 Received: from c-73-188-137-88.hsd1.de.comcast.net ([73.188.137.88]:54171 helo=izanagi) by mail.fsf.org with esmtpsa (TLS-1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.69) (envelope-from ) id 1ZY0td-0005iW-Jc for guix-devel@gnu.org; Fri, 04 Sep 2015 19:59:53 -0400 List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: guix-devel@gnu.org --=-=-= Content-Type: text/plain A step towards making containers behave better WRT terminals. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-build-container-Setup-dev-console.patch >From dc797eb8e306655b10bd466d64ef5deaf428259f Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sat, 1 Aug 2015 13:54:40 -0400 Subject: [PATCH] build: container: Setup /dev/console. * gnu/build/linux-container.scm (mount-file-systems): Bind mount the controlling terminal as /dev/console. --- gnu/build/linux-container.scm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/gnu/build/linux-container.scm b/gnu/build/linux-container.scm index af59904..4262748 100644 --- a/gnu/build/linux-container.scm +++ b/gnu/build/linux-container.scm @@ -55,6 +55,9 @@ to ROOT, then make ROOT the new root directory for the process." (define (scope dir) (string-append root dir)) + (define (touch file-name) + (call-with-output-file file-name (const #t))) + (define (bind-mount src dest) (mount src dest "none" MS_BIND)) @@ -89,8 +92,7 @@ to ROOT, then make ROOT the new root directory for the process." (for-each (lambda (device) (when (file-exists? device) ;; Create the mount point file. - (call-with-output-file (scope device) - (const #t)) + (touch (scope device)) (bind-mount device (scope device)))) '("/dev/null" "/dev/zero" @@ -101,6 +103,15 @@ to ROOT, then make ROOT the new root directory for the process." "/dev/ptmx" "/dev/fuse")) + ;; Setup the container's /dev/console by bind mounting the psuedo-terminal + ;; associated with standard input. + (let ((in (current-input-port)) + (console (scope "/dev/console"))) + (when (isatty? in) + (touch console) + (chmod console #o600) + (bind-mount (ttyname in) console))) + ;; Setup standard input/output/error. (symlink "/proc/self/fd" (scope "/dev/fd")) (symlink "/proc/self/fd/0" (scope "/dev/stdin")) -- 2.5.0 --=-=-= Content-Type: text/plain -- David Thompson GPG Key: 0FF1D807 --=-=-=--