[package] base-files, busybox: fix 22279, simplify code and get rid of awk
[openwrt/svn-archive/archive.git] / package / busybox / files / telnet
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2006-2010 OpenWrt.org
3 START=50
4
5 has_root_pwd() {
6 local pwd=$([ -f "$1" ] && cat "$1")
7 pwd="${pwd#*root:}"
8 pwd="${pwd%%:*}"
9
10 test -n "${pwd#!}"
11 }
12
13 start() {
14 if ( ! has_root_pwd /etc/passwd && ! has_root_pwd /etc/shadow ) || \
15 ( [ ! -x /usr/sbin/dropbear ] && [ ! -x /usr/sbin/sshd ] );
16 then
17 telnetd -l /bin/login.sh
18 fi
19 }
20
21 stop() {
22 killall telnetd 2>/dev/null
23 }
24