From 41dce94fe7ce2518a2a83387d3c88384c42ed203 Mon Sep 17 00:00:00 2001
From: An-Cheng Huang <ancheng@vyatta.com>
Date: Mon, 10 Dec 2007 18:05:13 -0800
Subject: also check telnet session for "allow-root"

---
 templates/service/telnet/allow-root/node.def | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)

(limited to 'templates/service/telnet/allow-root/node.def')

diff --git a/templates/service/telnet/allow-root/node.def b/templates/service/telnet/allow-root/node.def
index 654023af..9c3ff97d 100644
--- a/templates/service/telnet/allow-root/node.def
+++ b/templates/service/telnet/allow-root/node.def
@@ -1,10 +1,24 @@
 type: bool
 default: false
 help: "Enable/disable root login"
-update: "if [ \"$(@)\" == \"true\" ]; then \
-           sudo mv -f /etc/securetty /etc/securetty.allow-root >&/dev/null; \
-         else
-           sudo mv -f /etc/securetty.allow-root /etc/securetty >&/dev/null; \
-         fi ; /bin/true"
-delete: "sudo mv -f /etc/securetty.allow-root /etc/securetty >&/dev/null ; \
-         /bin/true"
+update: " \
+  if ! env | grep -q SSH_TTY=; then \
+    if [[ \"`tty`\" == /dev/pts/* ]]; then \
+      echo \"Please configure telnet settings via ssh or console.\"; \
+      exit 1; \
+    fi; \
+  fi; \
+  if [ \"$(@)\" == \"true\" ]; then \
+    sudo mv -f /etc/securetty /etc/securetty.allow-root >&/dev/null; \
+  else
+    sudo mv -f /etc/securetty.allow-root /etc/securetty >&/dev/null; \
+  fi ; /bin/true"
+delete: " \
+  if ! env | grep -q SSH_TTY=; then \
+    if [[ \"`tty`\" == /dev/pts/* ]]; then \
+      echo \"Please configure telnet settings via ssh or console.\"; \
+      exit 1; \
+    fi; \
+  fi; \
+  sudo mv -f /etc/securetty.allow-root /etc/securetty >&/dev/null ; \
+  /bin/true"
-- 
cgit v1.2.3

