2006-10-04 22:05:48 +02:00
|
|
|
#!/bin/sh /etc/rc.common
|
2011-02-07 22:45:02 +01:00
|
|
|
# Copyright (C) 2006-2011 OpenWrt.org
|
2011-11-07 23:58:39 +01:00
|
|
|
|
2007-05-10 12:38:53 +02:00
|
|
|
START=50
|
2013-09-23 23:58:36 +02:00
|
|
|
|
2013-07-11 19:00:26 +02:00
|
|
|
USE_PROCD=1
|
|
|
|
PROG=/usr/sbin/telnetd
|
2006-06-27 02:36:13 +02:00
|
|
|
|
2010-07-18 20:36:12 +02:00
|
|
|
has_root_pwd() {
|
|
|
|
local pwd=$([ -f "$1" ] && cat "$1")
|
|
|
|
pwd="${pwd#*root:}"
|
|
|
|
pwd="${pwd%%:*}"
|
|
|
|
|
2011-11-16 14:17:35 +01:00
|
|
|
test -n "${pwd#[\!x]}"
|
2010-07-18 20:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-02-08 02:01:17 +01:00
|
|
|
get_root_home() {
|
|
|
|
local homedir=$([ -f "$1" ] && cat "$1")
|
|
|
|
homedir="${homedir#*:*:0:0:*:}"
|
|
|
|
|
|
|
|
echo "${homedir%%:*}"
|
|
|
|
}
|
|
|
|
|
2011-02-02 19:50:50 +01:00
|
|
|
has_ssh_pubkey() {
|
2011-02-07 22:45:02 +01:00
|
|
|
( /etc/init.d/dropbear enabled 2> /dev/null && grep -qs "^ssh-" /etc/dropbear/authorized_keys ) || \
|
2011-02-08 02:01:17 +01:00
|
|
|
( /etc/init.d/sshd enabled 2> /dev/null && grep -qs "^ssh-" "$(get_root_home /etc/passwd)"/.ssh/authorized_keys )
|
2011-02-02 19:50:50 +01:00
|
|
|
}
|
|
|
|
|
2013-07-11 19:00:26 +02:00
|
|
|
start_service() {
|
2011-02-02 19:50:50 +01:00
|
|
|
if ( ! has_ssh_pubkey && \
|
|
|
|
! has_root_pwd /etc/passwd && ! has_root_pwd /etc/shadow ) || \
|
2011-02-07 22:45:02 +01:00
|
|
|
( ! /etc/init.d/dropbear enabled 2> /dev/null && ! /etc/init.d/sshd enabled 2> /dev/null );
|
2010-07-18 20:36:12 +02:00
|
|
|
then
|
2013-09-23 23:58:36 +02:00
|
|
|
procd_open_instance
|
|
|
|
procd_set_param command "$PROG" -F -l /bin/login.sh
|
2013-07-11 19:00:26 +02:00
|
|
|
procd_close_instance
|
2007-01-08 22:31:29 +01:00
|
|
|
fi
|
2006-10-04 22:05:48 +02:00
|
|
|
}
|