Merge pull request #2179 from deitch/read-only-securetty

Use existing securetty
This commit is contained in:
Justin Cormack 2017-07-11 23:19:43 +01:00 committed by GitHub
commit f98a56fc2c
12 changed files with 25 additions and 11 deletions

View File

@ -20,7 +20,7 @@ onboot:
command: ["/mount.sh", "/var/lib/docker"] command: ["/mount.sh", "/var/lib/docker"]
services: services:
- name: getty - name: getty
image: linuxkit/getty:5ab31289889d61a5d2ecbeea8e36ce74ac54737c image: linuxkit/getty:0bd92d5f906491c20e4177c57f965338fe5a8c5f
env: env:
- INSECURE=true - INSECURE=true
- name: rngd - name: rngd

View File

@ -16,7 +16,7 @@ onboot:
image: linuxkit/metadata:f122f1b4e873f1d08cd67bd9105385fd923af0cb image: linuxkit/metadata:f122f1b4e873f1d08cd67bd9105385fd923af0cb
services: services:
- name: getty - name: getty
image: linuxkit/getty:5ab31289889d61a5d2ecbeea8e36ce74ac54737c image: linuxkit/getty:0bd92d5f906491c20e4177c57f965338fe5a8c5f
env: env:
- INSECURE=true - INSECURE=true
- name: rngd - name: rngd

View File

@ -14,7 +14,7 @@ onboot:
command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"] command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
services: services:
- name: getty - name: getty
image: linuxkit/getty:5ab31289889d61a5d2ecbeea8e36ce74ac54737c image: linuxkit/getty:0bd92d5f906491c20e4177c57f965338fe5a8c5f
# to make insecure with passwordless root login, uncomment following lines # to make insecure with passwordless root login, uncomment following lines
#env: #env:
# - INSECURE=true # - INSECURE=true

View File

@ -11,7 +11,7 @@ onboot:
command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"] command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
services: services:
- name: getty - name: getty
image: linuxkit/getty:5ab31289889d61a5d2ecbeea8e36ce74ac54737c image: linuxkit/getty:0bd92d5f906491c20e4177c57f965338fe5a8c5f
env: env:
- INSECURE=true - INSECURE=true
trust: trust:

View File

@ -7,7 +7,7 @@ init:
- linuxkit/containerd:c977f27c234d55b85172813b8451f67ea86be4a3 - linuxkit/containerd:c977f27c234d55b85172813b8451f67ea86be4a3
services: services:
- name: getty - name: getty
image: linuxkit/getty:5ab31289889d61a5d2ecbeea8e36ce74ac54737c image: linuxkit/getty:0bd92d5f906491c20e4177c57f965338fe5a8c5f
env: env:
- INSECURE=true - INSECURE=true
- name: rngd - name: rngd

View File

@ -13,7 +13,7 @@ onboot:
command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"] command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
services: services:
- name: getty - name: getty
image: linuxkit/getty:5ab31289889d61a5d2ecbeea8e36ce74ac54737c image: linuxkit/getty:0bd92d5f906491c20e4177c57f965338fe5a8c5f
env: env:
- INSECURE=true - INSECURE=true
- name: redis - name: redis

View File

@ -11,7 +11,7 @@ onboot:
image: linuxkit/sysctl:d1a43c7c91e92374766f962dc8534cf9508756b0 image: linuxkit/sysctl:d1a43c7c91e92374766f962dc8534cf9508756b0
services: services:
- name: getty - name: getty
image: linuxkit/getty:5ab31289889d61a5d2ecbeea8e36ce74ac54737c image: linuxkit/getty:0bd92d5f906491c20e4177c57f965338fe5a8c5f
env: env:
- INSECURE=true - INSECURE=true
- name: rngd - name: rngd

View File

@ -24,7 +24,7 @@ onboot:
command: ["/swap.sh", "--path", "/var/external/swap", "--size", "1G", "--encrypt"] command: ["/swap.sh", "--path", "/var/external/swap", "--size", "1G", "--encrypt"]
services: services:
- name: getty - name: getty
image: linuxkit/getty:5ab31289889d61a5d2ecbeea8e36ce74ac54737c image: linuxkit/getty:0bd92d5f906491c20e4177c57f965338fe5a8c5f
env: env:
- INSECURE=true - INSECURE=true
- name: rngd - name: rngd

View File

@ -11,7 +11,7 @@ onboot:
image: linuxkit/sysctl:d1a43c7c91e92374766f962dc8534cf9508756b0 image: linuxkit/sysctl:d1a43c7c91e92374766f962dc8534cf9508756b0
services: services:
- name: getty - name: getty
image: linuxkit/getty:5ab31289889d61a5d2ecbeea8e36ce74ac54737c image: linuxkit/getty:0bd92d5f906491c20e4177c57f965338fe5a8c5f
env: env:
- INSECURE=true - INSECURE=true
- name: rngd - name: rngd

View File

@ -16,7 +16,7 @@ onboot:
image: linuxkit/metadata:f122f1b4e873f1d08cd67bd9105385fd923af0cb image: linuxkit/metadata:f122f1b4e873f1d08cd67bd9105385fd923af0cb
services: services:
- name: getty - name: getty
image: linuxkit/getty:5ab31289889d61a5d2ecbeea8e36ce74ac54737c image: linuxkit/getty:0bd92d5f906491c20e4177c57f965338fe5a8c5f
env: env:
- INSECURE=true - INSECURE=true
- name: rngd - name: rngd

View File

@ -16,6 +16,12 @@ services:
The above will launch a getty for each console defined in the cmdline, i.e. `/proc/cmdline`. The above will launch a getty for each console defined in the cmdline, i.e. `/proc/cmdline`.
### securetty
Every console defined in the `cmdline` **must** also already exist in `/etc/securetty` if you wish to login on that tty as root. If it does not exist, a getty will be started, but you will not be able to login as root. A warning message will be sent to that tty.
If you are using a console that is not in `securetty`, you can add it by overriding the default `securetty` file in the linuxkit root filesystem using `files:` in your moby `.yml` file.
### Login Options ### Login Options
There are 3 ways to launch a getty on a linuxkit instance: There are 3 ways to launch a getty on a linuxkit instance:

View File

@ -35,7 +35,8 @@ start_getty() {
fi fi
if ! grep -q -w "$tty" "$securetty"; then if ! grep -q -w "$tty" "$securetty"; then
echo "$tty" >> "$securetty" # we could not find the tty in securetty, so start a getty but warn that root login will not work
echo "getty: cmdline has console=$tty but does not exist in $securetty; will not be able to log in as root on this tty $tty." > /dev/$tty
fi fi
# respawn forever # respawn forever
infinite_loop setsid.getty -w /sbin/agetty $loginargs $line $speed $tty $term & infinite_loop setsid.getty -w /sbin/agetty $loginargs $line $speed $tty $term &
@ -49,6 +50,13 @@ if [ -f $ROOTSHADOW ]; then
echo >> /etc/shadow echo >> /etc/shadow
fi fi
ROOTSTTY=/hostroot/etc/securetty
if [ -f $ROOTSTTY ]; then
cp $ROOTSTTY /etc/securetty
# just in case someone forgot a newline
echo >> /etc/securetty
fi
for opt in $(cat /proc/cmdline); do for opt in $(cat /proc/cmdline); do
case "$opt" in case "$opt" in
console=*) console=*)