diff --git a/gnu/build/linux-container.scm b/gnu/build/linux-container.scm index af599040a1a123030ef232bad8021c32074e2106..c004303f035f58b9175f3a88a46c0883b5368e75 100644 --- a/gnu/build/linux-container.scm +++ b/gnu/build/linux-container.scm @@ -55,6 +55,9 @@ (define* (mount-file-systems root mounts #:key mount-/sys? mount-/proc?) (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 @@ (define* (mount* source target type #:optional (flags 0) options (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 @@ (define* (mount* source target type #:optional (flags 0) options "/dev/ptmx" "/dev/fuse")) + ;; Setup the container's /dev/console by bind mounting the pseudo-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"))