#! /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 parent_proc_id=`ps -fp $$ | tail -1 | awk '{print $3}'` while [ "$parent_proc_id" != "1" ] do proc_id=$parent_proc_id parent_proc_id=`ps -fp $proc_id | tail -1 | awk '{print $3}'` done if ps $proc_id | 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" <