busybox 1.9.1: add files needed for openwrt-style 'telnet failsafe login'
authorKoen Kooi <koen@openembedded.org>
Mon, 24 Mar 2008 17:57:00 +0000 (17:57 +0000)
committerKoen Kooi <koen@openembedded.org>
Mon, 24 Mar 2008 17:57:00 +0000 (17:57 +0000)
* the files aren't used in the recipe yet, just there for reference

packages/busybox/busybox-1.9.1/defconfig
packages/busybox/files/50telnet [new file with mode: 0644]
packages/busybox/files/login.failsafe [new file with mode: 0644]

index 770ef6e..33d3091 100644 (file)
@@ -633,7 +633,7 @@ CONFIG_ROUTE=y
 CONFIG_TELNET=y
 # CONFIG_FEATURE_TELNET_TTYPE is not set
 CONFIG_FEATURE_TELNET_AUTOLOGIN=y
-# CONFIG_TELNETD is not set
+CONFIG_TELNETD=y
 # CONFIG_FEATURE_TELNETD_STANDALONE is not set
 CONFIG_TFTP=y
 CONFIG_FEATURE_TFTP_GET=y
diff --git a/packages/busybox/files/50telnet b/packages/busybox/files/50telnet
new file mode 100644 (file)
index 0000000..3fb4a90
--- /dev/null
@@ -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 (file)
index 0000000..e7c12a2
--- /dev/null
@@ -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