2018-08-23 18:33:06 -06:00
|
|
|
Index: openwrt/package/base-files/files/lib/preinit/99_10_failsafe_login
|
|
|
|
===================================================================
|
|
|
|
--- openwrt.orig/package/base-files/files/lib/preinit/99_10_failsafe_login
|
|
|
|
+++ openwrt/package/base-files/files/lib/preinit/99_10_failsafe_login
|
2018-03-31 09:39:51 -06:00
|
|
|
@@ -3,8 +3,7 @@
|
|
|
|
# Copyright (C) 2010 Vertical Communications
|
|
|
|
|
|
|
|
failsafe_netlogin () {
|
|
|
|
- dropbearkey -t rsa -s 1024 -f /tmp/dropbear_failsafe_host_key
|
|
|
|
- dropbear -r /tmp/dropbear_failsafe_host_key <> /dev/null 2>&1
|
|
|
|
+ telnetd -l /bin/login.sh <> /dev/null 2>&1
|
|
|
|
}
|
|
|
|
|
|
|
|
failsafe_shell() {
|
2018-08-23 18:33:06 -06:00
|
|
|
Index: openwrt/package/utils/busybox/Config-defaults.in
|
|
|
|
===================================================================
|
|
|
|
--- openwrt.orig/package/utils/busybox/Config-defaults.in
|
|
|
|
+++ openwrt/package/utils/busybox/Config-defaults.in
|
|
|
|
@@ -2400,10 +2400,10 @@ config BUSYBOX_DEFAULT_UDPSVD
|
2018-03-31 09:39:51 -06:00
|
|
|
default n
|
|
|
|
config BUSYBOX_DEFAULT_TELNET
|
|
|
|
bool
|
|
|
|
- default n
|
|
|
|
+ default y
|
|
|
|
config BUSYBOX_DEFAULT_FEATURE_TELNET_TTYPE
|
|
|
|
bool
|
|
|
|
- default n
|
|
|
|
+ default y
|
|
|
|
config BUSYBOX_DEFAULT_FEATURE_TELNET_AUTOLOGIN
|
|
|
|
bool
|
|
|
|
default n
|
2018-08-23 18:33:06 -06:00
|
|
|
@@ -2412,10 +2412,10 @@ config BUSYBOX_DEFAULT_FEATURE_TELNET_WI
|
2018-03-31 09:39:51 -06:00
|
|
|
default n
|
|
|
|
config BUSYBOX_DEFAULT_TELNETD
|
|
|
|
bool
|
|
|
|
- default n
|
|
|
|
+ default y
|
|
|
|
config BUSYBOX_DEFAULT_FEATURE_TELNETD_STANDALONE
|
|
|
|
bool
|
|
|
|
- default n
|
|
|
|
+ default y
|
|
|
|
config BUSYBOX_DEFAULT_FEATURE_TELNETD_INETD_WAIT
|
|
|
|
bool
|
|
|
|
default n
|
2018-08-23 18:33:06 -06:00
|
|
|
Index: openwrt/package/utils/busybox/Makefile
|
|
|
|
===================================================================
|
|
|
|
--- openwrt.orig/package/utils/busybox/Makefile
|
|
|
|
+++ openwrt/package/utils/busybox/Makefile
|
|
|
|
@@ -108,6 +108,8 @@ define Package/busybox/install
|
2018-03-31 09:39:51 -06:00
|
|
|
ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_CROND),)
|
|
|
|
$(INSTALL_BIN) ./files/cron $(1)/etc/init.d/cron
|
|
|
|
endif
|
|
|
|
+ $(INSTALL_BIN) ./files/telnet $(1)/etc/init.d/telnet
|
|
|
|
+ $(INSTALL_BIN) ./files/login.sh $(1)/bin/login.sh
|
|
|
|
ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_NTPD),)
|
|
|
|
$(INSTALL_BIN) ./files/sysntpd $(1)/etc/init.d/sysntpd
|
|
|
|
$(INSTALL_BIN) ./files/ntpd-hotplug $(1)/usr/sbin/ntpd-hotplug
|
2018-08-23 18:33:06 -06:00
|
|
|
Index: openwrt/package/utils/busybox/files/telnet
|
|
|
|
===================================================================
|
|
|
|
--- /dev/null
|
|
|
|
+++ openwrt/package/utils/busybox/files/telnet
|
2018-03-31 09:39:51 -06:00
|
|
|
@@ -0,0 +1,33 @@
|
|
|
|
+#!/bin/sh /etc/rc.common
|
|
|
|
+# Copyright (C) 2006-2011 OpenWrt.org
|
|
|
|
+
|
|
|
|
+START=50
|
|
|
|
+
|
|
|
|
+USE_PROCD=1
|
|
|
|
+PROG=/usr/sbin/telnetd
|
|
|
|
+
|
|
|
|
+has_root_pwd() {
|
|
|
|
+ local pwd=$([ -f "$1" ] && cat "$1")
|
|
|
|
+ pwd="${pwd#*root:}"
|
|
|
|
+ pwd="${pwd%%:*}"
|
|
|
|
+
|
|
|
|
+ test -n "${pwd#[\!x]}"
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+get_root_home() {
|
|
|
|
+ local homedir=$([ -f "$1" ] && cat "$1")
|
|
|
|
+ homedir="${homedir#*:*:0:0:*:}"
|
|
|
|
+
|
|
|
|
+ echo "${homedir%%:*}"
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+has_ssh_pubkey() {
|
|
|
|
+ ( /etc/init.d/dropbear enabled 2> /dev/null && grep -qs "^ssh-" /etc/dropbear/authorized_keys ) || \
|
|
|
|
+ ( /etc/init.d/sshd enabled 2> /dev/null && grep -qs "^ssh-" "$(get_root_home /etc/passwd)"/.ssh/authorized_keys )
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+start_service() {
|
|
|
|
+ procd_open_instance
|
|
|
|
+ procd_set_param command "$PROG" -F -l /bin/login.sh
|
|
|
|
+ procd_close_instance
|
|
|
|
+}
|
2018-08-23 18:33:06 -06:00
|
|
|
Index: openwrt/package/utils/busybox/files/login.sh
|
|
|
|
===================================================================
|
|
|
|
--- /dev/null
|
|
|
|
+++ openwrt/package/utils/busybox/files/login.sh
|
2018-03-31 09:39:51 -06:00
|
|
|
@@ -0,0 +1,19 @@
|
|
|
|
+#!/bin/sh
|
|
|
|
+# Copyright (C) 2006-2011 OpenWrt.org
|
|
|
|
+
|
|
|
|
+if ( ! grep -qs '^root:[!x]\?:' /etc/shadow || \
|
|
|
|
+ ! grep -qs '^root:[!x]\?:' /etc/passwd ) && \
|
|
|
|
+ [ -z "$FAILSAFE" ]
|
|
|
|
+then
|
|
|
|
+ echo "WARNING: passwords are sent unencrypted."
|
|
|
|
+ busybox login
|
|
|
|
+else
|
|
|
|
+cat << EOF
|
|
|
|
+ === IMPORTANT ============================
|
|
|
|
+ Use 'passwd' to set your login password
|
|
|
|
+ this will enable telnet login with password
|
|
|
|
+ ------------------------------------------
|
|
|
|
+EOF
|
|
|
|
+
|
|
|
|
+exec /bin/ash --login
|
|
|
|
+fi
|