From: David Thompson <dthompson2@worcester.edu>
To: guix-devel@gnu.org
Subject: [PATCH] build: container: Setup /dev/console.
Date: Fri, 04 Sep 2015 19:59:52 -0400 [thread overview]
Message-ID: <87oahhybuv.fsf@izanagi.i-did-not-set--mail-host-address--so-tickle-me> (raw)
[-- Attachment #1: Type: text/plain, Size: 63 bytes --]
A step towards making containers behave better WRT terminals.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-build-container-Setup-dev-console.patch --]
[-- Type: text/x-patch, Size: 1955 bytes --]
From dc797eb8e306655b10bd466d64ef5deaf428259f Mon Sep 17 00:00:00 2001
From: David Thompson <dthompson2@worcester.edu>
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
[-- Attachment #3: Type: text/plain, Size: 38 bytes --]
--
David Thompson
GPG Key: 0FF1D807
next reply other threads:[~2015-09-04 23:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-04 23:59 David Thompson [this message]
2015-09-07 16:03 ` [PATCH] build: container: Setup /dev/console Ludovic Courtès
2015-09-07 17:09 ` Thompson, David
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87oahhybuv.fsf@izanagi.i-did-not-set--mail-host-address--so-tickle-me \
--to=dthompson2@worcester.edu \
--cc=guix-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.