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