Merge pull request #2233 from dave-tucker/ns-detect

getty: Detect if you are in a namespace
This commit is contained in:
Avi Deitcher 2017-07-27 16:50:02 +03:00 committed by GitHub
commit 8f10f69fd3
23 changed files with 29 additions and 22 deletions

View File

@ -53,7 +53,7 @@ services:
image: linuxkit/acpid:1966310cb75e28ffc668863a6577ee991327f918 image: linuxkit/acpid:1966310cb75e28ffc668863a6577ee991327f918
# Enable getty for easier debugging # Enable getty for easier debugging
- name: getty - name: getty
image: linuxkit/getty:894eef1e5f62f3bc31de8ffaff2b6c0e093c4595 image: linuxkit/getty:58620cff1b0bf8b5d144d087602115e996f18a02
env: env:
- INSECURE=true - INSECURE=true
# Run ntpd to keep time synchronised in the VM # Run ntpd to keep time synchronised in the VM

View File

@ -20,7 +20,7 @@ onboot:
command: ["/usr/bin/mountie", "/var/lib/docker"] command: ["/usr/bin/mountie", "/var/lib/docker"]
services: services:
- name: getty - name: getty
image: linuxkit/getty:894eef1e5f62f3bc31de8ffaff2b6c0e093c4595 image: linuxkit/getty:58620cff1b0bf8b5d144d087602115e996f18a02
env: env:
- INSECURE=true - INSECURE=true
- name: rngd - name: rngd

View File

@ -16,7 +16,7 @@ onboot:
image: linuxkit/metadata:f5d4299909b159db35f72547e4ae70bd76c42c6c image: linuxkit/metadata:f5d4299909b159db35f72547e4ae70bd76c42c6c
services: services:
- name: getty - name: getty
image: linuxkit/getty:894eef1e5f62f3bc31de8ffaff2b6c0e093c4595 image: linuxkit/getty:58620cff1b0bf8b5d144d087602115e996f18a02
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:894eef1e5f62f3bc31de8ffaff2b6c0e093c4595 image: linuxkit/getty:58620cff1b0bf8b5d144d087602115e996f18a02
# 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:894eef1e5f62f3bc31de8ffaff2b6c0e093c4595 image: linuxkit/getty:58620cff1b0bf8b5d144d087602115e996f18a02
env: env:
- INSECURE=true - INSECURE=true
trust: trust:

View File

@ -7,7 +7,7 @@ init:
- linuxkit/containerd:8fc87b7f465bde9ece781899a007f47b6d3c096b - linuxkit/containerd:8fc87b7f465bde9ece781899a007f47b6d3c096b
services: services:
- name: getty - name: getty
image: linuxkit/getty:894eef1e5f62f3bc31de8ffaff2b6c0e093c4595 image: linuxkit/getty:58620cff1b0bf8b5d144d087602115e996f18a02
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:894eef1e5f62f3bc31de8ffaff2b6c0e093c4595 image: linuxkit/getty:58620cff1b0bf8b5d144d087602115e996f18a02
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:894eef1e5f62f3bc31de8ffaff2b6c0e093c4595 image: linuxkit/getty:58620cff1b0bf8b5d144d087602115e996f18a02
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:894eef1e5f62f3bc31de8ffaff2b6c0e093c4595 image: linuxkit/getty:58620cff1b0bf8b5d144d087602115e996f18a02
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:1b651a91f1c17f50357be9873b580ccf81668630 image: linuxkit/getty:58620cff1b0bf8b5d144d087602115e996f18a02
env: env:
- INSECURE=true - INSECURE=true
- name: tss - name: tss

View File

@ -11,7 +11,7 @@ onboot:
image: linuxkit/sysctl:d1a43c7c91e92374766f962dc8534cf9508756b0 image: linuxkit/sysctl:d1a43c7c91e92374766f962dc8534cf9508756b0
services: services:
- name: getty - name: getty
image: linuxkit/getty:894eef1e5f62f3bc31de8ffaff2b6c0e093c4595 image: linuxkit/getty:58620cff1b0bf8b5d144d087602115e996f18a02
env: env:
- INSECURE=true - INSECURE=true
- name: rngd - name: rngd

View File

@ -16,7 +16,7 @@ onboot:
image: linuxkit/metadata:f5d4299909b159db35f72547e4ae70bd76c42c6c image: linuxkit/metadata:f5d4299909b159db35f72547e4ae70bd76c42c6c
services: services:
- name: getty - name: getty
image: linuxkit/getty:894eef1e5f62f3bc31de8ffaff2b6c0e093c4595 image: linuxkit/getty:58620cff1b0bf8b5d144d087602115e996f18a02
env: env:
- INSECURE=true - INSECURE=true
- name: rngd - name: rngd

View File

