BCMA - Reorder SPROM fill
[openwrt.git] / package / busybox / files / telnet
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2006-2011 OpenWrt.org
3
4 START=50
5
6 has_root_pwd() {
7 local pwd=$([ -f "$1" ] && cat "$1")
8 pwd="${pwd#*root:}"
9 pwd="${pwd%%:*}"
10
11 test -n "${pwd#[\!x]}"
12 }
13
14 get_root_home() {
15 local homedir=$([ -f "$1" ] && cat "$1")
16 homedir="${homedir#*:*:0:0:*:}"
17
18 echo "${homedir%%:*}"
19 }
20
21 has_ssh_pubkey() {
22 ( /etc/init.d/dropbear enabled 2> /dev/null && grep -qs "^ssh-" /etc/dropbear/authorized_keys ) || \
23 ( /etc/init.d/sshd enabled 2> /dev/null && grep -qs "^ssh-" "$(get_root_home /etc/passwd)"/.ssh/authorized_keys )
24 }
25
26 start() {
27 if ( ! has_ssh_pubkey && \
28 ! has_root_pwd /etc/passwd && ! has_root_pwd /etc/shadow ) || \
29 ( ! /etc/init.d/dropbear enabled 2> /dev/null && ! /etc/init.d/sshd enabled 2> /dev/null );
30 then
31 service_start /usr/sbin/telnetd -l /bin/login.sh
32 fi
33 }
34
35 stop() {
36 service_stop /usr/sbin/telnetd
37 }
This page took 0.046868 seconds and 5 git commands to generate.