From: Vasilis Tsiligiannis Date: Wed, 2 Feb 2011 18:50:50 +0000 (+0000) Subject: busybox: Disable telnet if an SSH public key for root exists (#8760) X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=b435f9d603c5ba47abf331b4104bfe2dd7dbfd54;p=openwrt%2Fstaging%2Fthess.git busybox: Disable telnet if an SSH public key for root exists (#8760) SVN-Revision: 25317 --- diff --git a/package/busybox/files/telnet b/package/busybox/files/telnet index b8823379b9..a1e17275a3 100755 --- a/package/busybox/files/telnet +++ b/package/busybox/files/telnet @@ -10,8 +10,14 @@ has_root_pwd() { test -n "${pwd#!}" } +has_ssh_pubkey() { + ( test -x /usr/sbin/dropbear && grep -qs "^ssh-" /etc/dropbear/authorized_keys ) || \ + ( test -x /usr/sbin/sshd && grep -qs "^ssh-" /root/.ssh/authorized_keys ) +} + start() { - if ( ! has_root_pwd /etc/passwd && ! has_root_pwd /etc/shadow ) || \ + if ( ! has_ssh_pubkey && \ + ! has_root_pwd /etc/passwd && ! has_root_pwd /etc/shadow ) || \ ( [ ! -x /usr/sbin/dropbear ] && [ ! -x /usr/sbin/sshd ] ); then telnetd -l /bin/login.sh