From c6c477f2ffb0f2fd4cf12882f22c2c44ab57cc46 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 16 Jun 2009 15:31:49 -0700 Subject: Make telnet management smarter Bug 4591 Consolidate check for telnet login Don't remove /etc/securetty edit it --- scripts/system/vyatta_update_telnet | 82 +++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100755 scripts/system/vyatta_update_telnet (limited to 'scripts') diff --git a/scripts/system/vyatta_update_telnet b/scripts/system/vyatta_update_telnet new file mode 100755 index 00000000..0725a85f --- /dev/null +++ b/scripts/system/vyatta_update_telnet @@ -0,0 +1,82 @@ +#! /bin/bash +# Script to control telnet daemon parameters +# and block changes when logged in over telnet + +# Block changes to telnet daemon when logged in over telnet +pid=$(who -um | awk -F " " '{print $7}') +if ps --pid $(ps --pid $pid -o ppid=) -o cmd= | grep -q telnetd +then + echo "Please configure telnet settings via ssh or console." + exit 1 +fi + +usage() { + echo "Usage: $0 enable " + echo " $0 disable" + echo " $0 allow-root {true|false}" + exit 1; +} + +allow-root() { + case "$1" in + true) ;; + false) ;; + *) echo "Expect true or false" + usage ;; + esac + + sudo sed -i -e '/^# Pseudo-terminal (telnet)/,$d' /etc/securetty + + if [ $1 = "false" ]; then + return + fi + + sudo sh -c "cat >>/etc/securetty" <