🐶 Sync 2026-08-11 02:49:26

This commit is contained in:
github-actions[bot]
2026-08-11 02:49:26 +08:00
parent e9d2e50b56
commit 3d975a2853
52 changed files with 841 additions and 1058 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=event-handler
PKG_VERSION:=1
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_BUILD_DIR:=$(BUILD_DIR)/event-handler
include $(INCLUDE_DIR)/package.mk
+4 -4
View File
@@ -1,6 +1,6 @@
config event-handler
option poe_gpio '632'
option usb_gpio '633'
option heat_gpio '634'
option wd_gpio '635'
option poe_gpio '408'
option usb_gpio '409'
option heat_gpio '410'
option wd_gpio '411'
+1 -1
View File
@@ -3,7 +3,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=hotplug-generator
PKG_VERSION:=1
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_BUILD_DIR:=$(BUILD_DIR)/hotplug-generator
include $(INCLUDE_DIR)/package.mk
+4 -5
View File
@@ -1,7 +1,6 @@
#!/bin/sh /etc/rc.common
START=10
USE_PROCD=1
START=90
IFACE_PATH="/etc/hotplug.d/iface/90-hp-generator"
add_iface_rule() {
@@ -39,12 +38,12 @@ add_iface_rule() {
echo "exit 0" >> "$IFACE_PATH-$1"
}
start_service() {
start() {
rm "$IFACE_PATH-"* 2>/dev/null
config_load hotplug
config_foreach add_iface_rule iface
}
service_triggers() {
procd_add_reload_trigger "hotplug"
restart() {
start
}
+3 -1
View File
@@ -3,7 +3,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=iolines
PKG_VERSION:=1
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_BUILD_DIR:=$(BUILD_DIR)/iolines
include $(INCLUDE_DIR)/package.mk
@@ -33,6 +33,8 @@ define Package/iolines/install
$(CP) ./files/iolines.config $(1)/etc/config/iolines
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/iolines.init $(1)/etc/init.d/iolines
$(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_BIN) ./files/iolines.defaults $(1)/etc/uci-defaults/20_iolines
endef
$(eval $(call BuildPackage,iolines))
+19
View File
@@ -0,0 +1,19 @@
#!/bin/sh
[ ! -f "/usr/share/ucitrack/luci-app-iolines.json" ] && {
cat > /usr/share/ucitrack/luci-app-iolines.json << EEOF
{
"config": "iolines",
"init": "iolines"
}
EEOF
}
uci -q batch <<-EOF >/dev/null
delete ucitrack.@iolines[-1]
add ucitrack iolines
set ucitrack.@iolines[-1].init=iolines
commit ucitrack
EOF
rm -f /tmp/luci-indexcache
exit 0
+1 -1
View File
@@ -6,7 +6,7 @@ LUCI_TITLE:=LuCI interface for hotplug configuration
LUCI_DEPENDS:=+luci-base +hotplug
LUCI_PKGARCH:=all
PKG_VERSION:=1.0
PKG_RELEASE:=4
PKG_RELEASE:=5
include $(TOPDIR)/feeds/luci/luci.mk
@@ -0,0 +1,19 @@
#!/bin/sh
[ ! -f "/usr/share/ucitrack/luci-app-hotplug.json" ] && {
cat > /usr/share/ucitrack/luci-app-hotplug.json << EEOF
{
"config": "hotplug",
"init": "hotplug"
}
EEOF
}
uci -q batch <<-EOF >/dev/null
delete ucitrack.@hotplug[-1]
add ucitrack hotplug
set ucitrack.@hotplug[-1].init=hotplug
commit ucitrack
EOF
rm -f /tmp/luci-indexcache
exit 0
@@ -0,0 +1,19 @@
#!/bin/sh
[ ! -f "/usr/share/ucitrack/luci-app-powersupply.json" ] && {
cat > /usr/share/ucitrack/luci-app-powersupply.json << EEOF
{
"config": "powersupply",
"init": "powersupply"
}
EEOF
}
uci -q batch <<-EOF >/dev/null
delete ucitrack.@powersupply[-1]
add ucitrack powersupply
set ucitrack.@powersupply[-1].init=powersupply
commit ucitrack
EOF
rm -f /tmp/luci-indexcache
exit 0
@@ -0,0 +1,19 @@
#!/bin/sh
[ ! -f "/usr/share/ucitrack/luci-app-pptpd.json" ] && {
cat > /usr/share/ucitrack/luci-app-pptpd.json << EEOF
{
"config": "pptpd",
"init": "pptpd"
}
EEOF
}
uci -q batch <<-EOF >/dev/null
delete ucitrack.@pptpd[-1]
add ucitrack pptpd
set ucitrack.@pptpd[-1].init=pptpd
commit ucitrack
EOF
rm -f /tmp/luci-indexcache
exit 0
+20
View File
@@ -0,0 +1,20 @@
#
# OpenWrt LuCI application for RMS configuration.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-rms
PKG_VERSION:=1.0.0
PKG_RELEASE:=1
LUCI_TITLE:=LuCI support for RMS
LUCI_DEPENDS:=+luci-base +rms
LUCI_PKGARCH:=all
PKG_LICENSE:=Proprietary
PKG_MAINTAINER:=RMS
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature
@@ -0,0 +1,112 @@
'use strict';
'require view';
'require form';
'require uci';
'require fs';
function requireWhenSelfhosted(o, is_file) {
o.rmempty = true;
if (is_file) {
var baseParse = o.parse;
o.parse = function (section_id) {
if (this.section.formvalue(section_id, 'mode') === 'selfhosted') {
var fval = this.formvalue(section_id);
if (fval == null || fval === '')
return Promise.reject(new TypeError(
_('This field is required in Self-hosted mode.')));
}
return baseParse.apply(this, arguments);
};
} else {
o.validate = function (section_id, value) {
if (this.section.formvalue(section_id, 'mode') !== 'selfhosted')
return true;
if (value == null || value === '')
return _('This field is required in Self-hosted mode.');
return true;
};
}
}
return view.extend({
load: function () {
return Promise.all([
uci.load('rms'),
L.resolveDefault(fs.read('/tmp/rms/device_id'), '')
]);
},
render: function (data) {
var m, s, o;
var deviceId = ((data && data[1]) || '').trim() || '—';
m = new form.Map(
'rms',
_('TELEOFIS: Remote Monitoring System'),
_('Connect to the centralized TELEOFIS platform for monitoring and remote device management.')
);
s = m.section(form.NamedSection, 'main', 'rms');
s.anonymous = true;
o = s.option(form.DummyValue, 'device_id', _('Device ID'));
o.rawhtml = false;
o.cfgvalue = function () { return deviceId; };
o = s.option(form.Flag, 'enabled', _('Enable'));
o.default = '0';
o.rmempty = false;
o = s.option(form.ListValue, 'mode', _('Connection mode'), _('Connect to the cloud service or to a management platform hosted on your organization\'s servers.'));
o.value('cloud', _('Cloud'));
o.value('selfhosted', _('Self-hosted'));
o.default = 'cloud';
o.forcewrite = true;
o = s.option(form.Value, 'server', _('Address'), _('Remote host or IP address'));
o.depends('mode', 'selfhosted');
o.datatype = 'host';
requireWhenSelfhosted(o);
o = s.option(form.Value, 'port', _('Port'));
o.depends('mode', 'selfhosted');
o.datatype = 'range(1024,65535)';
o.placeholder = '8883';
requireWhenSelfhosted(o);
o = s.option(form.FileUpload, 'sh_ca_cert', _('CA certificate'), _('Root certificate of the management platform. Generated by the self-hosted platform during its deployment.'));
o.depends('mode', 'selfhosted');
o.root_directory = '/etc/rms/certs/selfhosted';
o.enable_upload = true;
o.enable_remove = true;
requireWhenSelfhosted(o, true);
o = s.option(form.FileUpload, 'sh_bootstrap_cert', _('Bootstrap CRT'), _('Certificate for initial device authentication on the management platform. Generated by the self-hosted platform during its deployment.'));
o.depends('mode', 'selfhosted');
o.root_directory = '/etc/rms/certs/selfhosted';
o.enable_upload = true;
o.enable_remove = true;
requireWhenSelfhosted(o, true);
o = s.option(form.FileUpload, 'sh_bootstrap_key', _('Bootstrap KEY'), _('Private key for initial device authentication on the management platform. Generated by the self-hosted platform during its deployment.'));
o.depends('mode', 'selfhosted');
o.root_directory = '/etc/rms/certs/selfhosted';
o.enable_upload = true;
o.enable_remove = true;
requireWhenSelfhosted(o, true);
o = s.option(form.Value, 'interval', _('Telemetry interval, s'), _('Interval at which the device sends status data to the server. Range: 300 to 3600 s.'));
o.datatype = 'range(300,3600)';
o.default = '300';
o.placeholder = '300';
o.rmempty = false;
o = s.option(form.Value, 'keepalive', _('Keepalive interval, s'), _('Interval at which the device reports to the server that it is online and the connection is active. Range: 60 to 3600 s.'));
o.datatype = 'range(60,3600)';
o.default = '60';
o.placeholder = '60';
o.rmempty = false;
return m.render();
}
});
+74
View File
@@ -0,0 +1,74 @@
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Project-Id-Version: luci-app-rms\n"
"Language: ru\n"
"MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : 2);\n"
msgid "TELEOFIS: Remote Monitoring System"
msgstr "TELEOFIS: Система Дистанционного Мониторинга"
msgid "Connect to the centralized TELEOFIS platform for monitoring and remote device management."
msgstr "Подключение к централизованной платформе TELEOFIS для мониторинга и удалённого управления устройствами."
msgid "Device ID"
msgstr "Идентификатор устройства"
msgid "Enable"
msgstr "Включить"
msgid "Connection mode"
msgstr "Способ подключения"
msgid "Connect to the cloud service or to a management platform hosted on your organization's servers."
msgstr "Подключение к облачному сервису или к платформе управления на серверах вашей организации."
msgid "Cloud"
msgstr "Cloud"
msgid "Self-hosted"
msgstr "Self-hosted"
msgid "Address"
msgstr "Адрес"
msgid "Remote host or IP address"
msgstr "Имя удалённого хоста или IP-адрес"
msgid "Port"
msgstr "Порт"
msgid "CA certificate"
msgstr "CA сертификат"
msgid "Root certificate of the management platform. Generated by the self-hosted platform during its deployment."
msgstr "Корневой сертификат платформы управления. Формируется на стороне Self-hosted платформы при её развёртывании."
msgid "Bootstrap CRT"
msgstr "Bootstrap CRT"
msgid "Certificate for initial device authentication on the management platform. Generated by the self-hosted platform during its deployment."
msgstr "Сертификат для первичной аутентификации устройства на платформе управления. Формируется на стороне Self-hosted платформы при её развёртывании."
msgid "Bootstrap KEY"
msgstr "Bootstrap KEY"
msgid "Private key for initial device authentication on the management platform. Generated by the self-hosted platform during its deployment."
msgstr "Приватный ключ для первичной аутентификации устройства на платформе управления. Формируется на стороне Self-hosted платформы при её развёртывании."
msgid "Telemetry interval, s"
msgstr "Интервал передачи телеметрии, с"
msgid "Interval at which the device sends status data to the server. Range: 300 to 3600 s."
msgstr "Интервал, с которым устройство передаёт данные о своём состоянии на сервер. Диапазон: от 300 до 3600 с"
msgid "Keepalive interval, s"
msgstr "Интервал Keepalive, с"
msgid "Interval at which the device reports to the server that it is online and the connection is active. Range: 60 to 3600 s."
msgstr "Интервал, с которым устройство сообщает серверу, что находится в сети и соединение активно. Диапазон: от 60 до 3600 с"
msgid "This field is required in Self-hosted mode."
msgstr "Это поле обязательно в режиме Self-hosted."
@@ -0,0 +1,14 @@
{
"admin/services/rms": {
"title": "TELEOFIS: Remote Monitoring System",
"order": 1,
"action": {
"type": "view",
"path": "rms/overview"
},
"depends": {
"acl": [ "luci-app-rms" ],
"uci": { "rms": true }
}
}
}
@@ -0,0 +1,21 @@
{
"luci-app-rms": {
"description": "Grant UCI, file-upload and service-restart access for RMS configuration",
"read": {
"uci": [ "rms" ],
"file": {
"/etc/rms/certs/selfhosted": [ "list" ],
"/etc/rms/certs/selfhosted/*": [ "read" ],
"/tmp/rms/device_id": [ "read" ]
}
},
"write": {
"uci": [ "rms" ],
"file": {
"/etc/rms/certs/selfhosted/*": [ "write", "remove" ],
"/etc/init.d/rms-agent restart": [ "exec" ],
"/etc/init.d/rms-telemetry restart": [ "exec" ]
}
}
}
}
+1 -1
View File
@@ -10,7 +10,7 @@ LUCI_DEPENDS:=+smscontrol
# Version: <major>.<minor>.<patch>
PKG_VERSION:=0.2.0
PKG_RELEASE:=3
PKG_RELEASE:=4
LUCI_TITLE:=LuCI utility to remote control via SMS
@@ -0,0 +1,19 @@
#!/bin/sh
[ ! -f "/usr/share/ucitrack/luci-app-smscontrol.json" ] && {
cat > /usr/share/ucitrack/luci-app-smscontrol.json << EEOF
{
"config": "smscontrol",
"init": "smscontrol"
}
EEOF
}
uci -q batch <<-EOF >/dev/null
delete ucitrack.@smscontrol[-1]
add ucitrack smscontrol
set ucitrack.@smscontrol[-1].init=smscontrol
commit ucitrack
EOF
rm -f /tmp/luci-indexcache
exit 0
+1 -1
View File
@@ -3,7 +3,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-snmpd-ssl
LUCI_TITLE:=Net-SNMP LuCI interface with v3 support
LUCI_DEPENDS:=+luci-base
LUCI_DEPENDS:=+luci-base +snmpd-ssl
LUCI_PKGARCH:=all
include $(TOPDIR)/feeds/luci/luci.mk
@@ -0,0 +1,19 @@
#!/bin/sh
[ ! -f "/usr/share/ucitrack/luci-app-snmpd.json" ] && {
cat > /usr/share/ucitrack/luci-app-snmpd.json << EEOF
{
"config": "snmpd",
"init": "snmpd"
}
EEOF
}
uci -q batch <<-EOF >/dev/null
delete ucitrack.@snmpd[-1]
add ucitrack snmpd
set ucitrack.@snmpd[-1].init=snmpd
commit ucitrack
EOF
rm -f /tmp/luci-indexcache
exit 0
@@ -0,0 +1,19 @@
#!/bin/sh
[ ! -f "/usr/share/ucitrack/luci-app-xl2tpd.json" ] && {
cat > /usr/share/ucitrack/luci-app-xl2tpd.json << EEOF
{
"config": "xl2tpd",
"init": "xl2tpd"
}
EEOF
}
uci -q batch <<-EOF >/dev/null
delete ucitrack.@xl2tpd[-1]
add ucitrack xl2tpd
set ucitrack.@xl2tpd[-1].init=xl2tpd
commit ucitrack
EOF
rm -f /tmp/luci-indexcache
exit 0
+1 -1
View File
@@ -4,7 +4,7 @@ PKG_NAME:=luci-app-zabbix
LUCI_TITLE:=zabbix agentd configuration
LUCI_DEPENDS:=+luci-base
LUCI_DEPENDS:=zabbix-agentd-openssl
LUCI_DEPENDS:=zabbix-agentd-ssl
LUCI_PKGARCH:=all
include $(TOPDIR)/feeds/luci/luci.mk
@@ -0,0 +1,19 @@
#!/bin/sh
[ ! -f "/usr/share/ucitrack/luci-app-zabbix.json" ] && {
cat > /usr/share/ucitrack/luci-app-zabbix.json << EEOF
{
"config": "zabbix",
"init": "zabbix"
}
EEOF
}
uci -q batch <<-EOF >/dev/null
delete ucitrack.@zabbix[-1]
add ucitrack zabbix
set ucitrack.@zabbix[-1].init=zabbix_agentd
commit ucitrack
EOF
rm -f /tmp/luci-indexcache
exit 0
-14
View File
@@ -1,14 +0,0 @@
menu "Configuration"
depends on PACKAGE_libnetsnmp
config SNMP_WITH_PERL_EMBEDDED
bool
default n
prompt "Enable embedded perl in the SNMP agent and snmptrapd."
config SNMP_WITH_PERL_MODULES
bool
default n
prompt "Install perl modules"
endmenu
+7 -8
View File
@@ -8,8 +8,8 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=net-snmp
PKG_VERSION:=5.9.4
PKG_RELEASE:=1
PKG_VERSION:=5.9.1
PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=@SF/net-snmp
@@ -130,10 +130,7 @@ SNMP_MIB_MODULES_INCLUDED = \
host/hr_system \
ieee802dot11 \
if-mib/ifXTable \
ip-mib/ipAddressTable \
ip-mib/inetNetToMediaTable \
ip-forward-mib/inetCidrRouteTable \
ip-forward-mib/ipCidrRouteTable \
mibII/at \
mibII/icmp \
mibII/ifTable \
@@ -151,7 +148,7 @@ SNMP_MIB_MODULES_INCLUDED = \
snmpv3/usmStats \
snmpv3/usmUser \
tunnel \
ucd-snmp/disk_hw \
ucd-snmp/disk \
ucd-snmp/dlmod \
ucd-snmp/extensible \
ucd-snmp/loadave \
@@ -206,12 +203,11 @@ CONFIGURE_ARGS += \
--with-mib-modules="$(SNMP_MIB_MODULES_INCLUDED)" \
--with-out-transports="$(SNMP_TRANSPORTS_EXCLUDED)" \
--with-transports="$(SNMP_TRANSPORTS_INCLUDED)" \
--without-openssl \
--with-openssl=$(STAGING_DIR)/usr \
--without-libwrap \
--without-mysql \
--without-rpm \
--without-zlib \
--with-pcre2-8 \
--with-nl \
$(call autoconf_bool,CONFIG_IPV6,ipv6) \
--disable-perl-cc-checks \
@@ -220,12 +216,15 @@ CONFIGURE_ARGS += \
CONFIGURE_VARS += \
ac_cv_header_netlink_netlink_h=yes \
ac_cv_header_pcre_h=no \
netsnmp_cv_func_nl_connect_LIBS=-lnl-tiny \
ifeq ($(CONFIG_IPV6),y)
SNMP_TRANSPORTS_INCLUDED+= UDPIPv6
endif
TARGET_LDFLAGS += -L$(TOOLCHAIN_DIR)/usr/lib
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) \
INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
+4 -4
View File
@@ -15,11 +15,11 @@ link tests to fail due to a stray "no" word getting passed to the linker.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
--- a/configure.d/config_os_libs2
+++ b/configure.d/config_os_libs2
@@ -252,14 +252,22 @@ if test "x$with_nl" != "xno"; then
case $target_os in
linux*) # Check for libnl (linux)
@@ -247,14 +247,22 @@ if test "x$with_nl" != "xno"; then
)
netsnmp_save_CPPFLAGS="$CPPFLAGS"
- CPPFLAGS="${LIBNL3_CFLAGS} ${LIBNLROUTE3_CFLAGS} $CPPFLAGS"
- CPPFLAGS="${LIBNL3_CFLAGS} $CPPFLAGS"
- NETSNMP_SEARCH_LIBS(nl_connect, nl-3,
- [AC_CHECK_HEADERS(netlink/netlink.h)
- EXTERNAL_MIBGROUP_INCLUDES="$EXTERNAL_MIBGROUP_INCLUDES ${LIBNL3_CFLAGS}"],
@@ -29,6 +29,6 @@ Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
{
-next:
+next: ;
#ifdef HAVE_GETFSSTAT
#if HAVE_GETFSSTAT
if (HRFS_index >= fscount)
return -1;
@@ -1,13 +1,22 @@
--- a/agent/mibgroup/mibII/interfaces.c
+++ b/agent/mibgroup/mibII/interfaces.c
@@ -1586,6 +1586,10 @@ Interface_Scan_Init(void)
@@ -1579,6 +1579,10 @@ Interface_Scan_Init(void)
struct ifnet *nnew;
char *stats, *ifstart = line;
size_t len;
+ /* Ignore interfaces with no statistics. */
+ if (strstr(line, "No statistics available."))
+ continue;
+ continue;
+
len = strlen(line);
if (len && line[len - 1] == '\n')
line[len - 1] = '\0';
if (line[strlen(line) - 1] == '\n')
line[strlen(line) - 1] = '\0';
@@ -1611,7 +1615,7 @@ Interface_Scan_Init(void)
&coll) != 5)) {
if ((scan_line_to_use == scan_line_2_2)
&& !strstr(line, "No statistics available"))
- snmp_log(LOG_ERR,
+ snmp_log(LOG_DEBUG,
"/proc/net/dev data format error, line ==|%s|",
line);
continue;
+1 -1
View File
@@ -1,6 +1,6 @@
--- a/configure
+++ b/configure
@@ -16599,7 +16599,7 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu
@@ -15602,7 +15602,7 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu
need_version=no
library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
soname_spec='$libname$release$shared_ext$major'
@@ -1,11 +0,0 @@
--- a/configure.d/config_project_types
+++ b/configure.d/config_project_types
@@ -66,7 +66,7 @@ netsnmp_save_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS -Werror"
AC_MSG_CHECKING([for the type of fd_set::fds_bits])
-for type in __fd_mask __int32_t unknown; do
+for type in fd_mask int32_t size_t; do
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
#include <sys/select.h>
#include <stddef.h>
+5 -5
View File
@@ -1,11 +1,11 @@
--- a/Makefile.top
+++ b/Makefile.top
@@ -87,7 +87,7 @@ LIBCURRENT = 42
LIBAGE = 2
LIBREVISION = 1
@@ -87,7 +87,7 @@ LIBCURRENT = 41
LIBAGE = 1
LIBREVISION = 0
-LIB_LD_CMD = $(LIBTOOL) --mode=link $(LINKCC) $(CFLAGS) -rpath $(libdir) -version-info $(LIBCURRENT):$(LIBREVISION):$(LIBAGE) @LD_NO_UNDEFINED@ -o
+LIB_LD_CMD = $(LIBTOOL) --mode=link $(LINKCC) $(CFLAGS) -rpath $(libdir) $(LDFLAGS) -version-info $(LIBCURRENT):$(LIBREVISION):$(LIBAGE) @LD_NO_UNDEFINED@ -o
-LIB_LD_CMD = $(LIBTOOL) --mode=link $(LINKCC) $(CFLAGS) -rpath $(libdir) -version-info $(LIBCURRENT):$(LIBREVISION):$(LIBAGE) -o
+LIB_LD_CMD = $(LIBTOOL) --mode=link $(LINKCC) $(CFLAGS) -rpath $(libdir) $(LDFLAGS) -version-info $(LIBCURRENT):$(LIBREVISION):$(LIBAGE) -o
LIB_EXTENSION = la
LIB_VERSION =
LIB_LDCONFIG_CMD = $(LIBTOOL) --mode=finish $(INSTALL_PREFIX)$(libdir)
@@ -1,407 +0,0 @@
From d3e95c87b32397815f6d5bcfc844259f2552697a Mon Sep 17 00:00:00 2001
From: gagan sidhu <gagan@hotmail.com>
Date: Sun, 21 May 2023 15:47:36 -0600
Subject: [PATCH] add pcre2 support
---
agent/mibgroup/host/data_access/swrun.c | 29 ++++++++++--
agent/mibgroup/if-mib/data_access/interface.c | 47 ++++++++++++++++---
agent/mibgroup/struct.h | 2 +-
agent/mibgroup/ucd-snmp/proc.c | 32 +++++++++----
agent/mibgroup/ucd-snmp/proc.h | 2 +-
configure.d/config_os_libs1 | 27 +++++++++++
configure.d/config_project_with_enable | 4 ++
include/net-snmp/data_access/interface.h | 9 +++-
include/net-snmp/data_access/swrun.h | 2 +-
include/net-snmp/types.h | 2 +-
10 files changed, 132 insertions(+), 24 deletions(-)
--- a/agent/mibgroup/host/data_access/swrun.c
+++ b/agent/mibgroup/host/data_access/swrun.c
@@ -17,7 +17,10 @@
#include "swrun.h"
#include "swrun_private.h"
-#ifdef HAVE_PCRE_H
+#if defined(HAVE_PCRE2_H)
+#define PCRE2_CODE_UNIT_WIDTH 8
+#include <pcre2.h>
+#elif defined(HAVE_PCRE_H)
#include <pcre.h>
#endif
@@ -100,32 +103,52 @@ swrun_max_processes( void )
#endif /* NETSNMP_FEATURE_REMOVE_SWRUN_MAX_PROCESSES */
#ifndef NETSNMP_FEATURE_REMOVE_SWRUN_COUNT_PROCESSES_BY_REGEX
-#ifdef HAVE_PCRE_H
+#if defined(HAVE_PCRE2_H) || defined(HAVE_PCRE_H)
int
swrun_count_processes_by_regex( char *name, netsnmp_regex_ptr regexp )
{
netsnmp_swrun_entry *entry;
netsnmp_iterator *it;
int i = 0;
+#ifdef HAVE_PCRE2_H
+ pcre2_match_data *ndx_match;
+ int *found_ndx;
+ ndx_match = pcre2_match_data_create(30, NULL);
+ found_ndx = pcre2_get_ovector_pointer(ndx_match);
+#elif defined(HAVE_PCRE_H)
int found_ndx[30];
+#endif
int found;
char fullCommand[64 + 128 + 128 + 3];
netsnmp_cache_check_and_reload(swrun_cache);
if ( !swrun_container || !name || !regexp.regex_ptr )
+#ifdef HAVE_PCRE2_H
+ {
+ pcre2_match_data_free(ndx_match);
+ return 0;
+ }
+#else
return 0; /* or -1 */
+#endif
it = CONTAINER_ITERATOR( swrun_container );
while ((entry = (netsnmp_swrun_entry*)ITERATOR_NEXT( it )) != NULL) {
/* need to assemble full command back so regexps can get full picture */
sprintf(fullCommand, "%s %s", entry->hrSWRunPath, entry->hrSWRunParameters);
+#ifdef HAVE_PCRE2_H
+ found = pcre2_match(regexp.regex_ptr, fullCommand, strlen(fullCommand), 0, 0, ndx_match, NULL);
+#elif HAVE_PCRE_H
found = pcre_exec(regexp.regex_ptr, NULL, fullCommand, strlen(fullCommand), 0, 0, found_ndx, 30);
+#endif
if (found > 0) {
i++;
}
}
ITERATOR_RELEASE( it );
-
+#ifdef HAVE_PCRE2_H
+ pcre2_match_data_free(ndx_match);
+#endif
return i;
}
#endif /* HAVE_PCRE_H */
--- a/agent/mibgroup/if-mib/data_access/interface.c
+++ b/agent/mibgroup/if-mib/data_access/interface.c
@@ -16,7 +16,11 @@
#include "if-mib/ifTable/ifTable.h"
#include "if-mib/data_access/interface.h"
#include "interface_private.h"
-#if defined(HAVE_PCRE_H)
+
+#if defined(HAVE_PCRE2_H)
+#define PCRE2_CODE_UNIT_WIDTH 8
+#include <pcre2.h>
+#elif defined(HAVE_PCRE_H)
#include <pcre.h>
#elif defined(HAVE_REGEX_H)
#include <sys/types.h>
@@ -824,7 +828,13 @@ int netsnmp_access_interface_max_reached
int netsnmp_access_interface_include(const char *name)
{
netsnmp_include_if_list *if_ptr;
-#ifdef HAVE_PCRE_H
+#if defined(HAVE_PCRE2_H)
+ //pcre_exec->pcre2_match
+ //ovector->pcre2_match_data
+ pcre2_match_data *ndx_match;
+ ndx_match = pcre2_match_data_create(3, NULL);
+ int *found_ndx = pcre2_get_ovector_pointer(ndx_match);
+#elif defined(HAVE_PCRE_H)
int found_ndx[3];
#endif
@@ -840,7 +850,13 @@ int netsnmp_access_interface_include(con
for (if_ptr = include_list; if_ptr; if_ptr = if_ptr->next) {
-#if defined(HAVE_PCRE_H)
+#if defined(HAVE_PCRE2_H)
+ if (pcre2_match(if_ptr->regex_ptr, name, strlen(name), 0, 0,
+ ndx_match, NULL) >= 0) {
+ pcre2_match_data_free(ndx_match);
+ return TRUE;
+ }
+#elif defined(HAVE_PCRE_H)
if (pcre_exec(if_ptr->regex_ptr, NULL, name, strlen(name), 0, 0,
found_ndx, 3) >= 0)
return TRUE;
@@ -853,6 +869,9 @@ int netsnmp_access_interface_include(con
#endif
}
+#if defined(HAVE_PCRE2_H)
+ pcre2_match_data_free(ndx_match);
+#endif
return FALSE;
}
@@ -964,7 +983,13 @@ _parse_include_if_config(const char *tok
{
netsnmp_include_if_list *if_ptr, *if_new;
char *name, *st;
-#if defined(HAVE_PCRE_H)
+#if defined(HAVE_PCRE2_H)
+ //we can only get the message upon calling pcre2_error_message.
+ // so an additional variable is required.
+ int pcre2_err_code;
+ unsigned char pcre2_error[128];
+ int pcre2_error_offset;
+#elif defined(HAVE_PCRE_H)
const char *pcre_error;
int pcre_error_offset;
#elif defined(HAVE_REGEX_H)
@@ -996,7 +1021,15 @@ _parse_include_if_config(const char *tok
config_perror("Out of memory");
goto err;
}
-#if defined(HAVE_PCRE_H)
+#if defined(HAVE_PCRE2_H)
+ if_new->regex_ptr = pcre2_compile(if_new->name, PCRE2_ZERO_TERMINATED, 0,
+ &pcre2_err_code, &pcre2_error_offset, NULL);
+ if (!if_new->regex_ptr) {
+ pcre2_get_error_message(pcre2_err_code, pcre2_error, 128);
+ config_perror(pcre2_error);
+ goto err;
+ }
+#elif defined(HAVE_PCRE_H)
if_new->regex_ptr = pcre_compile(if_new->name, 0, &pcre_error,
&pcre_error_offset, NULL);
if (!if_new->regex_ptr) {
@@ -1032,7 +1065,7 @@ _parse_include_if_config(const char *tok
err:
if (if_new) {
-#if defined(HAVE_PCRE_H) || defined(HAVE_REGEX_H)
+#if defined(HAVE_PCRE2_H) || defined(HAVE_PCRE_H) || defined(HAVE_REGEX_H)
free(if_new->regex_ptr);
#endif
free(if_new->name);
@@ -1047,7 +1080,7 @@ _free_include_if_config(void)
while (if_ptr) {
if_next = if_ptr->next;
-#if defined(HAVE_PCRE_H)
+#if defined(HAVE_PCRE2_H) || defined(HAVE_PCRE_H)
free(if_ptr->regex_ptr);
#elif defined(HAVE_REGEX_H)
regfree(if_ptr->regex_ptr);
--- a/agent/mibgroup/struct.h
+++ b/agent/mibgroup/struct.h
@@ -30,7 +30,7 @@ struct extensible {
struct myproc {
char name[STRMAX];
-#ifdef HAVE_PCRE_H
+#if defined(HAVE_PCRE2_H) || defined(HAVE_PCRE_H)
netsnmp_regex_ptr regexp;
#endif
char fixcmd[STRMAX];
--- a/agent/mibgroup/ucd-snmp/proc.c
+++ b/agent/mibgroup/ucd-snmp/proc.c
@@ -39,7 +39,10 @@
# include <time.h>
# endif
#endif
-#ifdef HAVE_PCRE_H
+#ifdef HAVE_PCRE2_H
+#define PCRE2_CODE_UNIT_WIDTH 8
+#include <pcre2.h>
+#elifdef HAVE_PCRE_H
#include <pcre.h>
#endif
@@ -108,7 +111,7 @@ init_proc(void)
REGISTER_MIB("ucd-snmp/proc", extensible_proc_variables, variable2,
proc_variables_oid);
-#ifdef HAVE_PCRE_H
+#if defined(HAVE_PCRE2_H) || defined(HAVE_PCRE_H)
#define proc_parse_usage "process-name [max-num] [min-num] [regexp]"
#else
#define proc_parse_usage "process-name [max-num] [min-num]"
@@ -134,7 +137,7 @@ proc_free_config(void)
for (ptmp = procwatch; ptmp != NULL;) {
ptmp2 = ptmp;
ptmp = ptmp->next;
-#ifdef HAVE_PCRE_H
+#if defined(HAVE_PCRE2_H) || defined(HAVE_PCRE_H)
free(ptmp2->regexp.regex_ptr);
#endif
free(ptmp2);
@@ -208,7 +211,7 @@ proc_parse_config(const char *token, cha
if (*procp == NULL)
return; /* memory alloc error */
numprocs++;
-#ifdef HAVE_PCRE_H
+#if defined(HAVE_PCRE2_H) || defined(HAVE_PCRE_H)
(*procp)->regexp.regex_ptr = NULL;
#endif
/*
@@ -220,18 +223,31 @@ proc_parse_config(const char *token, cha
cptr = skip_not_white(cptr);
if ((cptr = skip_white(cptr))) {
(*procp)->min = atoi(cptr);
-#ifdef HAVE_PCRE_H
+#if defined(HAVE_PCRE2_H) || defined(HAVE_PCRE_H)
cptr = skip_not_white(cptr);
if ((cptr = skip_white(cptr))) {
+ DEBUGMSGTL(("ucd-snmp/regexp_proc", "Loading regex %s\n", cptr));
+#ifdef HAVE_PCRE2_H
+ unsigned char pcre2_error_msg[128];
+ int pcre2_err_code;
+ int pcre2_error_offset;
+
+ (*procp)->regexp.regex_ptr =
+ pcre2_compile(cptr, PCRE2_ZERO_TERMINATED, 0, &pcre2_err_code, &pcre2_error_offset, NULL);
+ pcre2_get_error_message(pcre2_err_code, pcre2_error_msg, 128);
+ if ((*procp)->regexp.regex_ptr == NULL) {
+ config_perror(pcre2_error_msg);
+ }
+#elifdef HAVE_PCRE_H
const char *pcre_error;
int pcre_error_offset;
- DEBUGMSGTL(("ucd-snmp/regexp_proc", "Loading regex %s\n", cptr));
(*procp)->regexp.regex_ptr =
pcre_compile(cptr, 0, &pcre_error, &pcre_error_offset, NULL);
if ((*procp)->regexp.regex_ptr == NULL) {
config_perror(pcre_error);
}
+#endif
}
#endif
} else
@@ -390,7 +406,7 @@ sh_count_myprocs(struct myproc *proc)
if (proc == NULL)
return 0;
-#if defined(USING_HOST_DATA_ACCESS_SWRUN_MODULE) && defined(HAVE_PCRE_H)
+#if defined(USING_HOST_DATA_ACCESS_SWRUN_MODULE) && (defined(HAVE_PCRE2_H) || defined(HAVE_PCRE_H))
if (proc->regexp.regex_ptr != NULL)
return sh_count_procs_by_regex(proc->name, proc->regexp);
#endif
@@ -406,7 +422,7 @@ sh_count_procs(char *procname)
return swrun_count_processes_by_name( procname );
}
-#ifdef HAVE_PCRE_H
+#if defined(HAVE_PCRE2_H) || defined(HAVE_PCRE_H)
netsnmp_feature_require(swrun_count_processes_by_regex);
int
sh_count_procs_by_regex(char *procname, netsnmp_regex_ptr regexp)
--- a/agent/mibgroup/ucd-snmp/proc.h
+++ b/agent/mibgroup/ucd-snmp/proc.h
@@ -12,7 +12,7 @@ config_require(util_funcs);
extern WriteMethod fixProcError;
int sh_count_myprocs(struct myproc *);
int sh_count_procs(char *);
-#ifdef HAVE_PCRE_H
+#if defined(HAVE_PCRE2_H) || defined(HAVE_PCRE_H)
int sh_count_procs_by_regex(char *, netsnmp_regex_ptr);
#endif
--- a/configure.d/config_os_libs1
+++ b/configure.d/config_os_libs1
@@ -97,6 +97,32 @@ LIBS="$netsnmp_save_LIBS"
#
# regex in process table
#
+if test "x$with_pcre2" != "xno"; then
+ AC_CHECK_HEADER([pcre2.h], [
+ AC_DEFINE([HAVE_PCRE2_H], [1], [Define to 1 if you have <pcre2.h>.])
+ pcre2_h=yes
+ ],
+ [pcre2_h=no], [#define PCRE2_CODE_UNIT_WIDTH 8]
+ )
+fi
+if test "x$pcre2header_h" = "xno" -o "x$pcre2_h" = "xno" ; then
+ if test "x$with_pcre2" = "xyes" ; then
+ AC_MSG_ERROR([Could not find the pcre2 header file needed and was specifically asked to use pcre2 support])
+ else
+ with_pcre2=no
+ fi
+fi
+
+if test "x$with_pcre2" != "xno"; then
+ NETSNMP_SEARCH_LIBS([pcre2_match_8], [pcre2-8], [
+ LMIBLIBS="$LMIBLIBS -lpcre2-8"
+ ],,, LAGENTLIBS)
+ AC_SUBST(LAGENTLIBS)
+ AC_SUBST(LMIBLIBS)
+fi
+
+if test "x$with_pcre2" != "xyes"; then
+
if test "x$with_pcre" != "xno"; then
AC_CHECK_HEADER([pcre.h], [
AC_DEFINE([HAVE_PCRE_H], [1], [Define to 1 if you have <pcre.h>.])
@@ -123,3 +149,4 @@ if test "x$with_pcre" != "xno"; then
AC_SUBST(LAGENTLIBS)
AC_SUBST(LMIBLIBS)
fi
+fi
--- a/configure.d/config_project_with_enable
+++ b/configure.d/config_project_with_enable
@@ -160,6 +160,10 @@ NETSNMP_ARG_WITH(rpm,
management system when building the host MIB
module.])
+NETSNMP_ARG_WITH(pcre2-8,
+[ --without-pcre2 Don't include pcre2 process searching
+ support in the agent.],
+ with_pcre2="$withval", with_pcre2="maybe")
NETSNMP_ARG_WITH(pcre,
[ --without-pcre Don't include pcre process searching
--- a/include/net-snmp/data_access/interface.h
+++ b/include/net-snmp/data_access/interface.h
@@ -10,7 +10,10 @@
extern "C" {
#endif
-#if defined(HAVE_PCRE_H)
+#if defined(HAVE_PCRE2_H)
+#define PCRE2_CODE_UNIT_WIDTH 8
+#include <pcre2.h>
+#elif defined(HAVE_PCRE_H)
#include <pcre.h>
#elif defined(HAVE_REGEX_H)
#include <regex.h>
@@ -211,7 +214,9 @@ typedef struct _conf_if_list {
typedef netsnmp_conf_if_list conf_if_list; /* backwards compat */
typedef struct _include_if_list {
-#if defined(HAVE_PCRE_H)
+#if defined(HAVE_PCRE2_H)
+ pcre2_code *regex_ptr;
+#elif defined(HAVE_PCRE_H)
pcre *regex_ptr;
#elif defined(HAVE_REGEX_H)
regex_t *regex_ptr;
--- a/include/net-snmp/data_access/swrun.h
+++ b/include/net-snmp/data_access/swrun.h
@@ -90,7 +90,7 @@ extern "C" {
int swrun_count_processes_by_name( char *name );
#if !defined(NETSNMP_FEATURE_REMOVE_SWRUN_COUNT_PROCESSES_BY_REGEX) \
- && defined(HAVE_PCRE_H)
+ && (defined(HAVE_PCRE2_H) || defined(HAVE_PCRE_H))
int swrun_count_processes_by_regex(char *name, netsnmp_regex_ptr regexp);
#endif
--- a/include/net-snmp/types.h
+++ b/include/net-snmp/types.h
@@ -63,7 +63,7 @@ typedef long ssize_t;
typedef unsigned long int nfds_t;
#endif
-#ifdef HAVE_PCRE_H
+#if defined(HAVE_PCRE2_H) || defined(HAVE_PCRE_H)
/*
* Abstract the pcre typedef such that not all *.c files have to include
* <pcre.h>.
@@ -1,185 +0,0 @@
From 48b313ca34dbdf303fb232191d4f74e1d0fc9f06 Mon Sep 17 00:00:00 2001
From: Bart Van Assche <bvanassche@acm.org>
Date: Sun, 21 May 2023 16:20:15 -0700
Subject: [PATCH] Run autoreconf
---
configure | 126 ++++++++++++++++++++++++++
include/net-snmp/net-snmp-config.h.in | 3 +
2 files changed, 129 insertions(+)
--- a/configure
+++ b/configure
@@ -928,6 +928,8 @@ with_dnssec
enable_dnssec
with_rpm
enable_rpm
+with_pcre2_8
+enable_pcre2_8
with_pcre
enable_pcre
with_install_prefix
@@ -1851,6 +1853,8 @@ Compiler Options:
--without-rpm Don't include support for the RPM package
management system when building the host MIB
module.
+ --without-pcre2 Don't include pcre2 process searching
+ support in the agent.
--without-pcre Don't include pcre process searching
support in the agent.
--with-install-prefix=PATH Just for installing, prefix all
@@ -5259,6 +5263,21 @@ fi
+# Check whether --with-pcre2-8 was given.
+if test ${with_pcre2_8+y}
+then :
+ withval=$with_pcre2_8; with_pcre2="$withval"
+else $as_nop
+ with_pcre2="maybe"
+fi
+
+ # Check whether --enable-pcre2-8 was given.
+if test ${enable_pcre2_8+y}
+then :
+ enableval=$enable_pcre2_8; as_fn_error $? "Invalid option. Use --with-pcre2-8/--without-pcre2-8 instead" "$LINENO" 5
+fi
+
+
# Check whether --with-pcre was given.
if test ${with_pcre+y}
@@ -26477,6 +26496,112 @@ LIBS="$netsnmp_save_LIBS"
#
# regex in process table
#
+if test "x$with_pcre2" != "xno"; then
+ ac_fn_c_check_header_compile "$LINENO" "pcre2.h" "ac_cv_header_pcre2_h" "#define PCRE2_CODE_UNIT_WIDTH 8
+
+"
+if test "x$ac_cv_header_pcre2_h" = xyes
+then :
+
+
+printf "%s\n" "#define HAVE_PCRE2_H 1" >>confdefs.h
+
+ pcre2_h=yes
+
+else $as_nop
+ pcre2_h=no
+fi
+
+fi
+if test "x$pcre2header_h" = "xno" -o "x$pcre2_h" = "xno" ; then
+ if test "x$with_pcre2" = "xyes" ; then
+ as_fn_error $? "Could not find the pcre2 header file needed and was specifically asked to use pcre2 support" "$LINENO" 5
+ else
+ with_pcre2=no
+ fi
+fi
+
+if test "x$with_pcre2" != "xno"; then
+
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing pcre2_match_8" >&5
+printf %s "checking for library containing pcre2_match_8... " >&6; }
+if test ${netsnmp_cv_func_pcre2_match_8_LAGENTLIBS+y}
+then :
+ printf %s "(cached) " >&6
+else $as_nop
+ netsnmp_func_search_save_LIBS="$LIBS"
+ netsnmp_target_val="$LAGENTLIBS"
+ netsnmp_temp_LIBS="${netsnmp_target_val} ${LIBS}"
+ netsnmp_result=no
+ LIBS="${netsnmp_temp_LIBS}"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+char pcre2_match_8 ();
+int
+main (void)
+{
+return pcre2_match_8 ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
+ netsnmp_result="none required"
+else $as_nop
+ for netsnmp_cur_lib in pcre2-8 ; do
+ LIBS="-l${netsnmp_cur_lib} ${netsnmp_temp_LIBS}"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+char pcre2_match_8 ();
+int
+main (void)
+{
+return pcre2_match_8 ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
+ netsnmp_result=-l${netsnmp_cur_lib}
+ break
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+ conftest$ac_exeext conftest.$ac_ext
+ done
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+ conftest$ac_exeext conftest.$ac_ext
+ LIBS="${netsnmp_func_search_save_LIBS}"
+ netsnmp_cv_func_pcre2_match_8_LAGENTLIBS="${netsnmp_result}"
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $netsnmp_cv_func_pcre2_match_8_LAGENTLIBS" >&5
+printf "%s\n" "$netsnmp_cv_func_pcre2_match_8_LAGENTLIBS" >&6; }
+ if test "${netsnmp_cv_func_pcre2_match_8_LAGENTLIBS}" != "no" ; then
+ if test "${netsnmp_cv_func_pcre2_match_8_LAGENTLIBS}" != "none required" ; then
+ LAGENTLIBS="${netsnmp_result} ${netsnmp_target_val}"
+ fi
+
+ LMIBLIBS="$LMIBLIBS -lpcre2-8"
+
+
+ fi
+
+
+
+fi
+
+if test "x$with_pcre2" != "xyes"; then
+
if test "x$with_pcre" != "xno"; then
ac_fn_c_check_header_compile "$LINENO" "pcre.h" "ac_cv_header_pcre_h" "$ac_includes_default"
if test "x$ac_cv_header_pcre_h" = xyes
@@ -31486,6 +31611,7 @@ printf "%s\n" "#define pid_t $ac_pid_typ
fi
+fi
--- a/include/net-snmp/net-snmp-config.h.in
+++ b/include/net-snmp/net-snmp-config.h.in
@@ -727,6 +727,9 @@
/* Define to 1 if you have the <pci/pci.h> header file. */
#undef HAVE_PCI_PCI_H
+/* Define to 1 if you have <pcre2.h>. */
+#undef HAVE_PCRE2_H
+
/* Define to 1 if you have <pcre.h>. */
#undef HAVE_PCRE_H
@@ -1,152 +0,0 @@
From 346b6f8959513320e5b674fd670c49ba2cd43af5 Mon Sep 17 00:00:00 2001
From: Bart Van Assche <bvanassche@acm.org>
Date: Sun, 21 May 2023 16:18:56 -0700
Subject: [PATCH] Improve pcre2 support
Fix compiler warnings. Convert C++ comments to C comments. Make sure that
declarations occur before statements.
---
agent/mibgroup/host/data_access/swrun.c | 17 ++++------
agent/mibgroup/if-mib/data_access/interface.c | 32 ++++++++++---------
agent/mibgroup/ucd-snmp/proc.c | 13 +++++---
3 files changed, 31 insertions(+), 31 deletions(-)
--- a/agent/mibgroup/host/data_access/swrun.c
+++ b/agent/mibgroup/host/data_access/swrun.c
@@ -111,10 +111,7 @@ swrun_count_processes_by_regex( char *na
netsnmp_iterator *it;
int i = 0;
#ifdef HAVE_PCRE2_H
- pcre2_match_data *ndx_match;
- int *found_ndx;
- ndx_match = pcre2_match_data_create(30, NULL);
- found_ndx = pcre2_get_ovector_pointer(ndx_match);
+ pcre2_match_data *ndx_match = pcre2_match_data_create(30, NULL);
#elif defined(HAVE_PCRE_H)
int found_ndx[30];
#endif
@@ -122,22 +119,20 @@ swrun_count_processes_by_regex( char *na
char fullCommand[64 + 128 + 128 + 3];
netsnmp_cache_check_and_reload(swrun_cache);
- if ( !swrun_container || !name || !regexp.regex_ptr )
+ if ( !swrun_container || !name || !regexp.regex_ptr ) {
#ifdef HAVE_PCRE2_H
- {
pcre2_match_data_free(ndx_match);
- return 0;
- }
-#else
- return 0; /* or -1 */
#endif
+ return 0; /* or -1 */
+ }
it = CONTAINER_ITERATOR( swrun_container );
while ((entry = (netsnmp_swrun_entry*)ITERATOR_NEXT( it )) != NULL) {
/* need to assemble full command back so regexps can get full picture */
sprintf(fullCommand, "%s %s", entry->hrSWRunPath, entry->hrSWRunParameters);
#ifdef HAVE_PCRE2_H
- found = pcre2_match(regexp.regex_ptr, fullCommand, strlen(fullCommand), 0, 0, ndx_match, NULL);
+ found = pcre2_match(regexp.regex_ptr, (unsigned char *)fullCommand,
+ strlen(fullCommand), 0, 0, ndx_match, NULL);
#elif HAVE_PCRE_H
found = pcre_exec(regexp.regex_ptr, NULL, fullCommand, strlen(fullCommand), 0, 0, found_ndx, 30);
#endif
--- a/agent/mibgroup/if-mib/data_access/interface.c
+++ b/agent/mibgroup/if-mib/data_access/interface.c
@@ -828,12 +828,8 @@ int netsnmp_access_interface_max_reached
int netsnmp_access_interface_include(const char *name)
{
netsnmp_include_if_list *if_ptr;
-#if defined(HAVE_PCRE2_H)
- //pcre_exec->pcre2_match
- //ovector->pcre2_match_data
- pcre2_match_data *ndx_match;
- ndx_match = pcre2_match_data_create(3, NULL);
- int *found_ndx = pcre2_get_ovector_pointer(ndx_match);
+#if defined(HAVE_PCRE2_H)
+ pcre2_match_data *ndx_match = pcre2_match_data_create(3, NULL);
#elif defined(HAVE_PCRE_H)
int found_ndx[3];
#endif
@@ -851,8 +847,8 @@ int netsnmp_access_interface_include(con
for (if_ptr = include_list; if_ptr; if_ptr = if_ptr->next) {
#if defined(HAVE_PCRE2_H)
- if (pcre2_match(if_ptr->regex_ptr, name, strlen(name), 0, 0,
- ndx_match, NULL) >= 0) {
+ if (pcre2_match(if_ptr->regex_ptr, (const unsigned char *)name,
+ strlen(name), 0, 0, ndx_match, NULL) >= 0) {
pcre2_match_data_free(ndx_match);
return TRUE;
}
@@ -984,11 +980,13 @@ _parse_include_if_config(const char *tok
netsnmp_include_if_list *if_ptr, *if_new;
char *name, *st;
#if defined(HAVE_PCRE2_H)
- //we can only get the message upon calling pcre2_error_message.
- // so an additional variable is required.
+ /*
+ * We can only get the message upon calling pcre2_error_message.
+ * so an additional variable is required.
+ */
int pcre2_err_code;
- unsigned char pcre2_error[128];
- int pcre2_error_offset;
+ char pcre2_error[128];
+ size_t pcre2_error_offset;
#elif defined(HAVE_PCRE_H)
const char *pcre_error;
int pcre_error_offset;
@@ -1022,10 +1020,14 @@ _parse_include_if_config(const char *tok
goto err;
}
#if defined(HAVE_PCRE2_H)
- if_new->regex_ptr = pcre2_compile(if_new->name, PCRE2_ZERO_TERMINATED, 0,
- &pcre2_err_code, &pcre2_error_offset, NULL);
+ if_new->regex_ptr = pcre2_compile((const unsigned char *)if_new->name,
+ PCRE2_ZERO_TERMINATED, 0,
+ &pcre2_err_code, &pcre2_error_offset,
+ NULL);
if (!if_new->regex_ptr) {
- pcre2_get_error_message(pcre2_err_code, pcre2_error, 128);
+ pcre2_get_error_message(pcre2_err_code,
+ (unsigned char *)pcre2_error,
+ sizeof(pcre2_error));
config_perror(pcre2_error);
goto err;
}
--- a/agent/mibgroup/ucd-snmp/proc.c
+++ b/agent/mibgroup/ucd-snmp/proc.c
@@ -226,15 +226,17 @@ proc_parse_config(const char *token, cha
#if defined(HAVE_PCRE2_H) || defined(HAVE_PCRE_H)
cptr = skip_not_white(cptr);
if ((cptr = skip_white(cptr))) {
- DEBUGMSGTL(("ucd-snmp/regexp_proc", "Loading regex %s\n", cptr));
#ifdef HAVE_PCRE2_H
- unsigned char pcre2_error_msg[128];
+ char pcre2_error_msg[128];
int pcre2_err_code;
- int pcre2_error_offset;
+ size_t pcre2_error_offset;
+ DEBUGMSGTL(("ucd-snmp/regexp_proc", "Loading regex %s\n", cptr));
(*procp)->regexp.regex_ptr =
- pcre2_compile(cptr, PCRE2_ZERO_TERMINATED, 0, &pcre2_err_code, &pcre2_error_offset, NULL);
- pcre2_get_error_message(pcre2_err_code, pcre2_error_msg, 128);
+ pcre2_compile((const unsigned char *)cptr, PCRE2_ZERO_TERMINATED, 0, &pcre2_err_code, &pcre2_error_offset, NULL);
+ pcre2_get_error_message(pcre2_err_code,
+ (unsigned char *)pcre2_error_msg,
+ sizeof(pcre2_error_msg));
if ((*procp)->regexp.regex_ptr == NULL) {
config_perror(pcre2_error_msg);
}
@@ -242,6 +244,7 @@ proc_parse_config(const char *token, cha
const char *pcre_error;
int pcre_error_offset;
+ DEBUGMSGTL(("ucd-snmp/regexp_proc", "Loading regex %s\n", cptr));
(*procp)->regexp.regex_ptr =
pcre_compile(cptr, 0, &pcre_error, &pcre_error_offset, NULL);
if ((*procp)->regexp.regex_ptr == NULL) {
@@ -1,30 +0,0 @@
From e5aadf1e78c624a8e4147d4b70a7795497a50e73 Mon Sep 17 00:00:00 2001
From: Niels Baggesen <nba@users.sourceforge.net>
Date: Mon, 22 May 2023 18:44:36 +0200
Subject: [PATCH] if-mib/data_access/interface.c: plug a leak with pcre2
---
agent/mibgroup/if-mib/data_access/interface.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
--- a/agent/mibgroup/if-mib/data_access/interface.c
+++ b/agent/mibgroup/if-mib/data_access/interface.c
@@ -829,7 +829,7 @@ int netsnmp_access_interface_include(con
{
netsnmp_include_if_list *if_ptr;
#if defined(HAVE_PCRE2_H)
- pcre2_match_data *ndx_match = pcre2_match_data_create(3, NULL);
+ pcre2_match_data *ndx_match;
#elif defined(HAVE_PCRE_H)
int found_ndx[3];
#endif
@@ -844,6 +844,9 @@ int netsnmp_access_interface_include(con
*/
return TRUE;
+#if defined(HAVE_PCRE2_H)
+ ndx_match = pcre2_match_data_create(3, NULL);
+#endif
for (if_ptr = include_list; if_ptr; if_ptr = if_ptr->next) {
#if defined(HAVE_PCRE2_H)
+39 -49
View File
@@ -1,6 +1,6 @@
--- /dev/null
+++ b/agent/mibgroup/ieee802dot11.c
@@ -0,0 +1,4916 @@
@@ -0,0 +1,4915 @@
+/****************************************************************************
+* *
+* File Name: ieee802dot11.c *
@@ -30,7 +30,6 @@
+#include <net-snmp/agent/net-snmp-agent-includes.h>
+#include "ieee802dot11.h"
+#include "iwlib.h"
+#include "util_funcs/header_generic.h"
+
+/****************************************************************************
+* Defines *
@@ -3974,7 +3973,7 @@
+ rc = ioctl ( skfd, SIOCGIFHWADDR, &ifr );
+ if ( rc >= 0 ) {
+
+ sprintf ( MACAddress, "%02X:%02X:%02X:%02X:%02X:%02X",
+ sprintf ( MACAddress, "%02X:%02X:%02X:%02X:%02X:%02X\0",
+ ( UCHAR ) ifr.ifr_hwaddr.sa_data[0], ( UCHAR ) ifr.ifr_hwaddr.sa_data[1],
+ ( UCHAR ) ifr.ifr_hwaddr.sa_data[2], ( UCHAR ) ifr.ifr_hwaddr.sa_data[3],
+ ( UCHAR ) ifr.ifr_hwaddr.sa_data[4], ( UCHAR ) ifr.ifr_hwaddr.sa_data[5] );
@@ -3997,83 +3996,83 @@
+
+ if ( hasChanged (( char * ) &nSc, sizeof ( nSc ))) {
+ nSc.ifIndex = ifIndex;
+ sprintf ( nSc.UID, "%04ld", nSc.ifIndex );
+ sprintf ( nSc.UID, "%04d\0", nSc.ifIndex );
+ strcpy ( nSc.ifName, ifName );
+ addList (( char * ) &scList, ( char * ) &nSc, sizeof ( nSc ));
+ }
+
+ if ( hasChanged (( char * ) &nPr, sizeof ( nPr ))) {
+ nPr.ifIndex = ifIndex;
+ sprintf ( nPr.UID, "%04ld", nPr.ifIndex );
+ sprintf ( nPr.UID, "%04d\0", nPr.ifIndex );
+ strcpy ( nPr.ifName, ifName );
+ addList (( char * ) &prList, ( char * ) &nPr, sizeof ( nPr ));
+ }
+
+ if ( hasChanged (( char * ) &nOp, sizeof ( nOp ))) {
+ nOp.ifIndex = ifIndex;
+ sprintf ( nOp.UID, "%04ld", nOp.ifIndex );
+ sprintf ( nOp.UID, "%04d\0", nOp.ifIndex );
+ strcpy ( nOp.ifName, ifName );
+ addList (( char * ) &opList, ( char * ) &nOp, sizeof ( nOp ));
+ }
+
+ if ( hasChanged (( char * ) &nCo, sizeof ( nCo ))) {
+ nCo.ifIndex = ifIndex;
+ sprintf ( nCo.UID, "%04ld", nCo.ifIndex );
+ sprintf ( nCo.UID, "%04d\0", nCo.ifIndex );
+ strcpy ( nCo.ifName, ifName );
+ addList (( char * ) &coList, ( char * ) &nCo, sizeof ( nCo ));
+ }
+
+ if ( hasChanged (( char * ) &nRi, sizeof ( nRi ))) {
+ nRi.ifIndex = ifIndex;
+ sprintf ( nRi.UID, "%04ld", nRi.ifIndex );
+ sprintf ( nRi.UID, "%04d\0", nRi.ifIndex );
+ strcpy ( nRi.ifName, ifName );
+ addList (( char * ) &riList, ( char * ) &nRi, sizeof ( nRi ));
+ }
+
+ if ( hasChanged (( char * ) &nPo, sizeof ( nPo ))) {
+ nPo.ifIndex = ifIndex;
+ sprintf ( nPo.UID, "%04ld", nPo.ifIndex );
+ sprintf ( nPo.UID, "%04d\0", nPo.ifIndex );
+ strcpy ( nPo.ifName, ifName );
+ addList (( char * ) &poList, ( char * ) &nPo, sizeof ( nPo ));
+ }
+
+ if ( hasChanged (( char * ) &nPa, sizeof ( nPa ))) {
+ nPa.ifIndex = ifIndex;
+ sprintf ( nPa.UID, "%04ld", nPa.ifIndex );
+ sprintf ( nPa.UID, "%04d\0", nPa.ifIndex );
+ strcpy ( nPa.ifName, ifName );
+ addList (( char * ) &paList, ( char * ) &nPa, sizeof ( nPa ));
+ }
+
+ if ( hasChanged (( char * ) &nPt, sizeof ( nPt ))) {
+ nPt.ifIndex = ifIndex;
+ sprintf ( nPt.UID, "%04ld", nPt.ifIndex );
+ sprintf ( nPt.UID, "%04d\0", nPt.ifIndex );
+ strcpy ( nPt.ifName, ifName );
+ addList (( char * ) &ptList, ( char * ) &nPt, sizeof ( nPt ));
+ }
+
+ if ( hasChanged (( char * ) &nPf, sizeof ( nPf ))) {
+ nPf.ifIndex = ifIndex;
+ sprintf ( nPf.UID, "%04ld", nPf.ifIndex );
+ sprintf ( nPf.UID, "%04d\0", nPf.ifIndex );
+ strcpy ( nPf.ifName, ifName );
+ addList (( char * ) &pfList, ( char * ) &nPf, sizeof ( nPf ));
+ }
+
+ if ( hasChanged (( char * ) &nPd, sizeof ( nPd ))) {
+ nPd.ifIndex = ifIndex;
+ sprintf ( nPd.UID, "%04ld", nPd.ifIndex );
+ sprintf ( nPd.UID, "%04d\0", nPd.ifIndex );
+ strcpy ( nPd.ifName, ifName );
+ addList (( char * ) &pdList, ( char * ) &nPd, sizeof ( nPd ));
+ }
+
+ if ( hasChanged (( char * ) &nPi, sizeof ( nPi ))) {
+ nPi.ifIndex = ifIndex;
+ sprintf ( nPi.UID, "%04ld", nPi.ifIndex );
+ sprintf ( nPi.UID, "%04d\0", nPi.ifIndex );
+ strcpy ( nPi.ifName, ifName );
+ addList (( char * ) &piList, ( char * ) &nPi, sizeof ( nPi ));
+ }
+ }
+
+//printf ( "%s - ifIndex: %ld ifName: %s UID: %s\n",
+//printf ( "%s - ifIndex: %d ifName: %s UID: %s\n",
+// "load80211Structs() - HASCHANGED", ifIndex, ifName, nSc.UID );
+}
+
@@ -4164,7 +4163,7 @@
+ nAa.ifIndex = ifIndex;
+ nAa.authenticationAlgorithmsIndex = 1; // index number one
+ nAa.authenticationAlgorithm = 1; // 1 => open key
+ sprintf ( nAa.UID, "%04ld%04ld", nAa.ifIndex, nAa.authenticationAlgorithmsIndex );
+ sprintf ( nAa.UID, "%04d%04d\0", nAa.ifIndex, nAa.authenticationAlgorithmsIndex );
+ nAa.authenticationAlgorithmsEnable = 1; // enabled by default
+ if ( ( wi->has_key ) &&
+ ( wi->key_size != 0 ) &&
@@ -4177,7 +4176,7 @@
+ nAa.ifIndex = ifIndex;
+ nAa.authenticationAlgorithmsIndex = 2; // index number 2
+ nAa.authenticationAlgorithm = 2; // 2 => shared key
+ sprintf ( nAa.UID, "%04ld%04ld", nAa.ifIndex, nAa.authenticationAlgorithmsIndex );
+ sprintf ( nAa.UID, "%04d%04d\0", nAa.ifIndex, nAa.authenticationAlgorithmsIndex );
+ nAa.authenticationAlgorithmsEnable = 2;
+ if ( ( wi->has_key ) &&
+ ( wi->key_size != 0 ) &&
@@ -4191,7 +4190,7 @@
+ nDf.haveWEPDefaultKeyValue = TRUE;
+ nDf.ifIndex = ifIndex;
+ nDf.WEPDefaultKeyIndex = i + 1; // index number
+ sprintf ( nDf.UID, "%04ld%04ld", nDf.ifIndex, nDf.WEPDefaultKeyIndex );
+ sprintf ( nDf.UID, "%04d%04d\0", nDf.ifIndex, nDf.WEPDefaultKeyIndex );
+ if ( wep[i].haveKey )
+ strcpy ( nDf.WEPDefaultKeyValue, "*****" );
+ else
@@ -4256,7 +4255,7 @@
+ nRt.supportedDataRatesTxIndex = i + 1;
+ nRt.supportedDataRatesTxValue = wi->range.bitrate[i] / 500000L;
+ nRt.haveSupportedDataRatesTxValue = TRUE;
+ sprintf ( nRt.UID, "%04ld%04ld", nRt.ifIndex, nRt.supportedDataRatesTxIndex );
+ sprintf ( nRt.UID, "%04d%04d\0", nRt.ifIndex, nRt.supportedDataRatesTxIndex );
+ strcpy ( nRt.ifName, ifName );
+ addList (( char * ) &rtList, ( char * ) &nRt, sizeof ( nRt ));
+ }
@@ -4269,7 +4268,7 @@
+ nRr.supportedDataRatesRxIndex = i + 1;
+ nRr.supportedDataRatesRxValue = wi->range.bitrate[i] / 500000L;
+ nRr.haveSupportedDataRatesRxValue = TRUE;
+ sprintf ( nRr.UID, "%04ld%04ld", nRr.ifIndex, nRr.supportedDataRatesRxIndex );
+ sprintf ( nRr.UID, "%04d%04d\0", nRr.ifIndex, nRr.supportedDataRatesRxIndex );
+ strcpy ( nRr.ifName, ifName );
+ addList (( char * ) &rrList, ( char * ) &nRr, sizeof ( nRr ));
+ }
@@ -4442,22 +4441,22 @@
+ s = bfr;
+ s = strchr ( s, ':' ); s++; /* Skip ethX: */
+ s = strtok ( s, " " ); /* ' ' => '\0' */
+ sscanf ( s, "%hX", &wi->stats.status ); // status
+ sscanf ( s, "%X", &wi->stats.status ); // status
+
+ s = strtok ( NULL, " " ); // link quality
+ if ( strchr ( s, '.' ) != NULL )
+ wi->stats.qual.updated |= 1;
+ sscanf ( s, "%hhd", &wi->stats.qual.qual );
+ sscanf ( s, "%d", &wi->stats.qual.qual );
+
+ s = strtok ( NULL, " " ); // signal level
+ if ( strchr ( s,'.' ) != NULL )
+ wi->stats.qual.updated |= 2;
+ sscanf ( s, "%hhd", &wi->stats.qual.level );
+ sscanf ( s, "%d", &wi->stats.qual.level );
+
+ s = strtok ( NULL, " " ); // noise level
+ if ( strchr ( s, '.' ) != NULL )
+ wi->stats.qual.updated += 4;
+ sscanf ( s, "%hhd", &wi->stats.qual.noise );
+ sscanf ( s, "%d", &wi->stats.qual.noise );
+
+ s = strtok ( NULL, " " ); sscanf ( s, "%d", &wi->stats.discard.nwid );
+ s = strtok ( NULL, " " ); sscanf ( s, "%d", &wi->stats.discard.code );
@@ -4563,12 +4562,12 @@
+ printf ( "%s %s\n", "SIOCGIWFREQ", " ===> no info.freq support" );
+
+ if ( info.has_sens )
+ printf ( "%s sens: %" PRIdPTR "\n", "SIOCGIWSENS", *(intptr_t *)&info.sens );
+ printf ( "%s sens: %d\n", "SIOCGIWSENS", info.sens );
+ else
+ printf ( "%s %s\n", "SIOCGIWSENS", " ===> no info.sens support" );
+
+ if ( info.has_key ) {
+ printf ( "%s key_size: %d key_flags: %d wepCurrentKey: %ld\n",
+ printf ( "%s key_size: %d key_flags: %d wepCurrentKey: %d\n",
+ "SIOCGIWENCODE", info.key_size, info.key_flags, wepCurrentKey );
+ printf ( "%s MODE: %d DISABLED: %d INDEX: %d OPEN: %d RESTRICTED: %d NOKEY: %d TEMP: %d\n",
+ "SIOCGIWENCODE", info.key_flags & IW_ENCODE_MODE,
@@ -4581,7 +4580,7 @@
+
+ for ( i = 0; i < MAX_WEP_KEYS; i++ ) {
+ if ( wep[i].haveKey )
+ printf ( "%s wep[%d].len: %ld wep[%d].key: %s\n",
+ printf ( "%s wep[%d].len: %d wep[%d].key: %s\n",
+ "SIOCGIWENCODE", i, wep[i].len, i, wep[i].key );
+ }
+
@@ -4595,19 +4594,19 @@
+ printf ( "%s %s\n", "SIOCGIWAP", " ===> no ap_addr information" );
+
+ if ( info.has_bitrate )
+ printf ( "%s bitrate: %" PRIdPTR " value: %d fixed: %d disabled: %d flags: %d\n",
+ "SIOCGIWRATE", *(intptr_t *)&info.bitrate, info.bitrate.value, info.bitrate.fixed,
+ printf ( "%s bitrate: %d value: %d fixed: %d disabled: %d flags: %d\n",
+ "SIOCGIWRATE", info.bitrate, info.bitrate.value, info.bitrate.fixed,
+ info.bitrate.disabled, info.bitrate.flags );
+ else
+ printf ( "%s %s\n", "SIOCGIWRATE", " ===> no info.bitrate support" );
+
+ if ( info.has_rts )
+ printf ( "%s rts: %" PRIdPTR "\n", "SIOCGIWRTS", *(intptr_t *)&info.rts );
+ printf ( "%s rts: %d\n", "SIOCGIWRTS", info.rts );
+ else
+ printf ( "%s %s\n", "SIOCGIWRTS", " ===> no info.rts support" );
+
+ if ( info.has_frag )
+ printf ( "%s frag: %" PRIdPTR "\n", "SIOCGIWFRAG", *(intptr_t *)&info.frag );
+ printf ( "%s frag: %d\n", "SIOCGIWFRAG", info.frag );
+ else
+ printf ( "%s %s\n", "SIOCGIWFRAG", " ===> no info.frag support" );
+
@@ -4617,7 +4616,7 @@
+ printf ( "%s %s\n", "SIOCGIWMODE", " ===> no info.mode support" );
+
+ if ( info.has_power ) {
+ printf ( "%s power: %" PRIdPTR "\n", "SIOCGIWPOWER", *(intptr_t *)&info.power );
+ printf ( "%s power: %d\n", "SIOCGIWPOWER", info.power );
+ printf ( "%s disabled: %d MIN: %d MAX: %d TIMEOUT: %d RELATIVE: %d\n",
+ "SIOCGIWPOWER",
+ info.power.disabled ? 1:0,
@@ -4637,7 +4636,7 @@
+ printf ( "%s %s\n", "SIOCGIWPOWER", " ===> no info.power support" );
+
+ if ( info.has_retry )
+ printf ( "%s retry: %" PRIdPTR "\n", "SIOCGIWRETRY", *(intptr_t *)&info.retry );
+ printf ( "%s retry: %d\n", "SIOCGIWRETRY", info.retry );
+ else
+ printf ( "%s %s\n", "SIOCGIWRETRY", " ===> no info.retry support" );
+
@@ -4701,12 +4700,12 @@
+addList ( char *l, char *data, int len )
+{
+ char uid[256];
+ avList_t *list;
+ LIST_HEAD ( , avNode ) *list;
+
+ // NOTE: this assumes the UID is at the beginning of the
+ // data structure and that UIDs are strings
+
+ list = ( avList_t * ) l; // NOTE: don't know how to get
+ list = ( LIST_HEAD ( , avNode ) * ) l; // NOTE: don't know how to get
+ strcpy ( uid, data ); // rid of compiler warning on
+ // LISTHEAD typecast
+ // create a new node and the data that goes in it
@@ -4788,9 +4787,9 @@
+****************************************************************************/
+static void flushList ( char *l )
+{
+ avList_t *list;
+ LIST_HEAD ( , avNode ) *list;
+
+ list = ( avList_t * ) l; // NOTE: don't know how to get
+ list = ( LIST_HEAD ( , avNode ) * ) l; // NOTE: don't know how to get
+ while ( !LIST_EMPTY ( list )) { // rid of compiler warning on
+ np = LIST_FIRST ( list ); // LISTHEAD typecast
+ if ( np->data )
@@ -4919,7 +4918,7 @@
+
--- /dev/null
+++ b/agent/mibgroup/ieee802dot11.h
@@ -0,0 +1,732 @@
@@ -0,0 +1,730 @@
+/****************************************************************************
+* *
+* File Name: ieee802dot11.h *
@@ -5025,7 +5024,7 @@
+/****************************************************************************
+* Linked List Structure *
+****************************************************************************/
+struct avNode {
+static struct avNode {
+ LIST_ENTRY ( avNode ) nodes;
+ char *data; // pointer to data
+};
@@ -5649,12 +5648,10 @@
+WriteMethod write_dot11SupportedRxAntenna;
+WriteMethod write_dot11DiversitySelectionRx;
+
+void shutdown_ieee802dot11 ( void );
+
+#endif /* _MIBGROUP_IEEE802DOT11_H */
--- /dev/null
+++ b/agent/mibgroup/iwlib.h
@@ -0,0 +1,509 @@
@@ -0,0 +1,502 @@
+/*
+ * Wireless Tools
+ *
@@ -5686,9 +5683,6 @@
+#include <unistd.h>
+#include <netdb.h> /* gethostbyname, getnetbyname */
+#include <net/ethernet.h> /* struct ether_addr */
+#ifdef HAVE_NET_IF_H
+#include <net/if.h>
+#endif
+#include <sys/time.h> /* struct timeval */
+#include <unistd.h>
+
@@ -5745,10 +5739,6 @@
+ && LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0)
+#define LIBC5_HEADERS
+
+/* Musl */
+#elif !defined(__GLIBC__) && LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,0)
+#define GENERIC_HEADERS
+
+/* Unsupported combination */
+#else
+#error "Your kernel/libc combination is not supported"
-10
View File
@@ -1,10 +0,0 @@
--- a/agent/mib_modules.c
+++ b/agent/mib_modules.c
@@ -42,6 +42,7 @@
#include <net-snmp/agent/table.h>
#include <net-snmp/agent/table_iterator.h>
#include "mib_module_includes.h"
+#include "mibgroup/ieee802dot11.h"
static int need_shutdown = 0;
+3 -3
View File
@@ -1,8 +1,8 @@
--- a/agent/mibgroup/iwlib.h
+++ b/agent/mibgroup/iwlib.h
@@ -92,6 +92,10 @@
#elif !defined(__GLIBC__) && LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,0)
#define GENERIC_HEADERS
@@ -85,6 +85,10 @@
&& LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0)
#define LIBC5_HEADERS
+/* Musl */
+#elif !defined(__GLIBC__) && LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,0)
@@ -1,130 +0,0 @@
--- a/configure.d/config_modules_agent
+++ b/configure.d/config_modules_agent
@@ -27,8 +27,6 @@ done
#
AC_MSG_CHECKING([for and configuring mib modules to use])
-AH_TOP([#define NETSNMP_REQUIRE_SEMICOLON extern void netsnmp_unused_function(void)])
-
# set up the CPP command
MODULECPP="$CPP $PARTIALTARGETFLAGS $CPPFLAGS -DNETSNMP_FEATURE_CHECKING -I${srcdir}/include -I${srcdir}/agent/mibgroup"
if test "x$enable_mfd_rewrites" = "xyes"; then
@@ -194,7 +192,7 @@ while test "x$new_module_list" != "x"; d
# - mib_module => libnetsnmpmibs (default)
# - agent_module => libnetsnmpagent
#
- AH_TOP([#define config_belongs_in(x) NETSNMP_REQUIRE_SEMICOLON])
+ AH_TOP([#define config_belongs_in(x)])
module_type=mib_module
if test -f $srcdir/$mibdir/$i.h; then
changequote(, )
@@ -279,7 +277,7 @@ while test "x$new_module_list" != "x"; d
#
# check if $i has any conflicts
#
- AH_TOP([#define config_exclude(x) NETSNMP_REQUIRE_SEMICOLON])
+ AH_TOP([#define config_exclude(x)])
new_list_excl=`$MODULECPP module_tmp_header.h | \
$SED -n 's/.*config_exclude(\(.*\)).*/\1/p'`
if test "x$new_list_excl" != "x"; then
@@ -308,7 +306,7 @@ while test "x$new_module_list" != "x"; d
#
# check if $i has any architecture specific requirements
#
- AH_TOP([#define config_arch_require(x,y) NETSNMP_REQUIRE_SEMICOLON])
+ AH_TOP([#define config_arch_require(x,y)])
changequote(, )
new_list_arch=`$MODULECPP module_tmp_header.h | \
$SED -n 's/.*config_arch_require( *\([^ ]*\) *, *\([^ ]*\) *).*/\1-xarchx-\2/p'`
@@ -330,7 +328,7 @@ while test "x$new_module_list" != "x"; d
# macro: config_version_require((base, version, version-modules, ...))
# - lists alternative modules used from different versions.
#
- AH_TOP([#define config_version_require(x) NETSNMP_REQUIRE_SEMICOLON])
+ AH_TOP([#define config_version_require(x)])
[new_list_alt3=`$MODULECPP module_tmp_header.h | \
$AWK '
BEGIN {
@@ -372,7 +370,7 @@ while test "x$new_module_list" != "x"; d
#
# check if $i has any other required modules
#
- AH_TOP([#define config_require(x) NETSNMP_REQUIRE_SEMICOLON])
+ AH_TOP([#define config_require(x)])
new_list="$new_list `$MODULECPP module_tmp_header.h | \
$SED -n 's/.*config_require(\(.*\)).*/\1/p'`"
AC_MSG_MODULE_DBG(" $i will test: $new_list")
@@ -409,7 +407,7 @@ while test "x$new_module_list" != "x"; d
#
# check if $i has any mibs to add
#
- AH_TOP([#define config_add_mib(x) NETSNMP_REQUIRE_SEMICOLON])
+ AH_TOP([#define config_add_mib(x)])
new_mibs=`$MODULECPP module_tmp_header.h | \
$SED -n 's/.*config_add_mib(\(.*\)).*/\1/p'`
if test "x$new_mibs" != "x"; then
@@ -456,7 +454,7 @@ while test "x$new_module_list" != "x"; d
# check for config_parse_dot_conf
# (generally not used any longer; old auto-load a .conf token)
#
- AH_TOP([#define config_parse_dot_conf(w,x,y,z) NETSNMP_REQUIRE_SEMICOLON])
+ AH_TOP([#define config_parse_dot_conf(w,x,y,z)])
changequote(, )
$MODULECPP module_tmp_header.h | \
$SED -n 's@.*config_parse_dot_conf(\([^)]*\), *\([^),]*\), *\([^),]*\), *\([^),]*\)).*@register_config_handler("snmpd",\1, \2, \3, \4);@p' >> $mibdir/mib_module_dot_conf.h
@@ -468,7 +466,7 @@ while test "x$new_module_list" != "x"; d
#
# check if $i has any errors, or warnings
#
- AH_TOP([#define config_error(x) NETSNMP_REQUIRE_SEMICOLON])
+ AH_TOP([#define config_error(x)])
error=`$MODULECPP module_tmp_header.h | \
$SED -n 's/.*config_error(\(.*\)).*/\1/p'`
if test "x$error" != "x"; then
@@ -481,7 +479,7 @@ while test "x$new_module_list" != "x"; d
# macro: config_warning(warning text)
# - used to signal a configuration "warning" to be printed to the user
#
- AH_TOP([#define config_warning(x) NETSNMP_REQUIRE_SEMICOLON])
+ AH_TOP([#define config_warning(x)])
warning=`$MODULECPP module_tmp_header.h | \
$SED -n 's/.*config_warning(\(.*\)).*/\1/p'`
if test "x$warning" != "x"; then
--- a/include/net-snmp/net-snmp-config.h.in
+++ b/include/net-snmp/net-snmp-config.h.in
@@ -36,25 +36,25 @@
/* definitions added by configure on-the-fly */
-#define config_parse_dot_conf(w,x,y,z) NETSNMP_REQUIRE_SEMICOLON
+#define config_parse_dot_conf(w,x,y,z)
-#define config_error(x) NETSNMP_REQUIRE_SEMICOLON
+#define config_error(x)
-#define config_warning(x) NETSNMP_REQUIRE_SEMICOLON
+#define config_warning(x)
-#define NETSNMP_REQUIRE_SEMICOLON extern void netsnmp_unused_function(void)
+#define extern void netsnmp_unused_function(void)
-#define config_belongs_in(x) NETSNMP_REQUIRE_SEMICOLON
+#define config_belongs_in(x)
-#define config_exclude(x) NETSNMP_REQUIRE_SEMICOLON
+#define config_exclude(x)
-#define config_arch_require(x,y) NETSNMP_REQUIRE_SEMICOLON
+#define config_arch_require(x,y)
-#define config_version_require(x) NETSNMP_REQUIRE_SEMICOLON
+#define config_version_require(x)
-#define config_require(x) NETSNMP_REQUIRE_SEMICOLON
+#define config_require(x)
-#define config_add_mib(x) NETSNMP_REQUIRE_SEMICOLON
+#define config_add_mib(x)
/* Define to 1 if using 'alloca.c'. */
#undef C_ALLOCA
+1 -1
View File
@@ -3,7 +3,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=powersupply
PKG_VERSION:=1
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_BUILD_DIR:=$(BUILD_DIR)/powersupply
include $(INCLUDE_DIR)/package.mk
+3 -3
View File
@@ -1,10 +1,10 @@
config system 'system'
option poe_out_power_gpio '627'
option poe_out_power_gpio '403'
option poe_out_power '0'
option poe_out_control '1'
option usb_power_gpio '629'
option usb_power_gpio '405'
option usb_power '1'
option usb_control '1'
option ext_power_gpio '626'
option ext_power_gpio '402'
option ext_power '0'
+5 -10
View File
@@ -2,9 +2,8 @@
START=11
STOP=10
USE_PROCD=1
start_service() {
start() {
poe_out_power_enabled="$(uci -q get powersupply.system.poe_out_power)"
poe_out_power_gpio="$(uci -q get powersupply.system.poe_out_power_gpio)"
voltage_threshold="$(cat /sys/class/i2c-dev/i2c-0/device/0-0011/voltage_threshold)"
@@ -28,7 +27,7 @@ start_service() {
echo $usb_power_control > /sys/class/i2c-dev/i2c-0/device/0-0011/usb_control
}
stop_service() {
stop() {
poe_out_power_gpio="$(uci -q get powersupply.system.poe_out_power_gpio)"
echo 0 > /sys/class/gpio/gpio$poe_out_power_gpio/value
@@ -50,13 +49,9 @@ boot() {
}
shutdown() {
stop_service
stop
}
service_triggers() {
procd_add_reload_trigger "powersupply"
}
reload_service() {
restart
restart() {
start
}
+76
View File
@@ -0,0 +1,76 @@
#
# OpenWrt package recipe for RMS IoT device management agent.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=rms
PKG_VERSION:=1.0.0
PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=git@gitlab.corp.teleofis.ru:stargate-v1/stargate-agent.git
PKG_SOURCE_VERSION:=834403219fa4061aa24f0e2c708c61c70d0f36a0
PKG_SOURCE_DATE:=2026-07-03
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_LICENSE:=Proprietary
PKG_MAINTAINER:=RMS
include $(INCLUDE_DIR)/package.mk
define Package/rms
SECTION:=net
CATEGORY:=Network
TITLE:=RMS device management agent
URL:=$(PKG_SOURCE_URL)
DEPENDS:=+libmosquitto-ssl +libjson-c +libopenssl +libuuid
endef
define Package/rms/description
RMS provides remote management of devices via MQTT/TLS
endef
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) \
CC="$(TARGET_CC)" \
CFLAGS="$(TARGET_CFLAGS) -I$(STAGING_DIR)/usr/include -I$(PKG_BUILD_DIR)/include" \
LDFLAGS="$(TARGET_LDFLAGS) -L$(STAGING_DIR)/usr/lib"
endef
define Package/rms/conffiles
/etc/config/rms
/etc/rms/*
endef
define Package/rms/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/rms-agent $(1)/usr/sbin/rms-agent
$(INSTALL_BIN) $(PKG_BUILD_DIR)/rms-telemetry $(1)/usr/sbin/rms-telemetry
$(INSTALL_DIR) $(1)/etc/rms
$(INSTALL_DATA) $(PKG_BUILD_DIR)/config/blacklist.txt $(1)/etc/rms/
$(INSTALL_DATA) $(PKG_BUILD_DIR)/config/deferred.conf $(1)/etc/rms/
$(INSTALL_DATA) $(PKG_BUILD_DIR)/config/payload.*.csv $(1)/etc/rms/
$(INSTALL_DATA) $(PKG_BUILD_DIR)/config/metrics.csv $(1)/etc/rms/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/config/apply_config.sh $(1)/etc/rms/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/config/storage_classify.sh $(1)/etc/rms/
$(INSTALL_DIR) $(1)/etc/rms/certs
$(INSTALL_DATA) $(PKG_BUILD_DIR)/config/bootstrap/ca.crt $(1)/etc/rms/certs/
$(INSTALL_DATA) $(PKG_BUILD_DIR)/config/bootstrap/bootstrap.crt $(1)/etc/rms/certs/
$(INSTALL_DATA) $(PKG_BUILD_DIR)/config/bootstrap/bootstrap.key $(1)/etc/rms/certs/
$(INSTALL_DIR) $(1)/etc/rms/certs/selfhosted
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) $(PKG_BUILD_DIR)/config/openwrt/rms-agent.init $(1)/etc/init.d/rms-agent
$(INSTALL_BIN) $(PKG_BUILD_DIR)/config/openwrt/rms-telemetry.init $(1)/etc/init.d/rms-telemetry
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) $(PKG_BUILD_DIR)/config/rms.config $(1)/etc/config/rms
endef
$(eval $(call BuildPackage,rms))
+1 -1
View File
@@ -3,7 +3,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=smscontrol
PKG_VERSION:=1
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_BUILD_DIR:=$(BUILD_DIR)/smscontrol
include $(INCLUDE_DIR)/package.mk
+5 -11
View File
@@ -1,8 +1,6 @@
#!/bin/sh /etc/rc.common
START=90
USE_PROCD=1
DIR="/var/spool/smscontrol"
COMMANDS="/var/spool/smscontrol/commands"
CALLS="/var/spool/smscontrol/calls"
@@ -101,14 +99,14 @@ add_cli() {
fi
}
stop_service() {
stop() {
rm "$COMMANDS" 2>/dev/null
rm "$CALLS" 2>/dev/null
rm "$CLI" 2>/dev/null
/etc/init.d/smstools3 stop
}
start_service() {
start() {
config_load smscontrol
generate_pass
enabled=$(uci get smscontrol.common.enabled)
@@ -130,11 +128,7 @@ start_service() {
fi
}
service_triggers() {
procd_add_reload_trigger "smscontrol"
}
reload_service() {
stop_service
start_service
restart() {
stop
start
}
+102
View File
@@ -0,0 +1,102 @@
#
# Copyright (C) 2006-2015 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=zabbix-ssl
PKG_VERSION:=5.0.8
PKG_RELEASE:=1
PKG_SOURCE:=zabbix-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://cdn.zabbix.com/zabbix/sources/stable/5.0/
PKG_HASH:=skip
PKG_BUILD_DIR=$(BUILD_DIR)/zabbix-$(PKG_VERSION)
PKG_MAINTAINER:=Etienne CHAMPETIER <champetier.etienne@gmail.com>
PKG_LICENSE:=GPL-2.0
PKG_LICENSE_FILES:=COPYING
PKG_CPE_ID:=cpe:/a:zabbix:zabbix
PKG_INSTALL:=1
PKG_BUILD_PARALLEL:=1
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/nls.mk
define Package/zabbix-ssl/Default
SECTION:=admin
CATEGORY:=Administration
SUBMENU:=Zabbix
TITLE:=Zabbix-ssl
URL:=https://www.zabbix.com/
USERID:=zabbix=53:zabbix=53
DEPENDS += $(ICONV_DEPENDS) +libpcre2 +zlib +libopenssl +libmariadbclient
endef
define Package/zabbix-agentd-ssl
$(call Package/zabbix-ssl/Default)
TITLE+= agentd-ssl
DEPENDS += +libpq
endef
CONFIGURE_ARGS+= \
--enable-agent \
--enable-proxy \
$(call autoconf_bool,CONFIG_IPV6,ipv6) \
--disable-java \
--with-mysql \
--with-libevent=$(STAGING_DIR)/usr/include/libevent \
--with-libpcre=$(STAGING_DIR)/usr/include \
--with-zlib=$(STAGING_DIR)/usr/include \
--with-openssl="$(STAGING_DIR)/usr"
CONFIGURE_VARS += \
ac_cv_header_sys_sysinfo_h=no
MAKE_FLAGS += ARCH="linux"
define Package/zabbix-ssl/install/sbin
$(INSTALL_DIR) \
$(1)/usr/sbin
$(INSTALL_BIN) \
$(PKG_INSTALL_DIR)/usr/sbin/zabbix_$(2) \
$(1)/usr/sbin/
endef
define Package/zabbix-ssl/install/bin
$(INSTALL_DIR) \
$(1)/usr/bin
$(INSTALL_BIN) \
$(PKG_INSTALL_DIR)/usr/bin/zabbix_$(2) \
$(1)/usr/bin/
endef
define Package/zabbix-ssl/install/etc
$(INSTALL_DIR) \
$(1)/etc
$(INSTALL_CONF) \
$(PKG_INSTALL_DIR)/etc/zabbix_$(2).conf \
$(1)/etc/
endef
define Build/Prepare
$(call Build/Prepare/Default)
endef
define Build/Compile
$(call Build/Compile/Default)
endef
define Package/zabbix-agentd-ssl/install
$(INSTALL_DIR) $(1)/etc/zabbix_agentd.conf.d
$(call Package/zabbix-ssl/install/sbin,$(1),agentd)
endef
$(eval $(call BuildPackage,zabbix-agentd-ssl))
+29
View File
@@ -0,0 +1,29 @@
#see https://openwrt.org/docs/guide-user/services/network_monitoring/zabbix for ready to use templates
# If you want to know the exact meaning of an UserParameter, you can search in the ieee80211 standard:
# https://standards.ieee.org/getieee802/download/802.11-2012.pdf
# example: for mac80211.ACKFailureCount search for dot11ACKFailureCount (page 2145)
# mac80211 phy discovery (like 'phy0')
# example: {"data":[{"{#PHY}":"phy0"}]}
#
UserParameter=mac80211.phydiscovery,zabbix_helper_mac80211 discovery
#phy statistics (you need {#PHY} as parameter)
#
UserParameter=mac80211.ACKFailureCount[*],zabbix_helper_mac80211 $1 dot11ACKFailureCount
UserParameter=mac80211.FCSErrorCount[*],zabbix_helper_mac80211 $1 dot11FCSErrorCount
UserParameter=mac80211.RTSFailureCount[*],zabbix_helper_mac80211 $1 dot11RTSFailureCount
UserParameter=mac80211.RTSSuccessCount[*],zabbix_helper_mac80211 $1 dot11RTSSuccessCount
# hidden behind MAC80211_DEBUG_COUNTERS
UserParameter=mac80211.FailedCount[*],zabbix_helper_mac80211 $1 dot11FailedCount
UserParameter=mac80211.FrameDuplicateCount[*],zabbix_helper_mac80211 $1 dot11FrameDuplicateCount
UserParameter=mac80211.MulticastReceivedFrameCount[*],zabbix_helper_mac80211 $1 dot11MulticastReceivedFrameCount
UserParameter=mac80211.MulticastTransmittedFrameCount[*],zabbix_helper_mac80211 $1 dot11MulticastTransmittedFrameCount
UserParameter=mac80211.MultipleRetryCount[*],zabbix_helper_mac80211 $1 dot11MultipleRetryCount
UserParameter=mac80211.ReceivedFragmentCount[*],zabbix_helper_mac80211 $1 dot11ReceivedFragmentCount
UserParameter=mac80211.RetryCount[*],zabbix_helper_mac80211 $1 dot11RetryCount
UserParameter=mac80211.TransmittedFragmentCount[*],zabbix_helper_mac80211 $1 dot11TransmittedFragmentCount
UserParameter=mac80211.TransmittedFrameCount[*],zabbix_helper_mac80211 $1 dot11TransmittedFrameCount
+6
View File
@@ -0,0 +1,6 @@
#see https://openwrt.org/docs/guide-user/services/network_monitoring/zabbix for ready to use templates
# network interface discovery
# example: {"data":[{"{#IF}":"lo", "{#NET}":"loopback"},{"{#IF}":"br-lan", "{#NET}":"lan"},{"{#IF}":"eth0.1", "{#NET}":"wan"}]}
#
UserParameter=netowrt.discovery,lua -l ubus -e 'u=ubus.connect();list="{\"data\":[";dump=u:call("network.interface", "dump", {});for _, intf in ipairs(dump.interface) do list=list.."{\"{#IF}\":\""..intf.device.."\", \"{#NET}\":\""..intf.interface.."\"},";end;list=string.gsub(list,",$","");print(list.."]}")'
+24
View File
@@ -0,0 +1,24 @@
#see https://openwrt.org/docs/guide-user/services/network_monitoring/zabbix for ready to use templates
# wifi interface discovery
# example: {"data":[{"{#IF}":"wlan0", "{#MODE}":"ap", "{#SSID}":"Openwrt", "{#NET}":"lan", "{#DEV}":"radio0", "{#ENC}":"psk2+ccmp", "{#TYPE}":"mac80211", "{#HWMODE}":"11ng", "{#CHANNEL}":"11", "{#BSSID}":"xx:xx:xx:xx:xx:xx"}]}
UserParameter=wifi.ifdiscovery, lua -l ubus -l iwinfo -e 'u=ubus.connect();list="{\"data\":[";stat=u:call("network.wireless", "status", {});for dev, dev_table in pairs(stat) do for i, iface in pairs(dev_table["interfaces"]) do c=iface["config"];i=iface["ifname"];t=iwinfo.type(i);iw=iwinfo[t];e = iw.encryption(i);e = e and e.description or "None";n = table.concat(c["network"]," ");list=list.."{\"{#IF}\":\""..i.."\", \"{#MODE}\":\""..iw.mode(i).."\", \"{#SSID}\":\""..c["ssid"].."\", \"{#NET}\":\""..n.."\", \"{#DEV}\":\""..dev.."\", \"{#ENC}\":\""..e.."\", \"{#TYPE}\":\""..t.."\", \"{#HWMODE}\":\"".."?".."\", \"{#CHANNEL}\":\""..iw.channel(i).."\", \"{#BSSID}\":\""..iw.bssid(i).."\"},";end;end;list=string.gsub(list,",$","");print(list.."]}")'
#iwinfo info (you need {#IF} as parameter, like 'wlan0')
UserParameter=wifi.iwinfo.channel[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].channel('$1'))"
UserParameter=wifi.iwinfo.frequency[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].frequency('$1'))"
UserParameter=wifi.iwinfo.txpower[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].txpower('$1'))"
UserParameter=wifi.iwinfo.bitrate[*],lua -l iwinfo -e "b = iwinfo[iwinfo.type('$1')].bitrate('$1'); print(b or '0')"
UserParameter=wifi.iwinfo.signal[*],lua -l iwinfo -e "s = iwinfo[iwinfo.type('$1')].signal('$1'); print(s or '-255')"
UserParameter=wifi.iwinfo.noise[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].noise('$1'))"
UserParameter=wifi.iwinfo.quality[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].quality('$1'))"
UserParameter=wifi.iwinfo.quality_max[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].quality_max('$1'))"
UserParameter=wifi.iwinfo.mode[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].mode('$1'))"
UserParameter=wifi.iwinfo.ssid[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].ssid('$1'))"
UserParameter=wifi.iwinfo.bssid[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].bssid('$1'))"
UserParameter=wifi.iwinfo.country[*],lua -l iwinfo -e "print(iwinfo[iwinfo.type('$1')].country('$1'))"
UserParameter=wifi.iwinfo.nbusers[*],lua -l iwinfo -e "n = 0; for _,_ in pairs(iwinfo[iwinfo.type('$1')].assoclist('$1')) do n = n + 1 end; print(n)"
UserParameter=wifi.iwinfo.encryption[*],lua -l iwinfo -e "e = iwinfo[iwinfo.type('$1')].encryption('$1'); print(e and e.description or 'None')"
UserParameter=wifi.iwinfo.hwmode[*],lua -l iwinfo -e "x=iwinfo[iwinfo.type('$1')].hwmodelist('$1'); print((x.a and 'a' or '')..(x.b and 'b' or '')..(x.g and 'g' or '')..(x.n and 'n' or ''))"
@@ -0,0 +1,8 @@
{
"user": "zabbix",
"access": {
"network.interface": {
"methods": [ "dump" ]
}
}
}
@@ -0,0 +1,8 @@
{
"user": "zabbix",
"access": {
"network.wireless": {
"methods": [ "status" ]
}
}
}
+77
View File
@@ -0,0 +1,77 @@
#define _GNU_SOURCE
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <dirent.h>
#include <stdbool.h>
int discovery()
{
DIR *dir;
struct dirent *ent;
bool comma = false;
if ((dir = opendir ("/sys/kernel/debug/ieee80211/")) != NULL) {
printf("{\"data\":[");
while ((ent = readdir (dir)) != NULL) {
if (strcmp(".", ent->d_name) && strcmp("..", ent->d_name)) {
if (comma)
printf(",");
printf("{\"{#PHY}\":\"%s\"}", ent->d_name);
comma = true;
}
}
printf("]}\n");
closedir(dir);
} else {
perror("");
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
int get_param(char *phy, char *stat)
{
char *filename = NULL;
FILE *f = NULL;
phy = basename(phy);
stat = basename(stat);
if (asprintf(&filename, "/sys/kernel/debug/ieee80211/%s/statistics/%s", phy, stat) > 0)
f = fopen(filename, "r");
if (f != NULL) {
char temp[256];
while (fgets(temp, 256, f) != NULL)
printf("%s",temp);
fclose(f);
} else {
perror("");
return EXIT_FAILURE;
}
free(filename);
return EXIT_SUCCESS;
}
int usage(char *name)
{
fprintf(stderr, "Usage:\n");
fprintf(stderr, " %s discovery\n", name);
fprintf(stderr, " => print mac80211.phydiscovery discovery rule\n");
fprintf(stderr, " %s PHY STAT\n", name);
fprintf(stderr, " => cat /sys/kernel/debug/ieee80211/PHY/statistics/STAT as root\n");
return EXIT_FAILURE;
}
int main(int argc, char *argv[])
{
switch (argc) {
case 2:
return discovery();
case 3:
return get_param(argv[1], argv[2]);
default:
return usage(argv[0]);
}
}
@@ -0,0 +1,11 @@
--- a/src/libs/zbxcommon/str.c
+++ b/src/libs/zbxcommon/str.c
@@ -54,7 +54,7 @@ static const char help_message_footer[]
void version(void)
{
printf("%s (Zabbix) %s\n", title_message, ZABBIX_VERSION);
- printf("Revision %s %s, compilation time: %s %s\n\n", ZABBIX_REVISION, ZABBIX_REVDATE, __DATE__, __TIME__);
+ printf("Revision %s %s\n\n", ZABBIX_REVISION, ZABBIX_REVDATE);
puts(copyright_message);
#if defined(HAVE_GNUTLS) || defined(HAVE_OPENSSL)
printf("\n");