From 2d9868a5b7d97cd493c7035b9057784125f0fe9c Mon Sep 17 00:00:00 2001
From: root <root@io.vyatta.com>
Date: Mon, 14 Jul 2008 14:59:07 -0700
Subject: Fix 3359: changing telnet setting drops other telnet sessions.

---
 templates/service/telnet/node.def | 45 ++++++++++++++++++++++++---------------
 1 file changed, 28 insertions(+), 17 deletions(-)

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

diff --git a/templates/service/telnet/node.def b/templates/service/telnet/node.def
index 5976addd..399f25ac 100644
--- a/templates/service/telnet/node.def
+++ b/templates/service/telnet/node.def
@@ -1,18 +1,29 @@
 help: Enable/disable Network Virtual Terminal Protocol (TELNET) protocol
-delete:expression: " \
-  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 /opt/vyatta/sbin/telnetd.init stop"
-end:expression: " \
-  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 [ -z \"$VAR(port/@)\" ]; then exit 0; fi; \
-  sudo /opt/vyatta/sbin/telnetd.init restart $VAR(port/@)"
+
+delete: pids=`who -u | awk -F " " '{print $7}'`
+        for i in $pids
+        do
+          ppid=`ps -p $i -o ppid=`
+          if ps -p $ppid -o cmd= | grep -q telnetd
+          then
+            echo "Please configure telnet settings via ssh or console."
+            exit 1
+          fi
+        done
+        sudo /opt/vyatta/sbin/telnetd.init stop
+
+end:    pids=`who -u | awk -F " " '{print $7}'`
+        for i in $pids
+        do
+          ppid=`ps -p $i -o ppid=`
+          if ps -p $ppid -o cmd= | grep -q telnetd
+          then
+            echo "Please configure telnet settings via ssh or console."
+            exit 1
+          fi
+        done
+        if [ -z "$VAR(port/@)" ] 
+        then
+          exit 0
+        fi
+        sudo /opt/vyatta/sbin/telnetd.init restart $VAR(port/@)
-- 
cgit v1.2.3

