You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
878 B
38 lines
878 B
![]()
19 years ago
|
#!/bin/sh /etc/rc.common
|
||
![]()
14 years ago
|
# Copyright (C) 2006-2011 OpenWrt.org
|
||
![]()
13 years ago
|
|
||
![]()
18 years ago
|
START=50
|
||
![]()
19 years ago
|
|
||
![]()
15 years ago
|
has_root_pwd() {
|
||
|
local pwd=$([ -f "$1" ] && cat "$1")
|
||
|
pwd="${pwd#*root:}"
|
||
|
pwd="${pwd%%:*}"
|
||
|
|
||
![]()
13 years ago
|
test -n "${pwd#[\!x]}"
|
||
![]()
15 years ago
|
}
|
||
|
|
||
![]()
14 years ago
|
get_root_home() {
|
||
|
local homedir=$([ -f "$1" ] && cat "$1")
|
||
|
homedir="${homedir#*:*:0:0:*:}"
|
||
|
|
||
|
echo "${homedir%%:*}"
|
||
|
}
|
||
|
|
||
![]()
14 years ago
|
has_ssh_pubkey() {
|
||
![]()
14 years ago
|
( /etc/init.d/dropbear enabled 2> /dev/null && grep -qs "^ssh-" /etc/dropbear/authorized_keys ) || \
|
||
![]()
14 years ago
|
( /etc/init.d/sshd enabled 2> /dev/null && grep -qs "^ssh-" "$(get_root_home /etc/passwd)"/.ssh/authorized_keys )
|
||
![]()
14 years ago
|
}
|
||
|
|
||
![]()
19 years ago
|
start() {
|
||
![]()
14 years ago
|
if ( ! has_ssh_pubkey && \
|
||
|
! has_root_pwd /etc/passwd && ! has_root_pwd /etc/shadow ) || \
|
||
![]()
14 years ago
|
( ! /etc/init.d/dropbear enabled 2> /dev/null && ! /etc/init.d/sshd enabled 2> /dev/null );
|
||
![]()
15 years ago
|
then
|
||
![]()
13 years ago
|
service_start /usr/sbin/telnetd -l /bin/login.sh
|
||
![]()
18 years ago
|
fi
|
||
![]()
19 years ago
|
}
|
||
|
|
||
|
stop() {
|
||
![]()
13 years ago
|
service_stop /usr/sbin/telnetd
|
||
![]()
19 years ago
|
}
|