2006-10-04 20:05:48 +00:00
|
|
|
#!/bin/sh /etc/rc.common
|
2010-07-18 18:36:12 +00:00
|
|
|
# Copyright (C) 2006-2010 OpenWrt.org
|
2007-05-10 10:38:53 +00:00
|
|
|
START=50
|
2006-06-27 00:36:13 +00:00
|
|
|
|
2010-07-18 18:36:12 +00:00
|
|
|
has_root_pwd() {
|
|
|
|
local pwd=$([ -f "$1" ] && cat "$1")
|
|
|
|
pwd="${pwd#*root:}"
|
|
|
|
pwd="${pwd%%:*}"
|
|
|
|
|
|
|
|
test -n "${pwd#!}"
|
|
|
|
}
|
|
|
|
|
2011-02-02 18:50:50 +00:00
|
|
|
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 )
|
|
|
|
}
|
|
|
|
|
2006-10-04 20:05:48 +00:00
|
|
|
start() {
|
2011-02-02 18:50:50 +00:00
|
|
|
if ( ! has_ssh_pubkey && \
|
|
|
|
! has_root_pwd /etc/passwd && ! has_root_pwd /etc/shadow ) || \
|
2010-07-18 18:36:12 +00:00
|
|
|
( [ ! -x /usr/sbin/dropbear ] && [ ! -x /usr/sbin/sshd ] );
|
|
|
|
then
|
2009-04-04 09:35:55 +00:00
|
|
|
telnetd -l /bin/login.sh
|
2007-01-08 21:31:29 +00:00
|
|
|
fi
|
2006-10-04 20:05:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
2010-07-18 18:36:12 +00:00
|
|
|
killall telnetd 2>/dev/null
|
2006-10-04 20:05:48 +00:00
|
|
|
}
|
2010-07-18 18:36:12 +00:00
|
|
|
|