@ -20,7 +20,7 @@ onshutdown:
command: ["/bin/echo", "so long and thanks for all the fish"] command: ["/bin/echo", "so long and thanks for all the fish"]
services: services:
- name: getty - name: getty
image: linuxkit/getty:894eef1e5f62f3bc31de8ffaff2b6c0e093c4595 image: linuxkit/getty:58620cff1b0bf8b5d144d087602115e996f18a02
env: env:
- INSECURE=true - INSECURE=true
- name: rngd - name: rngd

View File

@ -1 +0,0 @@
export PS1="(ns: getty) $PS1"

View File

@ -41,6 +41,14 @@ start_getty() {
infinite_loop setsid.getty -w /sbin/agetty $loginargs $line $speed $tty $term & infinite_loop setsid.getty -w /sbin/agetty $loginargs $line $speed $tty $term &
} }
# check if we are namespaced, and, if so, indicate in the PS1
if [ -z "$INITGETTY" ]; then
cat >/etc/profile.d/namespace.sh <<"EOF"
export PS1="(ns: getty) $PS1"
EOF
fi
# check if we have /etc/getty.shadow # check if we have /etc/getty.shadow
ROOTSHADOW=/hostroot/etc/getty.shadow ROOTSHADOW=/hostroot/etc/getty.shadow
if [ -f $ROOTSHADOW ]; then if [ -f $ROOTSHADOW ]; then

View File

@ -30,7 +30,7 @@ onboot:
- /var/lib:/var/lib - /var/lib:/var/lib
services: services:
- name: getty - name: getty
image: linuxkit/getty:894eef1e5f62f3bc31de8ffaff2b6c0e093c4595 image: linuxkit/getty:58620cff1b0bf8b5d144d087602115e996f18a02
env: env:
- INSECURE=true - INSECURE=true
- name: rngd - name: rngd

View File

@ -30,7 +30,7 @@ onboot:
- /var/lib:/var/lib - /var/lib:/var/lib
services: services:
- name: getty - name: getty
image: linuxkit/getty:894eef1e5f62f3bc31de8ffaff2b6c0e093c4595 image: linuxkit/getty:58620cff1b0bf8b5d144d087602115e996f18a02
env: env:
- INSECURE=true - INSECURE=true
- name: rngd - name: rngd

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:0bd92d5f906491c20e4177c57f965338fe5a8c5f image: linuxkit/getty:58620cff1b0bf8b5d144d087602115e996f18a02
env: env:
- INSECURE=true - INSECURE=true
trust: trust:

View File

@ -12,7 +12,7 @@ onboot:
image: linuxkit/sysctl:d1a43c7c91e92374766f962dc8534cf9508756b0 image: linuxkit/sysctl:d1a43c7c91e92374766f962dc8534cf9508756b0
services: services:
- name: getty - name: getty
image: linuxkit/getty:6cbeee0392b0670053ce2bf05a5a0d67ec2bce05 image: linuxkit/getty:58620cff1b0bf8b5d144d087602115e996f18a02
env: env:
- INSECURE=true - INSECURE=true
- name: rngd - name: rngd

View File

@ -30,7 +30,7 @@ services:
- name: sshd - name: sshd
image: linuxkit/sshd:dc98a72c1d1285c30f2db176252f3ce2bf645d5b image: linuxkit/sshd:dc98a72c1d1285c30f2db176252f3ce2bf645d5b
- name: getty - name: getty
image: linuxkit/getty:894eef1e5f62f3bc31de8ffaff2b6c0e093c4595 image: linuxkit/getty:58620cff1b0bf8b5d144d087602115e996f18a02
env: env:
- INSECURE=true - INSECURE=true
files: files:

View File

@ -16,7 +16,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:894eef1e5f62f3bc31de8ffaff2b6c0e093c4595 image: linuxkit/getty:58620cff1b0bf8b5d144d087602115e996f18a02
env: env:
- INSECURE=true - INSECURE=true
- name: rngd - name: rngd

View File

@ -23,7 +23,7 @@ onboot:
image: linuxkit/metadata:f5d4299909b159db35f72547e4ae70bd76c42c6c image: linuxkit/metadata:f5d4299909b159db35f72547e4ae70bd76c42c6c
services: services:
- name: getty - name: getty
image: linuxkit/getty:894eef1e5f62f3bc31de8ffaff2b6c0e093c4595 image: linuxkit/getty:58620cff1b0bf8b5d144d087602115e996f18a02
env: env:
- INSECURE=true - INSECURE=true
- name: qemu-ga - name: qemu-ga

View File

@ -12,7 +12,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:894eef1e5f62f3bc31de8ffaff2b6c0e093c4595 image: linuxkit/getty:58620cff1b0bf8b5d144d087602115e996f18a02
files: files:
- path: etc/getty.shadow - path: etc/getty.shadow
# sample sets password for root to "abcdefgh" (without quotes) # sample sets password for root to "abcdefgh" (without quotes)