diff options
Diffstat (limited to 'packages/busybox/files')
-rw-r--r-- | packages/busybox/files/50telnet | 16 | ||||
-rw-r--r-- | packages/busybox/files/login.failsafe | 19 |
2 files changed, 35 insertions, 0 deletions
diff --git a/packages/busybox/files/50telnet b/packages/busybox/files/50telnet new file mode 100644 index 0000000000..3fb4a90494 --- /dev/null +++ b/packages/busybox/files/50telnet @@ -0,0 +1,16 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2008 Koen Kooi + +# This starts telnetd if the password for 'root' is empty. This is needed for devices without a screen or serial console (wifi router, NAS, etc). + +start() { + if awk -F: '/^root:/ && ($2 != "") && ($2 !~ /\!/) {exit 1}' /etc/passwd 2>/dev/null + then + telnetd -l /bin/login.failsafe + fi +} + +stop() { + killall telnetd +} diff --git a/packages/busybox/files/login.failsafe b/packages/busybox/files/login.failsafe new file mode 100644 index 0000000000..e7c12a27fb --- /dev/null +++ b/packages/busybox/files/login.failsafe @@ -0,0 +1,19 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2008 Koen Kooi + +grep '^root:[^!]' /etc/passwd >&- 2>&- +[ "$?" = "0" ] && +{ + echo "Login failed." + exit 0 +} || { +cat << EOF + === IMPORTANT ============================ + Use 'passwd' to set your login password + this will disable telnet and enable SSH + ------------------------------------------ +EOF +} + +exec /bin/sh --login |