Просмотр исходного кода

Add mac-telnet - a layer 2 Telnet/SSH server useful to access bricked devices

This package adds the mac-telnet server, client, ping and discovery utilities.
See https://github.com/aouyar/MAC-Telnet for details.

This package uses the fork from https://github.com/jow-/MAC-Telnet as source,
the code there has a number of bugfixes and results in smaller binaries since
most core functionality has been ported to libubox facilities provided by
OpenWrt.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Jo-Philipp Wich 10 лет назад
Родитель
Сommit
6d3990cbcf
3 измененных файлов: 160 добавлений и 0 удалений
  1. 71
    0
      net/mac-telnet/Makefile
  2. 9
    0
      net/mac-telnet/files/mactelnet.config
  3. 80
    0
      net/mac-telnet/files/mactelnet.init

+ 71
- 0
net/mac-telnet/Makefile Просмотреть файл

@@ -0,0 +1,71 @@
1
+#
2
+# Copyright (C) 2014 OpenWrt.org
3
+#
4
+
5
+include $(TOPDIR)/rules.mk
6
+
7
+PKG_NAME:=mac-telnet
8
+PKG_VERSION:=2014-09-03
9
+PKG_RELEASE:=$(PKG_SOURCE_VERSION)
10
+
11
+PKG_SOURCE_PROTO:=git
12
+PKG_SOURCE_URL:=https://github.com/jow-/MAC-Telnet.git
13
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
14
+PKG_SOURCE_VERSION:=9a8bf5c242c6b0336c2f257aa67d2240454ba4b0
15
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
16
+
17
+PKG_LICENSE:=GPL-2.0+
18
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
19
+
20
+include $(INCLUDE_DIR)/package.mk
21
+
22
+TARGET_CFLAGS += -ffunction-sections -fdata-sections $(if $(CONFIG_MACTELNET_PLAIN_SUPPORT),-DTELNET_SUPPORT)
23
+TARGET_LDFLAGS += -Wl,--gc-sections
24
+
25
+# 1: name
26
+# 2: executable
27
+define BuildPlugin
28
+  define Package/mac-telnet-$(1)
29
+    SECTION:=net
30
+    CATEGORY:=Network
31
+    DEPENDS:=+libubox
32
+    TITLE:=MAC-Telnet / MAC-SSH $(1)
33
+    URL:=https://github.com/jow-/MAC-Telnet
34
+  endef
35
+
36
+  define Package/mac-telnet-$(1)/description
37
+    Open source MAC Telnet client and server utilities for connecting to
38
+    Mikrotik RouterOS routers and Linux machines via MAC address.
39
+  endef
40
+
41
+  define Package/mac-telnet-$(1)/install
42
+	$(INSTALL_DIR) $$(1)/usr/sbin
43
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(2) $$(1)/usr/sbin/
44
+	$(call Package/mac-telnet-$(1)/install-extra)
45
+  endef
46
+
47
+  $$(eval $$(call BuildPackage,mac-telnet-$(1)))
48
+endef
49
+
50
+define Package/mac-telnet-server/config
51
+  config MACTELNET_PLAIN_SUPPORT
52
+	bool "Include support for plain telnet connections"
53
+	depends on PACKAGE_mac-telnet-server
54
+        default y
55
+	help
56
+	  Disable this option to only support SSH logins to the
57
+	  MAC-Telnet server.
58
+endef
59
+
60
+define Package/mac-telnet-server/install-extra
61
+	$(INSTALL_DIR) $$(1)/etc/init.d
62
+	$(INSTALL_BIN) ./files/mactelnet.init $$(1)/etc/init.d/mactelnet
63
+	$(INSTALL_DIR) $$(1)/etc/config
64
+	$(INSTALL_DATE) ./files/mactelnet.config $$(1)/etc/config/mactelnet
65
+endef
66
+
67
+
68
+$(eval $(call BuildPlugin,server,mactelnetd))
69
+$(eval $(call BuildPlugin,client,mactelnet))
70
+$(eval $(call BuildPlugin,ping,macping))
71
+$(eval $(call BuildPlugin,discover,mndp))

+ 9
- 0
net/mac-telnet/files/mactelnet.config Просмотреть файл

@@ -0,0 +1,9 @@
1
+# Global settings for MAC-Telnet daemon
2
+config mactelnetd
3
+	option sshmode '0'
4
+	list interface 'lan'
5
+
6
+# Define a MAC-Telnet login, multiple login sections allowed
7
+config login
8
+	option username 'root'
9
+	option password 'secret'

+ 80
- 0
net/mac-telnet/files/mactelnet.init Просмотреть файл

@@ -0,0 +1,80 @@
1
+#!/bin/sh /etc/rc.common
2
+# Copyright (C) 2014 OpenWrt.org
3
+
4
+START=60
5
+
6
+USE_PROCD=1
7
+
8
+PROG=/usr/sbin/mactelnetd
9
+USERS=/var/etc/mactelnetd.users
10
+SSHMODE=0
11
+
12
+add_account() {
13
+	local cfg="$1"
14
+	local user pass
15
+
16
+	[ $SSHMODE -eq 0 ] || {
17
+		[ -n "$already_warned" ] || {
18
+			echo "mactelnet.$cfg: login sections ignored in SSH mode" >&1
19
+			already_warned=1
20
+		}
21
+		return
22
+	}
23
+
24
+	config_get username "$cfg" username
25
+	config_get password "$cfg" password
26
+
27
+	[ -n "$username" ] || {
28
+		echo "mactelnet.$cfg: username missing" >&2
29
+		return
30
+	}
31
+
32
+	[ -n "$password" ] || {
33
+		echo "mactelnet.$cfg: password missing" >&2
34
+		return
35
+	}
36
+
37
+	echo "$username:$password" >> $USERS
38
+}
39
+
40
+add_interface() {
41
+	local iface="$1"
42
+	local device
43
+
44
+	[ -n "$iface" ] || return
45
+
46
+	if network_get_physdev device "$iface"; then
47
+		procd_append_param command -i "$device"
48
+	fi
49
+
50
+	procd_add_reload_interface_trigger "$iface"
51
+}
52
+
53
+add_globals() {
54
+	local cfg="$1"
55
+
56
+	config_get_bool SSHMODE "$cfg" sshmode 0
57
+	[ $SSHMODE -eq 0 ] || procd_append_param command -S
58
+
59
+	config_list_foreach "$cfg" interface add_interface
60
+}
61
+
62
+start_service() {
63
+	. /lib/functions/network.sh
64
+
65
+	procd_open_instance
66
+
67
+	procd_add_reload_trigger mactelnet
68
+	procd_set_param command "$PROG" -f
69
+
70
+	config_load mactelnet
71
+	config_foreach add_globals mactelnetd
72
+
73
+	[ $SSHMODE -eq 1 ] || {
74
+		rm -f $USERS
75
+		config_foreach add_account login
76
+	}
77
+
78
+	procd_close_instance
79
+}
80
+