2022-04-24 16:14:10 -06:00
|
|
|
--- a/package/base-files/files/lib/preinit/99_10_failsafe_login
|
|
|
|
+++ b/package/base-files/files/lib/preinit/99_10_failsafe_login
|
2022-12-22 13:22:49 -07:00
|
|
|
@@ -1,6 +1,10 @@
|
|
|
|
# Copyright (C) 2006-2015 OpenWrt.org
|
2018-03-31 09:39:51 -06:00
|
|
|
# Copyright (C) 2010 Vertical Communications
|
|
|
|
|
2022-12-22 13:22:49 -07:00
|
|
|
+failsafe_netlogin () {
|
2018-03-31 09:39:51 -06:00
|
|
|
+ telnetd -l /bin/login.sh <> /dev/null 2>&1
|
2022-12-22 13:22:49 -07:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
failsafe_shell() {
|
|
|
|
local console="$(sed -e 's/ /\n/g' /proc/cmdline | grep '^console=' | head -1 | sed -e 's/^console=//' -e 's/,.*//')"
|
|
|
|
[ -n "$console" ] || console=console
|
|
|
|
@@ -11,4 +15,5 @@ failsafe_shell() {
|
|
|
|
done &
|
2018-03-31 09:39:51 -06:00
|
|
|
}
|
|
|
|
|
2022-12-22 13:22:49 -07:00
|
|
|
+boot_hook_add failsafe failsafe_netlogin
|
|
|
|
boot_hook_add failsafe failsafe_shell
|
2022-04-24 16:14:10 -06:00
|
|
|
--- a/package/utils/busybox/Config-defaults.in
|
|
|
|
+++ b/package/utils/busybox/Config-defaults.in
|
2022-12-22 13:22:49 -07:00
|
|
|
@@ -2552,10 +2552,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
|
2022-12-22 13:22:49 -07:00
|
|
|
@@ -2564,10 +2564,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
|
2022-12-22 13:22:49 -07:00
|
|
|
config BUSYBOX_DEFAULT_FEATURE_TELNETD_PORT_DEFAULT
|
|
|
|
int
|
|
|
|
default 23
|
2022-04-24 16:14:10 -06:00
|
|
|
--- a/package/utils/busybox/Makefile
|
|
|
|
+++ b/package/utils/busybox/Makefile
|
2022-12-22 13:22:49 -07:00
|
|
|
@@ -148,6 +148,8 @@ ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_C
|
2018-03-31 09:39:51 -06:00
|
|
|
$(INSTALL_BIN) ./files/cron $(1)/etc/init.d/cron
|
2022-12-22 13:22:49 -07:00
|
|
|
$(INSTALL_DIR) $(1)/etc/crontabs
|
2018-03-31 09:39:51 -06:00
|
|
|
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
|
|
|
--- /dev/null
|
2022-04-24 16:14:10 -06:00
|
|
|
+++ b/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
|
|
|
--- /dev/null
|
2022-04-24 16:14:10 -06:00
|
|
|
+++ b/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
|