aredn/patches/704-enable-telnet.patch

120 lines
3.6 KiB
Diff
Raw Normal View History

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
@@ -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() {
Index: openwrt/package/utils/busybox/Config-defaults.in
===================================================================
--- openwrt.orig/package/utils/busybox/Config-defaults.in
+++ openwrt/package/utils/busybox/Config-defaults.in
@@ -2479,10 +2479,10 @@ config BUSYBOX_DEFAULT_UDPSVD
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
@@ -2491,10 +2491,10 @@ config BUSYBOX_DEFAULT_FEATURE_TELNET_WI
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
Index: openwrt/package/utils/busybox/Makefile
===================================================================
--- openwrt.orig/package/utils/busybox/Makefile
+++ openwrt/package/utils/busybox/Makefile
@@ -110,6 +110,8 @@ define Package/busybox/install
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
Index: openwrt/package/utils/busybox/files/telnet
===================================================================
--- /dev/null
+++ openwrt/package/utils/busybox/files/telnet
@@ -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
+}
Index: openwrt/package/utils/busybox/files/login.sh
===================================================================
--- /dev/null
+++ openwrt/package/utils/busybox/files/login.sh
@@ -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