mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-01 08:03:56 +08:00
🌴 Sync 2026-03-05 23:51:42
This commit is contained in:
1 parent
97c049ed0a
commit
0acff03804
14253 files changed
+3893239
No files matched your search
@@ -0,0 +1,55 @@
|
||||
#
|
||||
# Copyright (C) 2016 Openwrt.org
|
||||
# Copyright (C) 2021 ImmortalWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=minieap
|
||||
PKG_VERSION:=0.93
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://codeload.github.com/updateing/minieap/tar.gz/v$(PKG_VERSION)?
|
||||
PKG_HASH:=skip
|
||||
|
||||
PKG_LICENSE:=GPL-3.0
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/minieap
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Campus Network
|
||||
TITLE:=Extendable 802.1x client
|
||||
URL:=https://github.com/updateing/minieap
|
||||
endef
|
||||
|
||||
define Package/minieap/description
|
||||
Extendable 802.1x client with Ruijie v3 (v4) plugin.
|
||||
endef
|
||||
|
||||
define Package/minieap/conffiles
|
||||
/etc/minieap.conf
|
||||
endef
|
||||
|
||||
MAKE_FLAGS += ENABLE_ICONV=false ENABLE_GBCONV=true
|
||||
|
||||
define Package/minieap/install
|
||||
$(INSTALL_DIR) $(1)/etc
|
||||
$(INSTALL_CONF) $(PKG_BUILD_DIR)/minieap.conf $(1)/etc/minieap.conf
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/minieap $(1)/usr/sbin/
|
||||
$(INSTALL_DIR) $(1)/lib/netifd
|
||||
$(INSTALL_BIN) $(CURDIR)/files/minieap.script $(1)/lib/netifd/minieap.script
|
||||
$(INSTALL_DIR) $(1)/lib/netifd/proto
|
||||
$(INSTALL_BIN) $(CURDIR)/files/minieap.proto $(1)/lib/netifd/proto/minieap.sh
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,minieap))
|
||||
@@ -0,0 +1,121 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
. /lib/functions/network.sh
|
||||
. ../netifd-proto.sh
|
||||
init_proto "$@"
|
||||
|
||||
append_setting() {
|
||||
local s="$1"
|
||||
[ -n "$s" ] && \
|
||||
echo "$s" >>"$config_file"
|
||||
}
|
||||
|
||||
append_setting_list() {
|
||||
[ -n "$1" ] && append_setting "$3=$1"
|
||||
}
|
||||
|
||||
proto_minieap_init_config() {
|
||||
lasterror=1
|
||||
|
||||
proto_config_add_string username
|
||||
proto_config_add_string password
|
||||
#proto_config_add_string nic
|
||||
proto_config_add_array 'module:list(string)'
|
||||
#proto_config_add_int daemonize #=0
|
||||
#proto_config_add_string if_impl #=sockraw
|
||||
proto_config_add_int max_fail
|
||||
proto_config_add_int max_retries
|
||||
proto_config_add_boolean no_auto_reauth
|
||||
proto_config_add_int wait_after_fail
|
||||
proto_config_add_int stage_timeout
|
||||
#proto_config_add_string proxy_lan_iface
|
||||
proto_config_add_int auth_round
|
||||
#proto_config_add_string pid_file #=none
|
||||
proto_config_add_string log_file
|
||||
#proto_config_add_string script #=/lib/netifd/minieap.script
|
||||
|
||||
#rjv3 plugin
|
||||
proto_config_add_int heartbeat
|
||||
proto_config_add_int eap_bcast_addr
|
||||
proto_config_add_int dhcp_type
|
||||
proto_config_add_array 'rj_option:list(string)'
|
||||
proto_config_add_string service
|
||||
proto_config_add_string version_str
|
||||
proto_config_add_string dhcp_script
|
||||
proto_config_add_string 'fake_dns1:ip4addr'
|
||||
proto_config_add_string 'fake_dns2:ip4addr'
|
||||
proto_config_add_string fake_serial
|
||||
proto_config_add_int max_dhcp_count
|
||||
}
|
||||
|
||||
proto_minieap_setup() {
|
||||
local config="$1"
|
||||
local iface="$2"
|
||||
|
||||
local username password module max_fail max_retries no_auto_reauth wait_after_fail stage_timeout auth_round log_file heartbeat eap_bcast_addr dhcp_type rj_option service version_str dhcp_script fake_dns1 fake_dns2 fake_serial max_dhcp_count
|
||||
json_get_vars username password max_fail max_retries no_auto_reauth wait_after_fail stage_timeout auth_round log_file heartbeat eap_bcast_addr dhcp_type service version_str dhcp_script fake_dns1 fake_dns2 fake_serial max_dhcp_count
|
||||
|
||||
[ -z "$username" -o -z "$password" ] && {
|
||||
echo "minieap: Missing username or password." >&2
|
||||
proto_notify_error "$config" "MISSING_USER_OR_PASS"
|
||||
proto_block_restart "$config"
|
||||
return
|
||||
}
|
||||
|
||||
config_dir='/var/etc/minieap'
|
||||
config_file="${config_dir}/${config}.conf"
|
||||
|
||||
[ -d $config_dir ] || {
|
||||
mkdir -p $config_dir
|
||||
chmod 0755 $config_dir
|
||||
}
|
||||
>$config_file
|
||||
|
||||
append_setting "username=$username"
|
||||
append_setting "password=$password"
|
||||
append_setting "nic=$iface"
|
||||
json_for_each_item append_setting_list module module
|
||||
append_setting "daemonize=0"
|
||||
append_setting "if-impl=sockraw"
|
||||
append_setting ${max_fail:+max-fail=$max_fail}
|
||||
append_setting ${max_retries:+max-retries=$max_retries}
|
||||
append_setting ${no_auto_reauth:+no-auto-reauth=$no_auto_reauth}
|
||||
append_setting ${wait_after_fail:+wait-after-fail=$wait_after_fail}
|
||||
append_setting ${stage_timeout:+stage-timeout=$stage_timeout}
|
||||
append_setting ${auth_round:+auth-round=$auth_round}
|
||||
append_setting "pid-file=none"
|
||||
append_setting ${log_file:+log-file="$log_file"}
|
||||
append_setting "script=/lib/netifd/minieap.script"
|
||||
|
||||
append_setting ${heartbeat:+heartbeat=$heartbeat}
|
||||
append_setting ${eap_bcast_addr:+eap-bcast-addr=$eap_bcast_addr}
|
||||
append_setting ${dhcp_type:+dhcp-type=$dhcp_type}
|
||||
append_setting ${dhcp_script:+dhcp-script="$dhcp_script"}
|
||||
json_for_each_item append_setting_list rj_option 'rj-option'
|
||||
append_setting ${service:+service="$service"}
|
||||
append_setting ${version_str:+version-str="$version_str"}
|
||||
append_setting ${fake_dns1:+fake-dns1=$fake_dns1}
|
||||
append_setting ${fake_dns2:+fake-dns2=$fake_dns2}
|
||||
append_setting ${fake_serial:+fake-serial="$fake_serial"}
|
||||
append_setting ${max_dhcp_count:+max-dhcp-count=$max_dhcp_count}
|
||||
|
||||
network_is_up wan || (echo "wan is not ready, sleep 10s." >&2; sleep 10)
|
||||
|
||||
proto_export "INTERFACE=$config"
|
||||
proto_run_command "$config" minieap --conf-file "$config_file"
|
||||
}
|
||||
|
||||
proto_minieap_teardown() {
|
||||
local interface="$1"
|
||||
|
||||
[ ${ERROR:-0} -ne 0 ] && {
|
||||
echo "minieap: Program exited with code $ERROR." >&2
|
||||
proto_notify_error "$interface" "EXIT_FAILURE"
|
||||
proto_block_restart "$interface"
|
||||
}
|
||||
|
||||
proto_kill_command "$interface"
|
||||
}
|
||||
|
||||
add_protocol minieap
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
[ -z "$INTERFACE" ] && echo "Error: should be run by minieap" && exit 1
|
||||
|
||||
. /lib/netifd/netifd-proto.sh
|
||||
|
||||
proto_init_update "*" 1
|
||||
proto_send_update "$INTERFACE"
|
||||
@@ -0,0 +1,54 @@
|
||||
From 17fb51ee6a502b6def8c0a8d3a6a9035844d56e4 Mon Sep 17 00:00:00 2001
|
||||
From: Aether Chen <15167799+chenjunyu19@users.noreply.github.com>
|
||||
Date: Sat, 9 Sep 2023 23:35:30 +0800
|
||||
Subject: [PATCH] rjv3: fix heap-use-after-free for dhcp double auth
|
||||
|
||||
---
|
||||
packet_plugin/rjv3/packet_plugin_rjv3.c | 2 +-
|
||||
packet_plugin/rjv3/packet_plugin_rjv3_priv.c | 6 +++---
|
||||
packet_plugin/rjv3/packet_plugin_rjv3_priv.h | 1 +
|
||||
3 files changed, 5 insertions(+), 4 deletions(-)
|
||||
|
||||
--- a/packet_plugin/rjv3/packet_plugin_rjv3.c
|
||||
+++ b/packet_plugin/rjv3/packet_plugin_rjv3.c
|
||||
@@ -230,7 +230,7 @@ static RESULT rjv3_process_success(struc
|
||||
* once the state transition is finished. We need to keep it
|
||||
* in case DHCP fails and we need to start heartbeating.
|
||||
*/
|
||||
- PRIV->last_recv_packet = frame_duplicate(frame);
|
||||
+ PRIV->duplicated_packet = frame_duplicate(frame);
|
||||
system(PRIV->dhcp_script);
|
||||
|
||||
/* Try right after the script ends */
|
||||
--- a/packet_plugin/rjv3/packet_plugin_rjv3_priv.c
|
||||
+++ b/packet_plugin/rjv3/packet_plugin_rjv3_priv.c
|
||||
@@ -504,8 +504,8 @@ void rjv3_start_secondary_auth(void* vth
|
||||
if (IS_FAIL(rjv3_get_dhcp_lease(this, &_tmp_dhcp_lease))) {
|
||||
PRIV->dhcp_count++;
|
||||
if (PRIV->dhcp_count > PRIV->max_dhcp_count) {
|
||||
- rjv3_process_result_prop(PRIV->last_recv_packet); // Loads of texts
|
||||
- free_frame(&PRIV->last_recv_packet); // Duplicated in process_success
|
||||
+ rjv3_process_result_prop(PRIV->duplicated_packet); // Loads of texts
|
||||
+ free_frame(&PRIV->duplicated_packet); // Duplicated in process_success
|
||||
schedule_alarm(1, rjv3_send_keepalive_timed, this);
|
||||
PR_ERR("无法获取 IPv4 地址等信息,将不会进行第二次认证而直接开始心跳");
|
||||
} else {
|
||||
@@ -515,7 +515,7 @@ void rjv3_start_secondary_auth(void* vth
|
||||
return;
|
||||
} else {
|
||||
PR_INFO("DHCP 完成,正在开始第二次认证");
|
||||
- free_frame(&PRIV->last_recv_packet); // Duplicated in process_success
|
||||
+ free_frame(&PRIV->duplicated_packet); // Duplicated in process_success
|
||||
switch_to_state(EAP_STATE_START_SENT, NULL);
|
||||
return;
|
||||
}
|
||||
--- a/packet_plugin/rjv3/packet_plugin_rjv3_priv.h
|
||||
+++ b/packet_plugin/rjv3/packet_plugin_rjv3_priv.h
|
||||
@@ -126,6 +126,7 @@ typedef struct _packet_plugin_rjv3_priv
|
||||
int succ_count;
|
||||
int dhcp_count; // Used in double auth
|
||||
ETH_EAP_FRAME* last_recv_packet;
|
||||
+ ETH_EAP_FRAME* duplicated_packet; // Used in double auth
|
||||
} rjv3_priv;
|
||||
|
||||
RESULT rjv3_append_priv(struct _packet_plugin* this, ETH_EAP_FRAME* frame);
|
||||
@@ -0,0 +1,59 @@
|
||||
From a8f92f43986c7efd1c1f5fcf5826fdcba76d7ad9 Mon Sep 17 00:00:00 2001
|
||||
From: Aether Chen <15167799+chenjunyu19@users.noreply.github.com>
|
||||
Date: Sun, 10 Sep 2023 13:45:20 +0800
|
||||
Subject: [PATCH] misc: fix some memory issues
|
||||
|
||||
---
|
||||
config.c | 4 ++--
|
||||
if_impl/if_impl.c | 2 +-
|
||||
packet_plugin/packet_plugin.c | 2 +-
|
||||
packet_plugin/rjv3/packet_plugin_rjv3.c | 3 +++
|
||||
4 files changed, 7 insertions(+), 4 deletions(-)
|
||||
|
||||
--- a/config.c
|
||||
+++ b/config.c
|
||||
@@ -66,8 +66,8 @@ RESULT parse_cmdline_conf_file(int argc,
|
||||
return FAILURE;
|
||||
} else {
|
||||
int _len = strnlen(argv[i + 1], MAX_PATH);
|
||||
- g_prog_config.conffile = (char*)malloc(_len);
|
||||
- strncpy(g_prog_config.conffile, argv[i + 1], _len);
|
||||
+ g_prog_config.conffile = (char*)malloc(_len + 1);
|
||||
+ strncpy(g_prog_config.conffile, argv[i + 1], _len + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
--- a/if_impl/if_impl.c
|
||||
+++ b/if_impl/if_impl.c
|
||||
@@ -42,7 +42,7 @@ void print_if_impl_list() {
|
||||
* if no name is specified.
|
||||
*/
|
||||
static int impl_name_cmp(void* to_find, void* vimpl) {
|
||||
- return to_find ? memcmp(to_find, IMPL->name, strlen(IMPL->name)) : 0;
|
||||
+ return to_find ? strcmp(to_find, IMPL->name) : 0;
|
||||
}
|
||||
|
||||
RESULT select_if_impl(const char* name) {
|
||||
--- a/packet_plugin/packet_plugin.c
|
||||
+++ b/packet_plugin/packet_plugin.c
|
||||
@@ -33,7 +33,7 @@ int init_packet_plugin_list() {
|
||||
}
|
||||
|
||||
static int plugin_name_cmp(void* to_find, void* curr) {
|
||||
- return memcmp(to_find, ((PACKET_PLUGIN*)curr)->name, strlen(((PACKET_PLUGIN*)curr)->name));
|
||||
+ return strcmp(to_find, ((PACKET_PLUGIN*)curr)->name);
|
||||
}
|
||||
|
||||
RESULT select_packet_plugin(const char* name) {
|
||||
--- a/packet_plugin/rjv3/packet_plugin_rjv3.c
|
||||
+++ b/packet_plugin/rjv3/packet_plugin_rjv3.c
|
||||
@@ -230,6 +230,9 @@ static RESULT rjv3_process_success(struc
|
||||
* once the state transition is finished. We need to keep it
|
||||
* in case DHCP fails and we need to start heartbeating.
|
||||
*/
|
||||
+ if (PRIV->duplicated_packet != NULL) {
|
||||
+ free_frame(&PRIV->duplicated_packet);
|
||||
+ }
|
||||
PRIV->duplicated_packet = frame_duplicate(frame);
|
||||
system(PRIV->dhcp_script);
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
From 983fd4a5851d4a344fab92666c5cdb83f26b2294 Mon Sep 17 00:00:00 2001
|
||||
From: Aether Chen <15167799+chenjunyu19@users.noreply.github.com>
|
||||
Date: Thu, 21 Sep 2023 18:45:09 +0800
|
||||
Subject: [PATCH] config: make sure conffile config null-terminated
|
||||
|
||||
---
|
||||
config.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/config.c
|
||||
+++ b/config.c
|
||||
@@ -67,7 +67,8 @@ RESULT parse_cmdline_conf_file(int argc,
|
||||
} else {
|
||||
int _len = strnlen(argv[i + 1], MAX_PATH);
|
||||
g_prog_config.conffile = (char*)malloc(_len + 1);
|
||||
- strncpy(g_prog_config.conffile, argv[i + 1], _len + 1);
|
||||
+ strncpy(g_prog_config.conffile, argv[i + 1], _len);
|
||||
+ g_prog_config.conffile[_len] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
--- a/packet_plugin/rjv3/packet_plugin_rjv3_priv.c
|
||||
+++ b/packet_plugin/rjv3/packet_plugin_rjv3_priv.c
|
||||
@@ -132,7 +132,8 @@ static void rjv3_set_hdd_serial(uint8_t*
|
||||
memmove(serial_buf, fake_serial, strnlen(fake_serial, MAX_PROP_LEN));
|
||||
return;
|
||||
}
|
||||
-#ifdef __linux__
|
||||
+ PR_WARN("请使用 --fake-serial 选项手动指定硬盘序列号");
|
||||
+#if 0
|
||||
FILE* _fp = fopen("/etc/mtab", "r");
|
||||
char _line_buf[MAX_LINE_LEN] = {0};
|
||||
char* _line_buf_dev, *_line_buf_mountpoint;
|
||||
Reference in new issue
Block a user