From f41c9764064e349293ce70b2fa79072d17a5bbc9 Mon Sep 17 00:00:00 2001
From: Dave Tucker
Date: Mon, 17 Jul 2017 16:39:45 +0100
Subject: [PATCH] getty: Detect if you are in a namespace
This is an attempt at fixing #2213
If `INITGETTY` has been set then we are not in a namespace.
Signed-off-by: Avi Deitcher
---
pkg/getty/etc/profile.d/namespace.sh | 1 -
pkg/getty/usr/bin/rungetty.sh | 8 ++++++++
2 files changed, 8 insertions(+), 1 deletion(-)
delete mode 100644 pkg/getty/etc/profile.d/namespace.sh
diff --git a/pkg/getty/etc/profile.d/namespace.sh b/pkg/getty/etc/profile.d/namespace.sh
deleted file mode 100644
index db350f3fa..000000000
--- a/pkg/getty/etc/profile.d/namespace.sh
+++ /dev/null
@@ -1 +0,0 @@
-export PS1="(ns: getty) $PS1"
diff --git a/pkg/getty/usr/bin/rungetty.sh b/pkg/getty/usr/bin/rungetty.sh
index 8cb89e877..68262087e 100755
--- a/pkg/getty/usr/bin/rungetty.sh
+++ b/pkg/getty/usr/bin/rungetty.sh
@@ -41,6 +41,14 @@ start_getty() {
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 "$INIGETTY" ]; then
+ cat >/etc/profile.d/namespace.sh <<"EOF"
+export PS1="(ns: getty) $PS1"
+EOF
+fi
+
# check if we have /etc/getty.shadow
ROOTSHADOW=/hostroot/etc/getty.shadow
if [ -f $ROOTSHADOW ]; then