From 3301af529c73cb1727f3ba3ecabd1f9795103ebb Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Mon, 9 Apr 2018 14:26:49 +0100 Subject: [PATCH] Avoid writing to tty devices which don't actually exist. $ git diff linuxkit.yml diff --git a/linuxkit.yml b/linuxkit.yml index e2ec829db..21b84e4ad 100644 --- a/linuxkit.yml +++ b/linuxkit.yml @@ -1,6 +1,6 @@ kernel: image: linuxkit/kernel:4.14.32 - cmdline: "console=tty0 console=ttyS0 console=ttyAMA0" + cmdline: "console=ttyS0 console=foobar" init: - linuxkit/init:v0.3 - linuxkit/runc:v0.3 $ linuxkit build linuxkit.yml [...] $ linuxkit run linuxkit [...] getty: cmdline has console=foobar but /dev/foobar is not a character device; not starting getty for foobar linuxkit-2ae2c420a11c login: root (automatic login) Welcome to LinuxKit! NOTE: This system is namespaced. The namespace you are currently in may not be the root. (ns: getty) linuxkit-2ae2c420a11c:~# ls -l /proc/1/root/dev/foobar -rw-r--r-- 1 root root 311 Apr 9 13:19 /proc/1/root/dev/foobar (ns: getty) linuxkit-2ae2c420a11c:~# cat /proc/1/root/dev/foobar Welcome to LinuxKit ## . ## ## ## == ## ## ## ## ## === /"""""""""""""""""\___/ === { / ===- \______ O __/ \ \ __/ \____\_______/ Also added quotes around $tty for good measure. Signed-off-by: Ian Campbell --- pkg/init/etc/init.d/000-issue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/init/etc/init.d/000-issue b/pkg/init/etc/init.d/000-issue index 7b98c331c..d661c79d4 100755 --- a/pkg/init/etc/init.d/000-issue +++ b/pkg/init/etc/init.d/000-issue @@ -6,7 +6,9 @@ if [ -f /etc/issue ]; then console=*) fulltty=${opt#console=} tty=${fulltty%,*} - cat /etc/issue >> /dev/$tty + if [ -c "/dev/$tty" ] ; then + cat /etc/issue >> "/dev/$tty" + fi esac done fi