From 42bf54de28d37d70463fdd0eef4988caa32b86c6 Mon Sep 17 00:00:00 2001 From: Avi Deitcher Date: Tue, 13 Jun 2017 21:59:42 +0300 Subject: [PATCH] copy setsid to setsidu so it does not get overwritten by busybox when used in init, and ensure inittab is clean Signed-off-by: Avi Deitcher --- pkg/getty/Dockerfile | 11 +++++++++++ pkg/getty/usr/bin/rungetty.sh | 9 ++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/pkg/getty/Dockerfile b/pkg/getty/Dockerfile index 3333ab88e..0292384cf 100644 --- a/pkg/getty/Dockerfile +++ b/pkg/getty/Dockerfile @@ -9,6 +9,17 @@ RUN apk add --no-cache --initdb -p /out \ util-linux \ && true RUN rm -rf /out/etc/apk /out/lib/apk /out/var/cache +# +# We require a version of `setsid(1)` which supports the `-w` +# option, which is not available in all implementations (e.g. the +# `busybox` implementation does not support it). When this is run +# as part of a LinuxKit `init` image (rather than as a standalone +# container) we cannot guarantee which version of `setsid` will +# be present once the layers are combined, so we take a copy of +# our own, known good, version for use later. +RUN cp /out/usr/bin/setsid /out/usr/bin/setsid.getty +# we really do not want a rogue inittab here +RUN rm -rf /out/etc/inittab FROM scratch ENTRYPOINT ["/sbin/tini","-s","-v","--"] diff --git a/pkg/getty/usr/bin/rungetty.sh b/pkg/getty/usr/bin/rungetty.sh index c01581e43..164554db9 100755 --- a/pkg/getty/usr/bin/rungetty.sh +++ b/pkg/getty/usr/bin/rungetty.sh @@ -7,12 +7,11 @@ infinite_loop() { done } -# run getty on all known consoles - except those already in inittab +# run getty on all known consoles start_getty() { tty=${1%,*} speed=${1#*,} - inittab="$2" - securetty="$3" + securetty="$2" line= term="linux" [ "$speed" = "$1" ] && speed=115200 @@ -39,7 +38,7 @@ start_getty() { echo "$tty" >> "$securetty" fi # respawn forever - infinite_loop setsid -w /sbin/getty $loginargs $line $speed $tty $term & + infinite_loop setsid.getty -w /sbin/getty $loginargs $line $speed $tty $term & } # check if we have /etc/getty.shadow @@ -53,7 +52,7 @@ fi for opt in $(cat /proc/cmdline); do case "$opt" in console=*) - start_getty ${opt#console=} /etc/inittab /etc/securetty + start_getty ${opt#console=} /etc/securetty esac done