Compare commits

..

82 Commits

Author SHA1 Message Date
Sukru Senli
ce40c32040 netmode: set default netmode 2025-10-20 17:45:57 +02:00
Sukru Senli
bb090135b2 netmode: fix static mode
and improve other modes
2025-10-20 16:43:38 +02:00
Sukru Senli
8d7cf1c701 netmode: add static mode and vlanid and dns servers as arguments to all modes 2025-10-20 12:51:04 +02:00
Erik Karlsson
9692cf8bc3 sulu-vendorext: remove unused voip ubus object 2025-10-20 10:23:28 +02:00
Vivek Kumar Dutta
7fa5c901f9 sulu-vendorext: fix compilation 2025-10-17 18:29:48 +05:30
Sukru Senli
7c2cbc4c1a sulu-vendorext: remove AccessPoint management from X_IOWRT_MAPController vendor extension 2025-10-17 14:57:17 +02:00
Sukru Senli
a9bdc41462 sulu-vendorext: remove firewall extension 2025-10-17 14:53:42 +02:00
Amin Ben Romdhane
389485a526 wifidmd: 1.1.33.4 2025-10-17 10:08:35 +02:00
Vivek Kumar Dutta
8087a16cdf firewallmngr: selects nat interface setting 2025-10-17 12:25:29 +05:30
Vivek Kumar Dutta
4e33db2700 usermngr: Only select shadow pam utils with security hardening 2025-10-17 10:46:54 +05:30
Vivek Kumar Dutta
e6b7048775 icwmp: Fix segfault with SMM disabled 2025-10-16 18:11:16 +05:30
Suvendhu Hansa
23c43898a4 usermngr: Vendor extension for Security Hardening parameters 2025-10-16 15:45:03 +05:30
Vivek Kumar Dutta
abebc40733 obuspa: Optimize startup to avoid db corruption
- Force update values from uci on firmware update
- In case of reload(uci update), old sql db gets deleted and created from uci
- Use In memory sql journal mode
2025-10-16 14:44:47 +05:30
Suvendhu Hansa
4823154afb usermngr: Added password strength validation 2025-10-15 18:13:54 +05:30
Vivek Dutta
936ce9be85 passwdqc: Install pwqcheck tool
(cherry picked from commit 17ae16e5d2)

17ae16e5 passwdqc: Install pwqcheck tool

Co-authored-by: Suvendhu Hansa <suvendhu.hansa@iopsys.eu>
2025-10-15 17:35:56 +05:30
Reidar Cederqvist
996c0b1832 sulu: update to version 5.1.8 2025-10-14 17:02:23 +02:00
Jakob Olsson
8c4e77a96b Revert "Revert "map-controller: config: add zerotouch, rate, bsteer plugins to default""
This reverts commit 2c58ce6912.
2025-10-14 09:46:15 +02:00
Jakob Olsson
e647ec0990 Revert "Revert "map-agent: map_genconfig: add dpp_chirp section for 2.4GHz""
This reverts commit ad3028061c.
2025-10-14 09:46:13 +02:00
Vivek Dutta
4cfbb3636f mosquitto-auth-shadow: support libpam based authentication
(cherry picked from commit 082452bfb5)

082452bf mosquitto-auth-shadow: support libpam based authentication

Co-authored-by: Vivek Kumar Dutta <vivek.dutta@iopsys.eu>
2025-10-14 09:35:03 +05:30
Janusz Dziedzic
528ad5cbd2 wifimngr: 17.7.8 2025-10-13 16:15:59 +00:00
Erik Karlsson
def81d62d5 logmngr: include pid when migrating also
(cherry picked from commit 46dc9e86d8)

Co-authored-by: Erik Karlsson <erik.karlsson@iopsys.eu>
2025-10-13 19:21:13 +05:30
Jakob Olsson
ad3028061c Revert "map-agent: map_genconfig: add dpp_chirp section for 2.4GHz"
This reverts commit 8554ccf3fc.
2025-10-13 12:12:08 +02:00
Jakob Olsson
2c58ce6912 Revert "map-controller: config: add zerotouch, rate, bsteer plugins to default"
This reverts commit ba95eec1b5.
2025-10-13 12:11:52 +02:00
Vivek Dutta
064418e23d logmngr: include pid in log output by fluent-bit
(cherry picked from commit 0b3420240d)

Co-authored-by: Mohd Husaam Mehdi <husaam.mehdi@iopsys.eu>
2025-10-12 11:38:13 +05:30
Jakob Olsson
ba95eec1b5 map-controller: config: add zerotouch, rate, bsteer plugins to default 2025-10-10 15:50:30 +02:00
Jakob Olsson
8554ccf3fc map-agent: map_genconfig: add dpp_chirp section for 2.4GHz 2025-10-10 15:47:08 +02:00
Janusz Dziedzic
d6cf506901 wifimngr: 17.7.7 2025-10-10 11:38:06 +00:00
Janusz Dziedzic
263723b795 libwifi: 7.13.7 2025-10-10 11:37:15 +00:00
Jakob Olsson
21724ac691 map-agent: 6.3.7.0: zerotouch 2025-10-10 12:01:47 +02:00
Jakob Olsson
3422f7fc4d map-plugins: 1.1.2 2025-10-10 12:01:47 +02:00
Jakob Olsson
19e4b41368 map-plugins: add zerotouch options 2025-10-10 12:01:47 +02:00
Jakob Olsson
db30526f64 map-controller: 6.4.4.0: add ZEROTOUCH_DPP 2025-10-10 12:01:47 +02:00
Janusz Dziedzic
d4c101f90f libwifi: fix target cflags 2025-10-09 14:27:32 +02:00
Janusz Dziedzic
d90063c7d5 wifimngr: disable scancache by default 2025-10-09 14:27:32 +02:00
Mohd Husaam Mehdi
09323326f4 passwdqc: align with usermngr (move PAM setup to usermngr) 2025-10-09 16:32:40 +05:30
Husaam Mehdi
33b62a44c5 sshmngr: use openssh-with-pam as the default backend 2025-10-09 16:32:17 +05:30
Vivek Kumar Dutta
9d0f9750dc usermngr: 1.4.1 2025-10-09 16:30:50 +05:30
Vivek Kumar Dutta
e68abd6288 usermngr: 1.4.0 2025-10-09 16:30:50 +05:30
Suvendhu Hansa
61559073e8 usermngr: modify password policy 2025-10-09 16:30:50 +05:30
Mohd Husaam Mehdi
ffd8352d38 usermngr: add UCI support for passwdqc parameters 2025-10-09 16:30:50 +05:30
Mohd Husaam Mehdi
d75d3bc3ed usermngr: 1.3.11 2025-10-09 16:30:50 +05:30
Mohd Husaam Mehdi
86ef800f0d usermngr: add support for USERMNGR_SECURITY_HARDENING
* this compile time flag will set up faildelay, lock out upon
  6 failed attempts during login via shell or console and enable
  password strength checks when changing password
* this will set openssh usePam option
* openssh and shadow-utils with PAM backend need to be selected for
  this compile time flag to work
2025-10-09 16:30:50 +05:30
Mohd Husaam Mehdi
130a3e5952 usermngr: set compile time flag to use pam with shadow-utils 2025-10-09 16:30:50 +05:30
Mohd Husaam Mehdi
0d4b4c5399 usermngr: include passwdqc and linux-pam
* passwdqc helps us enforce strong passwords policy
* linux-pam helps in managing failed login attempts
2025-10-09 16:30:50 +05:30
Mohd Husaam Mehdi
2240a84adc linux-pam: align with usermngr (move PAM setup to usermngr) 2025-10-09 10:36:57 +00:00
Mohd Husaam Mehdi
d4dfe767c9 parental-control: improve bundle sync logic
* handle the case when interface comes up after parental-control
* handle the case when bundle size can't be fetched for some reason
2025-10-09 14:09:06 +05:30
Vivek Kumar Dutta
58f141573a tr143: workaround for download byte mismatch 2025-10-09 14:01:05 +05:30
Suvendhu Hansa
91fac0490a firewallmngr: Add compile flag for InterfaceSetting 2025-10-09 13:48:25 +05:30
Sukru Senli
a80713423c sulu-vendorext: remove mldsync script
since changes via tr-181 do not trigger procd config reload trigger
2025-10-08 08:54:01 +02:00
Reidar Cederqvist
d530ffa4ba sulu: update to version 5.1.7 2025-10-07 17:14:47 +02:00
Mohd Husaam Mehdi
2da18cbb7d parental-control: fix handling of tcp and ipv6 based dns responses 2025-10-07 13:44:39 +05:30
Mohd Husaam Mehdi
c89816ac60 parental-control: config option for nfqueue number 2025-10-07 13:44:31 +05:30
Vivek Kumar Dutta
03810c0099 parental-control: 1.3.2 2025-10-07 13:44:24 +05:30
Mohd Husaam Mehdi
aad4bd7db5 parental-control: only flush relevant connections using conntrack 2025-10-07 13:44:18 +05:30
Reidar Cederqvist
f36ba2dc1f Update 3 files
- /sulu/sulu-base/Makefile
- /sulu/sulu-builder/Makefile
- /sulu/sulu-theme-genexis/Makefile
2025-10-04 14:27:19 +00:00
Erik Karlsson
91dced7427 sulu: fix faulty ACL generation logic
Also remove leftovers from QR code generation and pointless uci_load
2025-10-03 10:15:00 +02:00
Jakob Olsson
57ef92af9a map-controller: 6.4.3.5 2025-10-03 09:54:55 +02:00
Jakob Olsson
631122aa04 map-plugins: 1.1.1 2025-10-03 09:52:09 +02:00
Sukru Senli
ede7966809 sulu-vendorext: ap_to_mld_creds_sync: do no hardcode mld_id to 1
set it only if there are unused mld sections
2025-10-02 17:34:54 +02:00
Vivek Kumar Dutta
9a36c0310f sulu: Fix migration scripts 2025-10-02 15:17:18 +00:00
Jakob Olsson
2528cde629 map-controller: 6.4.3.4 2025-10-02 16:47:21 +02:00
Vivek Kumar Dutta
f317c67aed obuspa: Skip overriding of uci in case of firstboot 2025-10-02 12:52:56 +00:00
Jakob Olsson
7f14f8634e map-controller: 6.4.3.3 2025-10-02 13:21:31 +02:00
Jakob Olsson
62552e2269 map-controller: 6.4.3.2 2025-10-02 09:45:14 +02:00
Jakob Olsson
5837b73946 map-agent: 6.3.6.18 2025-10-01 13:32:08 +02:00
Erik Karlsson
22bded8f33 timemngr: do not fail uci-defaults on keep-settings upgrade 2025-09-30 16:15:28 +02:00
Erik Karlsson
1fbf254b3a sulu-vendorext: fix missed heimgard.wan to genexis.wan renaming
Also add proper sanity checks so a catch-all ACCEPT rule cannot be
inadvertently added.
2025-09-30 12:49:15 +02:00
Erik Karlsson
3b6f88daed sulu-builder: fix typo in version 2025-09-30 11:53:35 +02:00
Amin Ben Romdhane
f8ceb6293d wifidmd: 1.1.33.3 2025-09-30 11:24:36 +02:00
Jakob Olsson
d5375c89b1 map-agent: 6.3.6.17 2025-09-29 10:53:48 +02:00
Reidar Cederqvist
1301adc7c6 sulu: update to version 5.1.5 2025-09-26 15:08:51 +02:00
Filip Matusiak
85d7715db7 map-agent: 6.3.6.16 2025-09-26 12:10:25 +02:00
Reidar Cederqvist
25cb059235 sulu update to version 5.1.4 2025-09-25 15:56:29 +00:00
Filip Matusiak
a87b85eba5 map-controller: 6.4.2.10 2025-09-25 14:40:16 +02:00
Vivek Kumar Dutta
49a83e17cb sulu-vendorext: Updated MAPController ext 2025-09-25 14:47:59 +05:30
Sukru Senli
2ec059a373 sulu-vendorext: remove unused vendor extensions 2025-09-25 10:09:58 +02:00
Vivek Kumar Dutta
7193985d39 icwmp: Generate error on duplicate params 2025-09-25 11:55:16 +05:30
Jouni Ikonen
74372dab99 Bug 18049: Use separate file for sulu functions 2025-09-25 09:19:11 +05:30
Vivek Kumar Dutta
6bc7842b0d sulu-vendorext: Fix compilation 2025-09-24 17:35:16 +05:30
Reidar Cederqvist
87c2d0bb10 sulu: update to version 2 (5.1.3) 2025-09-24 01:04:33 +02:00
Sukru Senli
1e2f6161d6 sulu-vendorext: replace X_GENEXIS_EU_mesh with X_IOWRT_EU_MAPController 2025-09-23 10:07:13 +00:00
Jakob Olsson
bbb3df8c17 map-controller: config: add name to unique sections
channel_plan and sta_steering are unique sections, and should be named. Additionally added uci-default script to name the sections if missing
2025-09-23 11:50:17 +02:00
76 changed files with 1583 additions and 3004 deletions

View File

@@ -8,5 +8,11 @@ config FIREWALLMNGR_PORT_TRIGGER
help
Set this option to include support for PortTrigger object.
config FIREWALLMNGR_NAT_INTERFACE_SETTING
bool "Include Device.NAT.InterfaceSetting"
default y
help
Set this option to include support for NAT InterfaceSetting object.
endmenu
endif

View File

@@ -5,13 +5,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=firewallmngr
PKG_VERSION:=1.0.9
PKG_VERSION:=1.0.9.2
LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/network/firewallmngr.git
PKG_SOURCE_VERSION:=77ad8425b73a3ac63f6160dc217635394ac87907
PKG_SOURCE_VERSION:=fdabd33cf42ac02adadbdf43bd8bf86a62d7d1e3
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
endif
@@ -52,6 +52,10 @@ ifeq ($(CONFIG_FIREWALLMNGR_PORT_TRIGGER),y)
TARGET_CFLAGS += -DINCLUDE_PORT_TRIGGER
endif
ifeq ($(CONFIG_FIREWALLMNGR_NAT_INTERFACE_SETTING),y)
TARGET_CFLAGS += -DINCLUDE_NAT_IF_SETTING
endif
define Package/firewallmngr/install
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DIR) $(1)/etc/uci-defaults

View File

@@ -8,13 +8,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=icwmp
PKG_VERSION:=9.9.9.3
PKG_VERSION:=9.9.9.5
LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/bbf/icwmp.git
PKG_SOURCE_VERSION:=55a64d756afd6249b8bb4cccf2cdaa7e1aa05f91
PKG_SOURCE_VERSION:=f3d5843c54a4c1c3e74629f0953a3bf144c2fa8e
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
endif

View File

@@ -5,12 +5,12 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=libwifi
PKG_VERSION:=7.13.6
PKG_VERSION:=7.13.7
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=d17ad7415a821e95618c4739507bf129df3fdebf
PKG_SOURCE_VERSION:=0b3cc45334c167d164c2c79e82522f13698abf92
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/libwifi.git
PKG_MAINTAINER:=Anjan Chanda <anjan.chanda@iopsys.eu>
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz
@@ -61,7 +61,7 @@ else
endif
ifneq ($(CONFIG_PACKAGE_kmod-mt7915e_en7523),)
TARGET_CFLAGS=-DMT7915_VENDOR_EXT
TARGET_CFLAGS +=-DMT7915_VENDOR_EXT
endif
PKG_BUILD_DEPENDS:=PACKAGE_kmod-mt7915e_en7523:mt76_en7523

View File

@@ -31,8 +31,8 @@ MESON_ARGS += \
define Package/linux-pam/install
$(INSTALL_DIR) $(1)/usr/lib/security
$(INSTALL_DIR) $(1)/etc/uci-defaults/
$(INSTALL_BIN) ./files/pam_faillock.uci_default $(1)/etc/uci-defaults/99-add_pam_faillock
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./linux_pam.init $(1)/etc/init.d/linux_pam
endef
$(eval $(call BuildPackage,linux-pam))

View File

@@ -1,43 +0,0 @@
#!/bin/sh
create_faillock_files()
{
# also create files needed by pam_faillock
touch /var/log/faillock
chmod 700 /var/log/faillock
touch /var/log/btmp
chmod 700 /var/log/btmp
}
update_pam_common_auth()
{
local file="/etc/pam.d/common-auth"
local deny=6
local unlock_time=300
# update pam_unix.so line
sed -i -E 's|^.*pam_unix\.so.*|auth\t sufficient\tpam_unix.so nullok_secure|' "$file"
# Insert pam_faillock lines before and after pam_unix.so
sed -i -E "/pam_unix.so nullok_secure/i auth required pam_faillock.so preauth deny=$deny even_deny_root unlock_time=$unlock_time" "$file"
sed -i -E "/pam_unix.so nullok_secure/a auth [default=die] pam_faillock.so authfail audit deny=$deny even_deny_root unlock_time=$unlock_time" "$file"
}
update_pam_common_account()
{
# update account file
sed -i "/pam_unix.so/ i account required pam_faillock.so" /etc/pam.d/common-account
}
if [ -f "/usr/lib/security/pam_faillock.so" ]; then
update_pam_common_auth
update_pam_common_account
create_faillock_files
fi
if [ -f /etc/config/sshd ]; then
uci -q set sshd.@sshd[0].UsePAM=1
uci commit sshd
fi
exit 0

18
linux-pam/linux_pam.init Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/sh /etc/rc.common
START=11
STOP=90
USE_PROCD=1
create_faillock_files()
{
# also create files needed by pam_faillock
touch /var/log/faillock
chmod 700 /var/log/faillock
touch /var/log/btmp
chmod 700 /var/log/btmp
}
boot() {
create_faillock_files
}

View File

@@ -8,7 +8,7 @@ config source 'default_source'
config template 'default_template'
option name 'default_template'
option expression '{time} {hostname} {ident}: {message}'
option expression '{time} {hostname} {ident}[{pid}]: {message}'
config action 'default_action'
option name 'default_action'

View File

@@ -11,7 +11,7 @@ fi
if ! uci -q get logmngr.default_template > /dev/null; then
uci -q set logmngr.default_template=template
uci -q set logmngr.default_template.name='default_template'
uci -q set logmngr.default_template.expression='{time} {hostname} {ident}: {message}'
uci -q set logmngr.default_template.expression='{time} {hostname} {ident}[{pid}]: {message}'
fi
if uci -q get logmngr.a1 >/dev/null; then

View File

@@ -55,6 +55,10 @@ config AGENT_OPER_CHANNEL_CHANGE_RELAY_MCAST
config AGENT_USE_LIBDPP
bool "Depend on libdpp for DPP EasyConnect"
config AGENT_ZEROTOUCH_DPP
bool "Enable Zero-touch DPP bootstrapping. Depends on libztdpp.so"
default n
config AGENT_CHECK_PARTIAL_WIFI_RELOAD
bool "Option that allow SSID/PSK simple reload"
default y

View File

@@ -1,13 +1,14 @@
#
# Copyright (C) 2020-2023 IOPSYS Software Solutions AB
# Copyright (C) 2020-2024 IOPSYS Software Solutions AB
# Copyright (C) 2025 Genexis Sweden AB
#
include $(TOPDIR)/rules.mk
PKG_NAME:=map-agent
PKG_VERSION:=6.3.6.15
PKG_VERSION:=6.3.7.0
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_VERSION:=7b05d265776fca2ff84a63188fcec55c08057e33
PKG_SOURCE_VERSION:=ab9fa6ffc6978c84ab9a3b410d31c71c3b185430
PKG_MAINTAINER:=Jakob Olsson <jakob.olsson@iopsys.eu>
PKG_LICENSE:=BSD-3-Clause
@@ -26,7 +27,7 @@ include $(INCLUDE_DIR)/package.mk
define Package/map-agent
SECTION:=utils
CATEGORY:=Utilities
TITLE:=WiFi multi-AP Agent (EasyMesh R2)
TITLE:=Wi-Fi Multi-AP Agent (EasyMesh R6)
DEPENDS:=+libwifi +libuci +libubox +ubus +libeasy +libieee1905 +ieee1905 \
+ieee1905-map-plugin +ip-bridge +AGENT_USE_LIBDPP:libdpp \
+uuidgen +openssl-util +!TARGET_brcmbca:ebtables-legacy \
@@ -45,9 +46,12 @@ define Package/dynbhd
+ieee1905-map-plugin +map-agent
endef
ifeq ($(CONFIG_AGENT_ZEROTOUCH_DPP),y)
TARGET_CFLAGS += -DZEROTOUCH_DPP
endif
define Package/map-agent/description
This package implements EasyMesh R2 compliant WiFi Agent.
This package provides EasyMesh R6 compliant Wi-Fi Multi-AP Agent.
endef
define Package/dynbhd/description

View File

@@ -44,19 +44,16 @@ generate_multiap_config() {
2g)
mode_band=2
priority=2
dpp_chan="81/1"
channels="1 6 11"
;;
5g)
mode_band=5
priority=1
dpp_chan="128/36"
channels="36-64 100-112"
;;
6g)
mode_band=6
priority=0
dpp_chan="133/49"
;;
esac
@@ -158,13 +155,17 @@ generate_multiap_config() {
uci set mapagent.@bsta[-1].band="$mode_band"
uci set mapagent.@bsta[-1].priority="$priority"
#uci add mapagent dpp_uri
#uci set mapagent.@dpp_uri[-1].type="qrcode"
#uci set mapagent.@dpp_uri[-1].device="$device"
#uci set mapagent.@dpp_uri[-1].ifname="$ifname"
#uci set mapagent.@dpp_uri[-1].band="$mode_band"
#uci set mapagent.@dpp_uri[-1].chirp_interval="10"
#uci add_list mapagent.@dpp_uri[-1].dpp_chan="$dpp_chan"
# add dpp_chirp section for 2.4GHz bSTA
if [ $mode_band -eq 2 ]; then
uci add mapagent dpp_chirp
uci set mapagent.@dpp_chirp[-1].type="qrcode"
uci set mapagent.@dpp_chirp[-1].device="$device"
uci set mapagent.@dpp_chirp[-1].ifname="$ifname"
uci set mapagent.@dpp_chirp[-1].band="$mode_band"
for channel in $channels; do
uci add_list mapagent.@dpp_chirp[-1].channel="$channel"
done
fi
if [ $generate_wireless_sta_config -eq 1 ]; then
secname="default_sta_${device}"

View File

@@ -39,6 +39,10 @@ config CONTROLLER_EASYMESH_VENDOR_EXT_OUI
config CONTROLLER_USE_LIBDPP
bool "Depend on libdpp for DPP EasyConnect"
config CONTROLLER_ZEROTOUCH_DPP
bool "Enable Zero-touch DPP bootstrapping via passphrase."
default n
config CONTROLLER_PROPAGATE_PROBE_REQ
depends on CONTROLLER_EASYMESH_VENDOR_EXT
bool "Enable publishing probe requests vendor specific messages as UBUS events"

View File

@@ -6,9 +6,9 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=map-controller
PKG_VERSION:=6.4.2.9
PKG_VERSION:=6.4.4.0
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_VERSION:=c427bbaa53ce470a45a59326281f214f1111c3f7
PKG_SOURCE_VERSION:=d2e91ca156dbe0b44f0fc551b0a353137343fdf1
PKG_MAINTAINER:=Jakob Olsson <jakob.olsson@genexis.eu>
LOCAL_DEV=0
@@ -36,6 +36,9 @@ ifeq ($(CONFIG_CONTROLLER_USE_LIBDPP),y)
TARGET_CFLAGS += -DUSE_LIBDPP
endif
ifeq ($(CONFIG_CONTROLLER_ZEROTOUCH_DPP),y)
TARGET_CFLAGS += -DZEROTOUCH_DPP
endif
define Package/map-controller/description
This package provides WiFi MultiAP Controller as per the EasyMesh-R2 specs.
@@ -81,6 +84,7 @@ define Build/InstallDev
$(CP) $(PKG_BUILD_DIR)/src/cntlr_commands_impl.h $(1)/usr/include/map-controller
$(CP) $(PKG_BUILD_DIR)/src/cntlr_commands.h $(1)/usr/include/map-controller
$(CP) $(PKG_BUILD_DIR)/src/cntlr_apis.h $(1)/usr/include/map-controller
$(CP) $(PKG_BUILD_DIR)/src/cntlr_plugin.h $(1)/usr/include/map-controller
$(CP) $(PKG_BUILD_DIR)/src/wifi_opclass.h $(1)/usr/include/map-controller
$(CP) $(PKG_BUILD_DIR)/src/steer_module.h $(1)/usr/include/map-controller
$(CP) $(PKG_BUILD_DIR)/src/timer.h $(1)/usr/include/map-controller

View File

@@ -10,8 +10,9 @@ config controller 'controller'
option primary_pcp '0'
option stale_sta_timeout '30d'
option de_collect_interval '60'
list plugin 'zerotouch'
config sta_steering
config sta_steering 'sta_steering'
option enable_sta_steer '1'
option enable_bsta_steer '0'
option rcpi_threshold_2g '70'
@@ -23,8 +24,10 @@ config sta_steering
option plugins_enabled '1'
option plugins_policy 'any'
list plugins 'rcpi'
list plugins 'rate'
list plugins 'bsteer'
config channel_plan
config channel_plan 'channel_plan'
option preclear_dfs '0'
option acs '0'

View File

@@ -0,0 +1,18 @@
#!/bin/sh
. /lib/functions.sh
cfg=mapcontroller
# singleton sections
sections="channel_plan sta_steering"
for sec in $sections; do
# find unnamed section of given type, only index 0
s=$(uci show $cfg | grep -oE "@${sec}\[0\]" | sort -u)
[ "$s" = "" ] && continue
uci rename $cfg.$s=$sec
done
uci commit $cfg

View File

@@ -5,12 +5,12 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=map-plugins
PKG_VERSION:=1.0.32
PKG_VERSION:=1.1.2
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=d8b310edad1b9777aed805682394e3f9bb300d81
PKG_SOURCE_VERSION:=a76610182366cf05ed7e8f5fbac26890b709eeb4
PKG_SOURCE_URL:=https://dev.iopsys.eu/multi-ap/map-plugins.git
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz
PKG_MIRROR_HASH:=skip
@@ -27,12 +27,18 @@ include $(INCLUDE_DIR)/package.mk
include $(wildcard plugins/*.mk)
TARGET_CFLAGS += \
-I$(STAGING_DIR)/usr/include \
-I$(STAGING_DIR)/usr/include/libnl3 \
-D_GNU_SOURCE
MAKE_FLAGS += \
CFLAGS="$(TARGET_CFLAGS) -Wall"
plugins := \
$(if $(CONFIG_PACKAGE_map-plugins-steer-rate),steer-rate) \
$(if $(CONFIG_PACKAGE_map-plugins-bsteer),bsteer)
$(if $(CONFIG_PACKAGE_map-plugins-bsteer),bsteer) \
$(if $(CONFIG_PACKAGE_map-plugins-zero-touch),zero-touch)
ppkg:=$(patsubst plugins/%.mk,map-plugins-%,$(wildcard plugins/*.mk))

View File

@@ -0,0 +1,22 @@
define Package/map-plugins-zero-touch
$(call Package/map-plugins/Default)
TITLE:=Full Zero-touch bootstrapping of Wi-Fi Repeater device(s)
DEPENDS= +libubox +libuci +libubus +libeasy +libnl-genl \
+libjson-c +libblobmsg-json +map-controller \
+map-plugins
endef
define Package/map-plugins-zero-touch/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_DIR) $(1)/usr/lib/mapcontroller
$(CP) $(PKG_BUILD_DIR)/zero-touch/zerotouch.so $(1)/usr/lib/mapcontroller/zerotouch.so
$(CP) $(PKG_BUILD_DIR)/zero-touch/libztdpp.so $(1)/usr/lib/libztdpp.so
endef
define Build/Compile/map-plugins-zero-touch
$(MAKE) -C $(PKG_BUILD_DIR)/zero-touch \
CC="$(TARGET_CC)" \
CFLAGS="$(TARGET_CFLAGS)" \
LDFLAGS="$(TARGET_LDFLAGS)";
endef

View File

@@ -0,0 +1,7 @@
if PACKAGE_mosquitto-auth-shadow
config MOSQUITTO_AUTH_PAM_SUPPORT
bool "Enable support of Linux PAM module for Authentication"
default y
endif

View File

@@ -14,12 +14,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=mosquitto-auth-shadow
PKG_VERSION:=1.0.1
PKG_VERSION:=1.1.0
PKG_MAINTAINER:=Erik Karlsson <erik.karlsson@genexis.eu>
PKG_LICENSE:=EPL-2.0
PKG_BUILD_PARALLEL:=1
PKG_CONFIG_DEPENDS:=CONFIG_MOSQUITTO_AUTH_PAM_SUPPORT
include $(INCLUDE_DIR)/package.mk
@@ -27,7 +28,7 @@ define Package/mosquitto-auth-shadow
SECTION:=net
CATEGORY:=Network
TITLE:=mosquitto - /etc/shadow authentication plugin
DEPENDS:=+mosquitto-ssl
DEPENDS:=+mosquitto-ssl +MOSQUITTO_AUTH_PAM_SUPPORT:libpam
USERID:=mosquitto=200:mosquitto=200 mosquitto=200:shadow=11
endef
@@ -36,6 +37,14 @@ define Package/mosquitto-auth-shadow/description
users using /etc/shadow
endef
define Package/mosquitto-auth-shadow/config
source "$(SOURCE)/Config.in"
endef
ifeq ($(CONFIG_MOSQUITTO_AUTH_PAM_SUPPORT),y)
TARGET_CFLAGS+=-DENABLE_PAM_SUPPORT
endif
define Package/mosquitto-auth-shadow/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_BIN) $(PKG_BUILD_DIR)/mosquitto_auth_shadow.so $(1)/usr/lib/

View File

@@ -19,7 +19,7 @@ all: $(TARGETS)
$(CC) $(CFLAGS) -Wall -Werror -fPIC -c -o $@ $<
mosquitto_auth_shadow.so: mosquitto_auth_shadow.pic.o
$(CC) $(LDFLAGS) -shared -o $@ $^
$(CC) $(LDFLAGS) -shared -o $@ $^ $(if $(filter -DENABLE_PAM_SUPPORT,$(CFLAGS)),-lpam)
clean:
rm -f *.o $(TARGETS)

View File

@@ -15,22 +15,78 @@
#include <string.h>
#include <shadow.h>
#include <crypt.h>
#include <stdlib.h>
#include <mosquitto.h>
#include <mosquitto_broker.h>
#include <mosquitto_plugin.h>
static int basic_auth_callback(int event, void *event_data, void *userdata)
#ifdef ENABLE_PAM_SUPPORT
#include <security/pam_appl.h>
static int pam_conversation(int num_msg, const struct pam_message **msg, struct pam_response **resp, void *appdata_ptr)
{
int i;
const char *pass = (const char *)appdata_ptr;
*resp = calloc(num_msg, sizeof(struct pam_response));
if (*resp == NULL) {
mosquitto_log_printf(MOSQ_LOG_ERR, "pam failed to allocate buffer for validation");
return PAM_BUF_ERR;
}
if (pass == NULL)
return PAM_SUCCESS;
for (i = 0; i < num_msg; ++i) {
if (msg[i]->msg_style == PAM_PROMPT_ECHO_OFF) {
(*resp)[i].resp = strdup(pass);
if ((*resp)[i].resp == NULL) {
for (int j = 0; j < i ; j++)
free((*resp)[j].resp);
free(*resp);
*resp = NULL;
mosquitto_log_printf(MOSQ_LOG_ERR, "pam failed in strdup");
return PAM_BUF_ERR;
}
}
}
return PAM_SUCCESS;
}
static int process_pam_auth_callback(struct mosquitto_evt_basic_auth *ed)
{
struct pam_conv conv;
int retval;
pam_handle_t *pamh = NULL;
conv.conv = pam_conversation;
conv.appdata_ptr = (void *)ed->password;
retval = pam_start("mosquitto", ed->username, &conv, &pamh);
if (retval != PAM_SUCCESS) {
mosquitto_log_printf(MOSQ_LOG_ERR, "pam start failed: %s", pam_strerror(pamh, retval));
return MOSQ_ERR_AUTH;
}
retval = pam_authenticate(pamh, 0);
pam_end(pamh, retval);
if (retval == PAM_SUCCESS) {
mosquitto_log_printf(MOSQ_LOG_NOTICE, "pam user [%s] logged in", ed->username);
return MOSQ_ERR_SUCCESS;
}
mosquitto_log_printf(MOSQ_LOG_NOTICE, "pam user [%s] failed authentication, err [%s]", ed->username, pam_strerror(pamh, retval));
return MOSQ_ERR_AUTH;
}
#else
static int process_shadow_auth_callback(struct mosquitto_evt_basic_auth *ed)
{
struct mosquitto_evt_basic_auth *ed = event_data;
struct spwd spbuf, *sp = NULL;
char buf[256];
struct crypt_data data;
char *hash;
/* Let other plugins or broker decide about anonymous login */
if (ed->username == NULL)
return MOSQ_ERR_PLUGIN_DEFER;
getspnam_r(ed->username, &spbuf, buf, sizeof(buf), &sp);
if (sp == NULL || sp->sp_pwdp == NULL)
@@ -54,6 +110,22 @@ static int basic_auth_callback(int event, void *event_data, void *userdata)
return MOSQ_ERR_AUTH;
}
#endif
static int basic_auth_callback(int event, void *event_data, void *userdata)
{
struct mosquitto_evt_basic_auth *ed = event_data;
/* Let other plugins or broker decide about anonymous login */
if (ed->username == NULL)
return MOSQ_ERR_PLUGIN_DEFER;
#ifdef ENABLE_PAM_SUPPORT
return process_pam_auth_callback(ed);
#else
return process_shadow_auth_callback(ed);
#endif
}
int mosquitto_plugin_version(int supported_version_count,
const int *supported_versions)

View File

@@ -17,6 +17,8 @@ l3_mcast_config() {
l3_network_config() {
logger -s -p user.info -t "netmode" "Generating L3 network configuration"
wandev="$(uci -q get network.WAN.ifname)"
# Configure L3 Network Mode
uci -q set network.lan=interface
uci -q set network.lan.device='br-lan'
@@ -36,11 +38,35 @@ l3_network_config() {
uci -q delete network.wan.disabled
uci -q delete network.wan.username
uci -q delete network.wan.password
uci -q delete network.wan.ipaddr
uci -q delete network.wan.gateway
uci -q delete network.wan.netmask
uci -q set network.wan6=interface
uci -q set network.wan6.proto='dhcpv6'
uci -q delete network.wan6.disabled
if [ -n "$wandev" ] && echo "$NETMODE_vlanid" | grep -Eq '^[0-9]+$' && [ "$NETMODE_vlanid" -ge 1 ]; then
uci -q set network.vlan_${NETMODE_vlanid}=device
uci -q set network.vlan_${NETMODE_vlanid}.type="8021q"
uci -q set network.vlan_${NETMODE_vlanid}.name="$wandev.$NETMODE_vlanid"
uci -q set network.vlan_${NETMODE_vlanid}.ifname="$wandev"
uci -q set network.vlan_${NETMODE_vlanid}.vid=$NETMODE_vlanid
wandev="$wandev.$NETMODE_vlanid"
fi
uci -q set network.wan.device="$wandev"
uci -q set network.wan6.device="$wandev"
uci -q delete network.wan.dns
if [ -n "$NETMODE_dns_servers" ]; then
dns_servers="$(echo $NETMODE_dns_servers | tr ',' ' ')"
for server in $dns_servers; do
uci -q add_list network.wan.dns=$server
done
fi
uci -q delete network.br_lan.ports
uci -q set network.br_lan.bridge_empty='1'
@@ -61,12 +87,6 @@ l3_network_config() {
[ -n "$device" ] && uci add_list network.br_lan.ports="$device"
fi
json_select ..
json_select wan 2>/dev/null
json_get_var device device
if [ -n "$device" ]; then
uci -q set network.wan.device="$device"
uci -q set network.wan6.device="$device"
fi
json_cleanup
fi

View File

@@ -17,6 +17,8 @@ l3_mcast_config() {
l3_network_pppoe_config() {
logger -s -p user.info -t "netmode" "Generating L3 network configuration"
wandev="$(uci -q get network.WAN.ifname)"
# Configure L3 Network Mode
uci -q set network.lan=interface
uci -q set network.lan.device='br-lan'
@@ -36,9 +38,33 @@ l3_network_pppoe_config() {
uci -q set network.wan.username="$NETMODE_username"
uci -q set network.wan.password="$NETMODE_password"
uci -q delete network.wan.disabled
uci -q delete network.wan.ipaddr
uci -q delete network.wan.gateway
uci -q delete network.wan.netmask
uci -q set network.wan6.disabled='1'
if [ -n "$wandev" ] && echo "$NETMODE_vlanid" | grep -Eq '^[0-9]+$' && [ "$NETMODE_vlanid" -ge 1 ]; then
uci -q set network.vlan_${NETMODE_vlanid}=device
uci -q set network.vlan_${NETMODE_vlanid}.type="8021q"
uci -q set network.vlan_${NETMODE_vlanid}.name="$wandev.$NETMODE_vlanid"
uci -q set network.vlan_${NETMODE_vlanid}.ifname="$wandev"
uci -q set network.vlan_${NETMODE_vlanid}.vid=$NETMODE_vlanid
wandev="$wandev.$NETMODE_vlanid"
fi
uci -q set network.wan.device="$wandev"
uci -q set network.wan6.device="$wandev"
uci -q delete network.wan.dns
if [ -n "$NETMODE_dns_servers" ]; then
dns_servers="$(echo $NETMODE_dns_servers | tr ',' ' ')"
for server in $dns_servers; do
uci -q add_list network.wan.dns=$server
done
fi
uci -q delete network.br_lan.ports
uci -q set network.br_lan.bridge_empty='1'
@@ -59,12 +85,6 @@ l3_network_pppoe_config() {
[ -n "$device" ] && uci add_list network.br_lan.ports="$device"
fi
json_select ..
json_select wan 2>/dev/null
json_get_var device device
if [ -n "$device" ]; then
uci -q set network.wan.device="$device"
uci -q set network.wan6.device="$device"
fi
json_cleanup
fi

View File

@@ -0,0 +1,127 @@
#!/bin/sh
. /lib/functions.sh
. /usr/share/libubox/jshn.sh
source "/etc/device_info"
l3_mcast_config() {
# configure L3 mcast config
logger -s -p user.info -t "netmode" "Generating L3 mcast configuration"
rm -f /etc/config/mcast
sh /rom/etc/uci-defaults/61-mcast_config_generate
uci -q commit mcast
}
l3_network_config() {
logger -s -p user.info -t "netmode" "Generating L3 network configuration"
wandev="$(uci -q get network.WAN.ifname)"
# Configure L3 Network Mode
uci -q set network.lan=interface
uci -q set network.lan.device='br-lan'
uci -q set network.lan.proto='static'
uci -q set network.lan.ipaddr='192.168.1.1'
uci -q set network.lan.netmask='255.255.255.0'
uci -q set network.lan.ip6assign='60'
uci -q delete network.lan.vendorid
uci -q delete network.lan.clientid
uci -q delete network.lan.reqopts
uci -q delete network.lan.sendopts
uci -q delete network.lan6
uci -q set network.wan=interface
uci -q set network.wan.device="$wandev"
uci -q set network.wan.proto='static'
uci -q set network.wan.ipaddr="$NETMODE_ipaddr"
uci -q set network.wan.gateway="$NETMODE_gateway"
uci -q set network.wan.netmask="$NETMODE_netmask"
uci -q delete network.wan.disabled
uci -q delete network.wan.username
uci -q delete network.wan.password
uci -q set network.wan6.disabled='1'
if [ -n "$wandev" ] && echo "$NETMODE_vlanid" | grep -Eq '^[0-9]+$' && [ "$NETMODE_vlanid" -ge 1 ]; then
uci -q set network.vlan_${NETMODE_vlanid}=device
uci -q set network.vlan_${NETMODE_vlanid}.type="8021q"
uci -q set network.vlan_${NETMODE_vlanid}.name="$wandev.$NETMODE_vlanid"
uci -q set network.vlan_${NETMODE_vlanid}.ifname="$wandev"
uci -q set network.vlan_${NETMODE_vlanid}.vid=$NETMODE_vlanid
wandev="$wandev.$NETMODE_vlanid"
fi
uci -q set network.wan.device="$wandev"
uci -q set network.wan6.device="$wandev"
uci -q delete network.wan.dns
if [ -n "$NETMODE_dns_servers" ]; then
dns_servers="$(echo $NETMODE_dns_servers | tr ',' ' ')"
for server in $dns_servers; do
uci -q add_list network.wan.dns=$server
done
fi
uci -q delete network.br_lan.ports
uci -q set network.br_lan.bridge_empty='1'
add_port_to_br_lan() {
port="$1"
[ -n "$port" -a -d /sys/class/net/$port ] || continue
uci add_list network.br_lan.ports="$port"
}
if [ -f /etc/board.json ]; then
json_load_file /etc/board.json
json_select network
json_select lan
if json_is_a ports array; then
json_for_each_item add_port_to_br_lan ports
else
json_get_var device device
[ -n "$device" ] && uci add_list network.br_lan.ports="$device"
fi
json_select ..
json_cleanup
fi
uci -q commit network
# Enable DHCP Server
uci -q set dhcp.lan.ignore=0
uci -q set dhcp.wan.ignore=1
uci -q commit dhcp
/etc/init.d/odhcpd enable
# Enable SSDPD
uci -q set ssdpd.ssdp.enabled="1"
uci -q commit ssdpd
# Update CWMP Agent WAN Interface
uci -q set cwmp.cpe.default_wan_interface="wan"
uci -q commit cwmp
# Update gateway WAN Interface
uci -q set gateway.global.wan_interface="wan"
uci -q commit gateway
# Enable firewall
uci -q set firewall.globals.enabled="1"
uci -q commit firewall
}
l3_network_config
l3_mcast_config
# If device is already boot-up, assume netmode changed during runtime
if [ -f /var/run/boot_complete ]; then
/etc/init.d/odhcpd restart 2>/dev/null
for config in network dhcp ssdpd cwmp gateway firewall mcast; do
ubus call uci commit "{\"config\":\"$config\"}"
sleep 1
done
fi

View File

@@ -3,25 +3,90 @@
"supported_modes": [
{
"name": "routed-dhcp",
"description": "WAN with DHCP proto (Layer 3)"
"description": "DHCP",
"supported_args": [
{
"name": "vlanid",
"description": "VLAN ID",
"required": false,
"type": "integer"
},
{
"name": "dns_servers",
"description": "DNS Servers",
"required": false,
"type": "string"
}
]
},
{
"name": "routed-pppoe",
"description": "WAN with PPPoE (Layer 3)",
"description": "PPPoE",
"supported_args": [
{
"name": "username",
"description": "PPPoE username",
"description": "PPPoE Username",
"required": true,
"type": "string",
"type": "string",
"#value": "TestUser"
},
{
"name": "password",
"description": "PPPoE password",
"description": "PPPoE Password",
"required": true,
"type": "string",
"type": "string",
"#value": "TestPassword"
},
{
"name": "vlanid",
"description": "VLAN ID",
"required": false,
"type": "integer"
},
{
"name": "dns_servers",
"description": "DNS Servers",
"required": false,
"type": "string"
}
]
},
{
"name": "routed-static",
"description": "Static",
"supported_args": [
{
"name": "ipaddr",
"description": "IP Address",
"required": true,
"type": "string",
"#value": "93.21.0.104"
},
{
"name": "netmask",
"description": "Subnet Mask",
"required": true,
"type": "string",
"#value": "255.255.255.0"
},
{
"name": "gateway",
"description": "Default Gateway",
"required": true,
"type": "string",
"#value": "93.21.0.1"
},
{
"name": "vlanid",
"description": "VLAN ID",
"required": false,
"type": "integer"
},
{
"name": "dns_servers",
"description": "DNS Servers",
"required": false,
"type": "string"
}
]
}

View File

@@ -0,0 +1,29 @@
#!/bin/sh
enabled="$(uci -q get netmode.global.enabled)"
[ "$enabled" == "1" ] || exit 0
mode="$(uci -q get netmode.global.mode)"
[ -n "$mode" ] && exit 0
[ -f /etc/netmodes/supported_modes.json ] || exit 0
# NetMode is enabled without a Mode being set
# Figure out the current mode from network config
wanproto=$(uci -q get network.wan.proto)
curmode=""
case "$wanproto" in
dhcp) curmode="routed-dhcp" ;;
pppoe) curmode="routed-pppoe" ;;
static) curmode="routed-static" ;;
esac
found=0
for md in $(jsonfilter -i /etc/netmodes/supported_modes.json -e "@.supported_modes.*.name"); do
[ "$md" == "$curmode" ] && found=1
done
if [ $found -eq 1 ]; then
uci -q set netmode.global.mode="$curmode"
echo "$curmode" > /etc/netmodes/.last_mode
fi

View File

@@ -5,13 +5,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=obuspa
PKG_VERSION:=10.0.0.16
PKG_VERSION:=10.0.0.17
LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/bbf/obuspa.git
PKG_SOURCE_VERSION:=479ffb3582aa245a84829502d9412ca2539eefca
PKG_SOURCE_VERSION:=8f0f8cfc2c4048bfed674163030d0b06f96f2da1
PKG_MAINTAINER:=Vivek Dutta <vivek.dutta@iopsys.eu>
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
@@ -32,8 +32,9 @@ define Package/obuspa
SUBMENU:=TRx69
TITLE:=USP agent
MENU:=1
DEPENDS:=+libopenssl +libuci +libblobmsg-json +libcurl +libsqlite3 +libubox +libubus +libmosquitto-ssl +libwebsockets-openssl +ca-certificates \
+OBUSPA_LOCAL_MQTT_LISTENER:mosquitto-ssl +libjson-c
DEPENDS:=+libopenssl +libcurl +libsqlite3 +libmosquitto-ssl +libwebsockets-openssl
DEPENDS+=+libjson-c +libubox +libubus +libuci +libblobmsg-json
DEPENDS+=+ca-certificates +OBUSPA_LOCAL_MQTT_LISTENER:mosquitto-ssl
DEPENDS+=+libbbfdm-api +libbbfdm-ubus +dm-service
endef

View File

@@ -6,19 +6,18 @@ USE_PROCD=1
PROG=/usr/sbin/obuspa
CONFIGURATION=obuspa
ENV_PROFILE="/root/.profile"
KEEP_FILE="/lib/upgrade/keep.d/obuspa"
RESET_FILE="/tmp/obuspa/fw_defaults"
SQL_DB_FILE="/tmp/obuspa/usp.db"
DB_DUMP="/tmp/obuspa/usp.dump_$(date +%s)"
OBUSPA_BOOT_MARKER="/etc/obuspa/.boot"
BASEPATH=""
INSTANCE_COUNT=0
CLIENT_ID_PREFIX=""
. /lib/functions/network.sh
. /usr/share/libubox/jshn.sh
. /etc/obuspa/usp_utils.sh
global_init()
@@ -30,6 +29,7 @@ global_init()
log()
{
echo "$*"|logger -t obuspa.init -p debug
echo "$*" >/dev/console
}
db_set_reset_file()
@@ -47,37 +47,9 @@ db_set_reset_file()
fi
}
db_set_sql()
{
local param value
param="${1}"
shift
value="$*"
if [ -n "${param}" ] && [ -n "${value}" ]; then
if grep -q "${param} " ${DB_DUMP}; then
value="${value//\//\\/}"
sed -i "s/${param} .*/${param} \"${value}\"/g" ${DB_DUMP}
else
echo "${param} \"${value}\"" >> ${DB_DUMP}
fi
fi
}
db_set()
{
# if sql db dump file present, update it
if [ -f "${DB_DUMP}" ]; then
db_set_sql "$@"
else
db_set_reset_file "$@"
fi
}
dump_db()
{
${PROG} -v0 -f ${SQL_DB_FILE} -c show database |grep "^Internal.\|^Device."|sed '{s/=> /"/g;s/$/"/g}' | sort > ${DB_DUMP}
db_set_reset_file "$@"
}
# if db present then check if it matches with existing instances
@@ -92,21 +64,6 @@ get_base_path()
path=""
count=0
if [ -f "${DB_DUMP}" ]; then
path=$(grep -E "${refpath}\d+.Alias \"${value}\"" ${DB_DUMP})
path=${path%.*}
if [ -z "${path}" ]; then
path=$(grep -oE "${refpath}\d+" ${DB_DUMP} |sort -r|head -n 1)
if [ -n "${path}" ]; then
count=${path##*.}
count=$(( count + 1 ))
else
count=1
fi
path="${refpath}${count}"
fi
fi
if [ -z "${path}" ]; then
INSTANCE_COUNT=$(( INSTANCE_COUNT + 1 ))
path="${refpath}${INSTANCE_COUNT}"
@@ -122,9 +79,7 @@ get_refrence_path()
value="${2}"
path=""
if [ -f "${DB_DUMP}" ]; then
path=$(grep -E "${dmref}\d+.Alias " ${DB_DUMP}|grep -w "${value}")
elif [ -f "${RESET_FILE}" ]; then
if [ -f "${RESET_FILE}" ]; then
path=$(grep -E "${dmref}\d+.Alias " ${RESET_FILE}|grep -w "${value}")
fi
path=${path%.*}
@@ -136,7 +91,7 @@ update_keep()
file=${1}
if [ -z "${file}" ]; then
return;
return 0
fi
if [ ! -f "${KEEP_FILE}" ]; then
@@ -263,7 +218,7 @@ configure_localagent()
validate_localagent_section "${1}" || {
log "Validation of localagent section failed"
return 0;
return 0
}
db_set Device.LocalAgent.EndpointID "${EndpointID}"
@@ -271,7 +226,7 @@ configure_localagent()
update_reset_reason()
{
[ -f "/tmp/reset_reason" ] || return 0;
[ -f "/tmp/reset_reason" ] || return 0
if grep -qwi "defaultreset" /tmp/reset_reason; then
db_set Internal.Reboot.Cause "FactoryReset"
@@ -310,10 +265,6 @@ get_role_index()
val="$(grep "Device.LocalAgent.ControllerTrust.Role.\d.Name" ${CTRUST_RESET_FILE} |grep $name)"
val="$(echo ${val/.Name /,}|cut -d, -f 1)"
echo "$val"
elif [ -f "${DB_DUMP}" ]; then
val="$(grep "Device.LocalAgent.ControllerTrust.Role.\d.Name" ${DB_DUMP} |grep $name)"
val="$(echo ${val/.Name /,}|cut -d, -f 1)"
echo "$val"
else
log "Not able to get role ${name}, use Untrusted role"
echo "${drole}"
@@ -331,19 +282,19 @@ configure_controller()
sec="${1}"
validate_controller_section "${1}" || {
log "Validation of controller section failed"
return 1;
return 1
}
sec="${sec/controller_/cpe-}"
get_base_path "Device.LocalAgent.Controller." "${sec}"
if [ -z "${BASEPATH}" ]; then
log "Failed to get path [$BASEPATH]"
return 1;
return 1
fi
if [ -z "${Protocol}" ]; then
log "controller:: Protocol cannot be empty"
return 1;
return 1
fi
dm_ref=""
@@ -439,14 +390,14 @@ configure_subscription()
sec="${1}"
validate_subscription_section "${1}" || {
log "Validation of subscription section failed"
return 1;
return 1
}
sec="${sec/sub_/cpe-}"
get_base_path "Device.LocalAgent.Subscription." "sub_${1}"
if [ -z "${BASEPATH}" ]; then
log "Failed to get path [$BASEPATH]"
return 1;
return 1
fi
if [ -n "${controller}" ]; then
@@ -483,12 +434,12 @@ configure_challenges()
get_base_path "Device.LocalAgent.ControllerTrust.Challenge." "${sec}"
if [ -z "${BASEPATH}" ]; then
log "Failed to get path [$BASEPATH]"
return 1;
return 1
fi
if [ -z "${role_name}" ] && [ -z "${Role}" ]; then
log "Either role_name or Role must defined for a challenge";
return 1;
log "Either role_name or Role must defined for a challenge"
return 1
fi
db_set "${BASEPATH}.Alias" "${sec}"
@@ -515,18 +466,18 @@ configure_mtp() {
sec="${1}"
validate_mtp_section "${1}" || {
log "Validation of mtp section failed"
return 1;
return 1
}
sec="${sec/mtp_/cpe-}"
get_base_path "Device.LocalAgent.MTP." "${sec}"
if [ -z "${BASEPATH}" ]; then
log "Failed to get path [$BASEPATH]"
return 1;
return 1
fi
if [ -z "${Protocol}" ]; then
log "Protocol not defined for the mtp[${1}] section"
return 1;
return 1
fi
dm_ref=""
@@ -584,14 +535,14 @@ configure_stomp_connection() {
sec="${1}"
validate_stomp_connection_section "${1}" || {
log "Validation of stomp section failed"
return 1;
return 1
}
sec="${sec/stomp_/cpe-}"
get_base_path "Device.STOMP.Connection." "${sec}"
if [ -z "${BASEPATH}" ]; then
log "Failed to get path [$BASEPATH]"
return 1;
return 1
fi
db_set "${BASEPATH}.Alias" "${sec}"
@@ -614,14 +565,18 @@ configure_mqtt_client() {
sec="${1}"
validate_mqtt_client_section "${1}" || {
log "Validation of mqtt section failed"
return 1;
return 1
}
sec="${sec/mqtt_/cpe-}"
get_base_path "Device.MQTT.Client." "${sec}"
if [ -z "${BASEPATH}" ]; then
log "Failed to get path [$BASEPATH]"
return 1;
return 1
fi
if [ -z "${ClientID}" ]; then
ClientID="${CLIENT_ID_PREFIX}-${sec}"
fi
db_set "${BASEPATH}.Alias" "${sec}"
@@ -648,6 +603,9 @@ configure_obuspa() {
fi
if [ -n "${log_level}" ]; then
if [ "${log_level}" -gt "4" ]; then
log_level="4"
fi
procd_append_param command -v "${log_level}"
fi
@@ -676,13 +634,13 @@ configure_obuspa() {
if [ -n "${db_file}" ]; then
update_keep "${db_file}"
procd_append_param command -f "${SQL_DB_FILE}"
procd_append_param command -f "${db_file}"
if [ -f "${db_file}-journal" ]; then
log "SQL Journal detected ..."
fi
fi
if [ -f "${RESET_FILE}" ]; then
if [ -f "${SQL_DB_FILE}" ]; then
mv ${SQL_DB_FILE} ${SQL_DB_FILE}.old
fi
procd_append_param command -r ${RESET_FILE}
fi
@@ -701,301 +659,34 @@ configure_obuspa() {
fi
}
get_instances_from_db_dump()
{
local obj inst
obj="${1}\d+"
if [ ! -f "${DB_DUMP}" ]; then
echo ""
return 0;
fi
inst="$(grep -oE "${obj}" "${DB_DUMP}"|uniq)"
echo "$inst"
}
get_param_value_from_dump()
{
local param value
param="${1}"
if [ -z "${param}" ] || [ ! -f "${DB_DUMP}" ]; then
log "error getting param"
echo ""
return 0
fi
value="$(grep "^${param} " ${DB_DUMP}|awk '{print $2}')"
echo "${value//\"/}"
}
update_uci_sec()
{
local sec tmp
sec="${1}"
stype="${2}"
if [ -z "$sec" ] || [ -z "$stype" ]; then
log "No section name, error"
return 0
fi
tmp="$(uci_get obuspa "${sec}")"
if [ "$tmp" != "$stype" ]; then
uci_add obuspa "${stype}" "${sec}"
fi
}
sync_db_controller()
{
local cntrs copts sec pvalue protocol
copts="Enable EndpointID PeriodicNotifInterval"
popts="Destination Topic Host Port Path EnableEncryption"
cntrs="$(get_instances_from_db_dump Device.LocalAgent.Controller.)"
for cntr in $cntrs; do
sec="$(get_param_value_from_dump "${cntr}".Alias)"
sec="${sec/cpe-/controller_}"
sec="${sec/-/_}"
update_uci_sec "${sec}" controller
for param in ${copts}; do
pvalue="$(get_param_value_from_dump "${cntr}"."${param}")"
uci_set obuspa "${sec}" "${param}" "${pvalue}"
done
uci_set obuspa "${sec}" "_sync" "1"
protocol="$(get_param_value_from_dump "${cntr}".MTP.1.Protocol)"
if [ -z "${protocol}" ]; then
break;
fi
uci_set obuspa "${sec}" "Protocol" "${protocol}"
for param in ${popts}; do
pvalue="$(get_param_value_from_dump "${cntr}".MTP.1."${protocol}"."${param}")"
uci_set obuspa "${sec}" "${param}" "${pvalue}"
done
done
}
sync_db_localagent_mtp()
{
local mtps opts popts sec pvalue protocol
opts="Enable"
popts="ResponseTopicConfigured Destination Port Path EnableEncryption PublishQoS"
mtps="$(get_instances_from_db_dump Device.LocalAgent.MTP.)"
for inst in $mtps; do
sec="$(get_param_value_from_dump "${inst}".Alias)"
sec="${sec/cpe-/mtp_}"
sec="${sec/-/_}"
update_uci_sec "${sec}" mtp
for param in ${opts}; do
pvalue="$(get_param_value_from_dump "${inst}"."${param}")"
uci_set obuspa "${sec}" "${param}" "${pvalue}"
done
uci_set obuspa "${sec}" "_sync" "1"
protocol="$(get_param_value_from_dump "${inst}".Protocol)"
if [ -z "${protocol}" ]; then
break;
fi
uci_set obuspa "${sec}" "Protocol" "${protocol}"
for param in ${popts}; do
pvalue="$(get_param_value_from_dump "${inst}"."${protocol}"."${param}")"
uci_set obuspa "${sec}" "${param}" "${pvalue}"
done
done
}
sync_db_mqtt_client()
{
local mtps copts sec pvalue protocol
opts="Enable BrokerAddress BrokerPort Username ProtocolVersion TransportProtocol ClientID"
mtps="$(get_instances_from_db_dump Device.MQTT.Client.)"
for inst in $mtps; do
sec="$(get_param_value_from_dump "${inst}".Alias)"
sec="${sec/cpe-/mqtt_}"
sec="${sec/-/_}"
update_uci_sec "${sec}" mqtt
for param in ${opts}; do
pvalue="$(get_param_value_from_dump "${inst}"."${param}")"
uci_set obuspa "${sec}" "${param}" "${pvalue}"
done
uci_set obuspa "${sec}" "_sync" "1"
done
}
sync_db_stomp_connection()
{
local mtps copts sec pvalue protocol
opts="Enable Host Port Username EnableEncryption EnableHeartbeats VirtualHost"
mtps="$(get_instances_from_db_dump Device.STOMP.Connection.)"
for inst in $mtps; do
sec="$(get_param_value_from_dump "${inst}".Alias)"
sec="${sec/cpe-/stomp_}"
sec="${sec/-/_}"
update_uci_sec "${sec}" stomp
for param in ${opts}; do
pvalue="$(get_param_value_from_dump "${inst}"."${param}")"
uci_set obuspa "${sec}" "${param}" "${pvalue}"
done
uci_set obuspa "${sec}" "_sync" "1"
done
}
sync_update_sec()
{
local _sync
config_get _sync "${1}" _sync ""
if [ -z "${_sync}" ]; then
uci_remove obuspa "${1}"
log "Deleting obuspa.${1} section ..."
else
uci_remove obuspa "${1}" _sync
fi
}
sync_uci_with_db()
{
if [ ! -f "${DB_DUMP}" ]; then
return 0;
fi
config_load obuspa
sync_db_controller
sync_db_localagent_mtp
sync_db_mqtt_client
sync_db_stomp_connection
uci_commit obuspa
config_load obuspa
config_foreach sync_update_sec controller
config_foreach sync_update_sec mtp
config_foreach sync_update_sec mqtt
config_foreach sync_update_sec stomp
uci_commit obuspa
}
delete_sql_db_entry_with_pattern()
{
local params pattern
pattern="${1}"
if [ ! -f "${DB_DUMP}" ]; then
return 0;
fi
if [ "${#pattern}" -lt 7 ]; then
return 0;
fi
#log "Deleting with pattern [${pattern}] from ${DB_DUMP}"
sed -i "/${pattern}/d" ${DB_DUMP}
}
check_n_delete_db()
{
local sec t r path
sec="${1}"
if uci -q get obuspa."${sec}" >/dev/null 2>&1; then
return 0
fi
t="${2}"
r="${3}"
sec="${sec/${t}_/cpe-}"
path=$(grep -E "${r}\d+.Alias \"${sec}\"" ${DB_DUMP})
path=${path%.*}
delete_sql_db_entry_with_pattern "${path}"
}
workaround_remove_download_pattern()
{
local inst
inst="$(cat ${DB_DUMP} |grep -E "Device.DeviceInfo.FirmwareImage.\d.Download()"|grep -oE "Device.LocalAgent.Request.\d.")"
if [ -n "${inst}" ]; then
log "Workaround to remove the old download Request [$inst]"
delete_sql_db_entry_with_pattern "${inst}"
fi
}
reverse_update_db_with_uci()
{
if [ ! -f "${DB_DUMP}" ]; then
return 0;
fi
export UCI_CONFIG_DIR="/tmp/obuspa"
config_load obuspa
config_foreach check_n_delete_db controller controller "Device.LocalAgent.Controller."
config_foreach check_n_delete_db mtp mtp "Device.LocalAgent.MTP."
config_foreach check_n_delete_db mqtt mqtt "Device.MQTT.Client."
config_foreach check_n_delete_db stomp stomp "Device.STOMP.Connection."
unset UCI_CONFIG_DIR
}
# Create factory reset file
db_init()
{
local reason role_file
local reason
reason="${1}"
mkdir -p /tmp/obuspa/
# Load configuration
config_load $CONFIGURATION
config_get SQL_DB_FILE global db_file "/tmp/obuspa/usp.db"
config_get role_file global role_file ""
if [ -f "${SQL_DB_FILE}.old" ] && [ ! -f "${SQL_DB_FILE}" ]; then
log "Copying old db, since new db not present ..."
mv ${SQL_DB_FILE}.old ${SQL_DB_FILE}
# remove usp.db, in case of reload
if [ -f "${OBUSPA_BOOT_MARKER}" ] && [ "${reason}" = "update" ]; then
log "Deleting ${OBUSPA_BOOT_MARKER} to enforce values from uci ...."
rm -f "${OBUSPA_BOOT_MARKER}"
fi
# Dump datamodel parameters from DB
if [ -f "${SQL_DB_FILE}" ]; then
dump_db
fi
# In case of Reboot or service restart update the uci
# from usp.db file
if [ -f "${DB_DUMP}" ] && [ "${reason}" != "update" ]; then
# Only do this if db have reasonable data
val="$(awk 'END{print NR}' ${DB_DUMP})"
if [ "$val" -gt 15 ]; then
log "Syncing obuspa uci with usp.db ...."
sync_uci_with_db
fi
fi
# remove entries from db if deleted from uci, only in case of reload
if [ -f "${DB_DUMP}" ] && [ "${reason}" = "update" ] && [ -f "/tmp/obuspa/obuspa" ]; then
log "Deleting entries from usp.db if uci not present ...."
reverse_update_db_with_uci
if [ -f "${OBUSPA_BOOT_MARKER}" ]; then
return 0
fi
# Remove reset file if present
[ -f "${RESET_FILE}" ] && mv ${RESET_FILE} ${RESET_FILE}.old
[ -f "${RESET_FILE}" ] && rm ${RESET_FILE}
CLIENT_ID_PREFIX="$(db -q get device.deviceinfo.ManufacturerOUI)"
CLIENT_ID_PREFIX="${CLIENT_ID_PREFIX}-$(db -q get device.deviceinfo.SerialNumber)"
CLIENT_ID_PREFIX="${CLIENT_ID_PREFIX//+/%2b}"
#log "Create reset file ...."
config_load $CONFIGURATION
config_get dualstack_pref global dualstack_pref "IPv6"
log "Enforce uci values, no boot marker"
global_init
config_foreach configure_localagent localagent
global_init
@@ -1011,21 +702,12 @@ db_init()
global_init
config_foreach configure_challenges challenge
# enforce ctrust only on upgrades, not on reloads
if [ -f "${CTRUST_RESET_FILE}" ] && [ -z "${reason}" ]; then
cat ${CTRUST_RESET_FILE} >> ${RESET_FILE}
fi
update_reset_reason
update_dual_stack_pref "${dualstack_pref}"
uci_commit ${CONFIGURATION}
cp /etc/config/obuspa /tmp/obuspa/
if [ -f "${DB_DUMP}" ]; then
workaround_remove_download_pattern
mv ${DB_DUMP} ${RESET_FILE}
fi
if [ -f "${CTRUST_RESET_FILE}" ]; then
cat ${CTRUST_RESET_FILE} >> ${RESET_FILE}
rm ${CTRUST_RESET_FILE}
fi
}
start_service() {
@@ -1037,21 +719,18 @@ start_service() {
procd_open_instance ${CONFIGURATION}
if [ "${enabled}" -eq 1 ]; then
db_init "${1}"
procd_set_param command ${PROG}
db_init "${1}"
configure_obuspa
procd_set_param respawn \
"${respawn_threshold:-10}" \
"${respawn_timeout:-10}" "${respawn_retry:-5}"
#procd_set_param limits core="unlimited"
fi
procd_close_instance ${CONFIGURATION}
}
stop_service() {
if command -v timeout >/dev/null 2>&1; then
timeout 5 ${PROG} -c stop
fi
${PROG} -c stop
}
reload_service() {
@@ -1060,5 +739,6 @@ reload_service() {
}
service_triggers() {
export PROCD_RELOAD_DELAY=3000
procd_add_reload_trigger "obuspa"
}

View File

@@ -1,10 +1,12 @@
#!/bin/sh
CTRUST_RESET_FILE="/tmp/obuspa/ctrust_reset"
CTRUST_RESET_FILE="/etc/obuspa/ctrust_reset"
VENDOR_PREFIX_FILE="/etc/obuspa/vendor_prefix"
FW_DEFAULT_ROLE_DIR="/etc/users/roles"
SECURE_ROLES=""
CTRUST_RESET_FILE_TEMP="/tmp/obuspa/ctrust_reset"
mkdir -p /tmp/obuspa/
# include jshn.sh
@@ -23,9 +25,9 @@ db_add()
value="$*"
if [ -n "${param}" ] && [ -n "${value}" ]; then
echo "${param} \"${value}\"">>${CTRUST_RESET_FILE}
echo "${param} \"${value}\"">>${CTRUST_RESET_FILE_TEMP}
else
echo >>${CTRUST_RESET_FILE}
echo >>${CTRUST_RESET_FILE_TEMP}
fi
}
@@ -252,7 +254,10 @@ configure_ctrust_role()
if [ -n "${SECURE_ROLES}" ]; then
db_add Device.LocalAgent.ControllerTrust.SecuredRoles "${SECURE_ROLES}"
fi
if [ -f "${CTRUST_RESET_FILE_TEMP}" ]; then
mv -f "${CTRUST_RESET_FILE_TEMP}" "${CTRUST_RESET_FILE}"
fi
}
# configure_ctrust_role "${@}"

View File

@@ -4,5 +4,3 @@
. /etc/obuspa/usp_utils.sh
configure_ctrust_role
exit 0

View File

@@ -8,6 +8,7 @@ RETRY_MIN_INTERVAL="5"
RETRY_INTERVAL_MUL="2000"
ENDPOINT_ID=""
CONTROLLER_DISCOVERED=0
OBUSPA_BOOT_MARKER="/etc/obuspa/.boot"
log()
{
@@ -57,18 +58,18 @@ get_vivsoi() {
data="${opt125}"
rem_len="${len}"
while [ $rem_len -gt 0 ]; do
while [ "${rem_len}" -gt 0 ]; do
ent_id=${data:0:8}
ent_id=$(printf "%d\n" "0x$ent_id")
if [ $ent_id -ne 3561 ]; then
if [ "${ent_id}" -ne 3561 ]; then
len_val=${data:8:2}
data_len=$(printf "%d\n" "0x$len_val")
# add 4 byte for ent_id and 1 byte for len
data_len=$(( data_len * 2 + 10 ))
# move ahead data to next enterprise id
data=${data:"${data_len}":"${rem_len}"}
rem_len=$(( rem_len - $data_len ))
rem_len=$(( rem_len - data_len ))
continue
fi
@@ -79,7 +80,7 @@ get_vivsoi() {
data_len=$(( data_len * 2 + 10 ))
opt_len=$(printf "%d\n" "0x$len_val")
[ $opt_len -eq 0 ] && return
[ "${opt_len}" -eq 0 ] && return
# populate the option data of enterprise id
sub_data_len=$(( opt_len * 2))
@@ -98,28 +99,28 @@ get_vivsoi() {
sub_opt_len=$(( sub_opt_len * 2 ))
# get the value of sub option starting 4 means starting after length
sub_opt_val=${sub_data:4:${sub_opt_len}}
sub_opt_val=${sub_data:4:"${sub_opt_len}"}
# assign the value found in sub option
case "${sub_opt_id}" in
"25")
URL=$(echo -n $sub_opt_val | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
URL=$(echo -n "${sub_opt_val}" | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
CONTROLLER_DISCOVERED=1
;;
"26")
PROV_CODE=$(echo -n $sub_opt_val | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
PROV_CODE=$(echo -n "${sub_opt_val}" | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
CONTROLLER_DISCOVERED=1
;;
"27")
RETRY_MIN_INTERVAL=$(echo -n $sub_opt_val | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
RETRY_MIN_INTERVAL=$(echo -n "${sub_opt_val}" | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
CONTROLLER_DISCOVERED=1
;;
"28")
RETRY_INTERVAL_MUL=$(echo -n $sub_opt_val | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
RETRY_INTERVAL_MUL=$(echo -n "${sub_opt_val}" | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
CONTROLLER_DISCOVERED=1
;;
"29")
ENDPOINT_ID=$(echo -n $sub_opt_val | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
ENDPOINT_ID=$(echo -n "${sub_opt_val}" | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
CONTROLLER_DISCOVERED=1
;;
esac
@@ -131,7 +132,7 @@ get_vivsoi() {
sub_data_len=$((sub_data_len - sub_opt_end))
# fetch next sub option hex string
sub_data=${sub_data:${sub_opt_end}:${sub_data_len}}
sub_data=${sub_data:"${sub_opt_end}":"${sub_data_len}"}
done
# move ahead data to next enterprise id
@@ -146,7 +147,7 @@ get_access_role()
lan_proto="$(uci -q get network.lan.proto)"
if [ "${lan_proto}" == "dhcp" ]; then
if [ "${lan_proto}" = "dhcp" ]; then
mode="extender"
else
mode="full_access"
@@ -174,7 +175,7 @@ config_get_bool enable_obuspa global enabled 1
config_get wan_intf global interface
config_get_bool dhcp_discovery global dhcp_discovery 1
if [ "$enable_obuspa" = "0" ] || [ "$dhcp_discovery" = "0" ]; then
if [ "${enable_obuspa}" -eq 0 ] || [ "${dhcp_discovery}" -eq 0 ]; then
return 0
fi
@@ -190,9 +191,9 @@ if [ -z "${wan_intf}" ]; then
fi
fi
if [ "${wan_intf}" == "${INTERFACE}" ]; then
if [ "${wan_intf}" = "${INTERFACE}" ]; then
if [ -n "$opt125" ]; then
len=$(printf "$opt125"|wc -c)
len=$(echo -n "${opt125}"|wc -c)
get_vivsoi "$opt125" "$len"
fi
@@ -228,10 +229,10 @@ if [ "${wan_intf}" == "${INTERFACE}" ]; then
;;
*)
# This is an FQDN, perform DNS query
nslookup $URL > /tmp/fqdn_ip
nslookup -type=ptr $URL > /tmp/fqdn_ptr
nslookup -type=srv $URL > /tmp/fqdn_srv
nslookup -type=txt $URL > /tmp/fqdn_srv
nslookup "${URL}" > /tmp/fqdn_ip
nslookup -type=ptr "${URL}" > /tmp/fqdn_ptr
nslookup -type=srv "${URL}" > /tmp/fqdn_srv
nslookup -type=txt "${URL}" > /tmp/fqdn_srv
# TODO extend to collect information from dns-sd records
;;
@@ -247,16 +248,16 @@ if [ "${wan_intf}" == "${INTERFACE}" ]; then
fi
fi
if [ "${proto}" == "mqtt" ] || [ "${proto}" == "mqtts" ]; then
if [ "${proto}" = "mqtt" ] || [ "${proto}" = "mqtts" ]; then
offered_proto="MQTT"
if [ "${proto}" == "mqtt" ]; then
if [ "${proto}" = "mqtt" ]; then
mtp_encrypt="TCP/IP"
else
mtp_encrypt="TLS"
fi
elif [ "${proto}" == "ws" ] || [ "${proto}" == "wss" ]; then
elif [ "${proto}" = "ws" ] || [ "${proto}" = "wss" ]; then
offered_proto="WebSocket"
if [ "${proto}" == "wss" ]; then
if [ "${proto}" = "wss" ]; then
mtp_encrypt="1"
else
mtp_encrypt="0"
@@ -265,35 +266,46 @@ if [ "${wan_intf}" == "${INTERFACE}" ]; then
controllers=$(uci -q show obuspa | grep "=controller" | cut -d'=' -f1 | cut -d'.' -f2)
for controller in $controllers; do
dhcp_disc=$(uci -q get obuspa.$controller.dhcp_discovered)
dhcp_disc=$(uci -q get obuspa."${controller}".dhcp_discovered)
if [ "${dhcp_disc}" -eq 1 ]; then
dhcp_controller="${controller}"
break
fi
done
# Check if any of the existing controller section matches with the endpointid
if [ -z "${dhcp_controller}" ] && [ -n "${ENDPOINT_ID}" ]; then
for controller in $controllers; do
endpointid=$(uci -q get obuspa."${controller}".EndpointID)
if [ "${endpointid}" = "${ENDPOINT_ID}" ]; then
dhcp_controller="${controller}"
break
fi
done
fi
if [ -n "${dhcp_controller}" ]; then
cont_proto="$(uci -q get obuspa.$dhcp_controller.Protocol)"
if [ "${cont_proto}" == "MQTT" ]; then
dhcp_mqtt="$(uci -q get obuspa.$dhcp_controller.mqtt)"
cont_proto=$(uci -q get obuspa."${dhcp_controller}".Protocol)
if [ "${cont_proto}" = "MQTT" ]; then
dhcp_mqtt=$(uci -q get obuspa."${dhcp_controller}".mqtt)
mtps=$(uci -q show obuspa | grep "=mtp" | cut -d'=' -f1 | cut -d'.' -f2)
for mtp in $mtps; do
mtp_mqtt="$(uci -q get obuspa.$mtp.mqtt)"
if [ "${mtp_mqtt}" == "${dhcp_mqtt}" ]; then
mtp_mqtt=$(uci -q get obuspa."${mtp}".mqtt)
if [ "${mtp_mqtt}" = "${dhcp_mqtt}" ]; then
dhcp_mtp="${mtp}"
break
fi
done
elif [ "${cont_proto}" == "WebSocket" ]; then
cont_port="$(uci -q get obuspa.$dhcp_controller.Port)"
cont_encr="$(uci -q get obuspa.$dhcp_controller.EnableEncryption)"
elif [ "${cont_proto}" = "WebSocket" ]; then
cont_port=$(uci -q get obuspa."${dhcp_controller}".Port)
cont_encr=$(uci -q get obuspa."${dhcp_controller}".EnableEncryption)
mtps=$(uci -q show obuspa | grep "=mtp" | cut -d'=' -f1 | cut -d'.' -f2)
for mtp in $mtps; do
mtp_port="$(uci -q get obuspa.$mtp.Port)"
mtp_encr="$(uci -q get obuspa.$mtp.EnableEncryption)"
if [ "${mtp_port}" == "${cont_port}" ] && [ "${mtp_encr}" == "${cont_encr}" ]; then
mtp_port=$(uci -q get obuspa."${mtp}".Port)
mtp_encr=$(uci -q get obuspa."${mtp}".EnableEncryption)
if [ "${mtp_port}" = "${cont_port}" ] && [ "${mtp_encr}" = "${cont_encr}" ]; then
dhcp_mtp="${mtp}"
break
fi
@@ -306,43 +318,43 @@ if [ "${wan_intf}" == "${INTERFACE}" ]; then
if [ -n "${dhcp_controller}" ]; then
## Handling of controller section
ct_endpoint=$(uci -q get obuspa.$dhcp_controller.EndpointID)
ct_proto=$(uci -q get obuspa.$dhcp_controller.Protocol)
ct_prov=$(uci -q get obuspa.$dhcp_controller.ProvisioningCode)
ct_endpoint=$(uci -q get obuspa."${dhcp_controller}".EndpointID)
ct_proto=$(uci -q get obuspa."${dhcp_controller}".Protocol)
ct_prov=$(uci -q get obuspa."${dhcp_controller}".ProvisioningCode)
if [ "${ct_proto}" = "MQTT" ]; then
ct_topic=$(uci -q get obuspa.$dhcp_controller.Topic)
ct_topic=$(uci -q get obuspa."${dhcp_controller}".Topic)
else
ct_topic=$(uci -q get obuspa.$dhcp_controller.Path)
ct_topic=$(uci -q get obuspa."${dhcp_controller}".Path)
fi
if [ -n "${ENDPOINT_ID}" ] && [ "${ct_endpoint}" != "${ENDPOINT_ID}" ]; then
uci -q set obuspa.$dhcp_controller.EndpointID="${ENDPOINT_ID}"
uci -q set obuspa."${dhcp_controller}".EndpointID="${ENDPOINT_ID}"
uci_change=1
fi
if [ -n "${offered_proto}" ] && [ "${ct_proto}" != "${offered_proto}" ]; then
uci -q set obuspa.$dhcp_controller.Protocol="${offered_proto}"
uci -q set obuspa."${dhcp_controller}".Protocol="${offered_proto}"
if [ "${offered_proto}" != "MQTT" ]; then
uci -q set obuspa.$dhcp_controller.mqtt=""
uci -q set obuspa.$dhcp_controller.Topic=""
uci -q set obuspa.$dhcp_controller.Host="${ip}"
uci -q set obuspa.$dhcp_controller.Port="${port}"
uci -q set obuspa.$dhcp_controller.Path="${ct_topic}"
uci -q set obuspa.$dhcp_controller.EnableEncryption="${mtp_encrypt}"
uci -q delete obuspa."${dhcp_controller}".mqtt
uci -q delete obuspa."${dhcp_controller}".Topic
uci -q set obuspa."${dhcp_controller}".Host="${ip}"
uci -q set obuspa."${dhcp_controller}".Port="${port}"
uci -q set obuspa."${dhcp_controller}".Path="${ct_topic}"
uci -q set obuspa."${dhcp_controller}".EnableEncryption="${mtp_encrypt}"
else
uci -q set obuspa.$dhcp_controller.EnableEncryption=""
uci -q set obuspa.$dhcp_controller.Path=""
uci -q set obuspa.$dhcp_controller.Host=""
uci -q set obuspa.$dhcp_controller.Port=""
uci -q delete obuspa."${dhcp_controller}".EnableEncryption
uci -q delete obuspa."${dhcp_controller}".Path
uci -q delete obuspa."${dhcp_controller}".Host
uci -q delete obuspa."${dhcp_controller}".Port
if [ -z "${dhcp_mqtt}" ]; then
uci -q set obuspa.$dhcp_controller.mqtt='dhcpmqtt'
uci -q set obuspa."${dhcp_controller}".mqtt='dhcpmqtt'
else
uci -q set obuspa.$dhcp_controller.mqtt="${dhcp_mqtt}"
uci -q set obuspa."${dhcp_controller}".mqtt="${dhcp_mqtt}"
fi
uci -q set obuspa.$dhcp_controller.Topic="${ct_topic}"
uci -q set obuspa."${dhcp_controller}".Topic="${ct_topic}"
fi
proto_changed=1
@@ -355,38 +367,37 @@ if [ "${wan_intf}" == "${INTERFACE}" ]; then
protocol="${offered_proto}"
fi
if [ "${protocol}" == "MQTT" ]; then
uci -q set obuspa.$dhcp_controller.Topic="${topic}"
if [ "${protocol}" = "MQTT" ]; then
uci -q set obuspa."${dhcp_controller}".Topic="${topic}"
else
uci -q set obuspa.$dhcp_controller.Path="${topic}"
uci -q set obuspa."${dhcp_controller}".Path="${topic}"
fi
uci_change=1
fi
if [ -n "${PROV_CODE}" ] && [ "${ct_prov}" != "${PROV_CODE}" ]; then
uci -q set obuspa.$dhcp_controller.ProvisioningCode="${PROV_CODE}"
uci -q set obuspa."${dhcp_controller}".ProvisioningCode="${PROV_CODE}"
uci_change=1
fi
if [ "${proto_changed}" -eq 1 ]; then
if [ "${offered_proto}" == "WebSocket" ]; then
if [ "${offered_proto}" = "WebSocket" ]; then
if [ -n "${dhcp_mqtt}" ]; then
uci -q del obuspa.$dhcp_mqtt
uci -q delete obuspa."${dhcp_mqtt}"
fi
if [ -z "${dhcp_mtp}" ]; then
sec=$(uci -q add obuspa mtp)
uci -q rename obuspa."${sec}"='dhcpmtp'
uci -q set obuspa.dhcpmtp="mtp"
dhcp_mtp="dhcpmtp"
uci -q set obuspa.$dhcp_mtp.Enable='1'
uci -q set obuspa."${dhcp_mtp}".Enable='1'
fi
uci -q set obuspa.$dhcp_mtp.mqtt=''
uci -q set obuspa.$dhcp_mtp.ResponseTopicConfigured=''
uci -q set obuspa.$dhcp_mtp.Protocol='WebSocket'
uci -q set obuspa.$dhcp_mtp.Port="${port}"
uci -q set obuspa.$dhcp_mtp.EnableEncryption="${mtp_encrypt}"
uci -q set obuspa."${dhcp_mtp}".mqtt=''
uci -q set obuspa."${dhcp_mtp}".ResponseTopicConfigured=''
uci -q set obuspa."${dhcp_mtp}".Protocol='WebSocket'
uci -q set obuspa."${dhcp_mtp}".Port="${port}"
uci -q set obuspa."${dhcp_mtp}".EnableEncryption="${mtp_encrypt}"
uci_change=1
else
@@ -394,137 +405,135 @@ if [ "${wan_intf}" == "${INTERFACE}" ]; then
user="$(uci -q get obuspa.global.username)"
pass="$(uci -q get obuspa.global.password)"
sec=$(uci -q add obuspa mqtt)
uci -q rename obuspa."${sec}"='dhcpmqtt'
uci -q set obuspa.dhcpmqtt="mqtt"
dhcp_mqtt="dhcpmqtt"
uci -q set obuspa.$dhcp_mqtt.Enable='1'
uci -q set obuspa.$dhcp_mqtt.Username="${user}"
uci -q set obuspa.$dhcp_mqtt.Password="${pass}"
uci -q set obuspa."${dhcp_mqtt}".Enable='1'
uci -q set obuspa."${dhcp_mqtt}".Username="${user}"
uci -q set obuspa."${dhcp_mqtt}".Password="${pass}"
fi
uci -q set obuspa.$dhcp_mqtt.BrokerAddress="${ip}"
uci -q set obuspa.$dhcp_mqtt.BrokerPort="${port}"
uci -q set obuspa.$dhcp_mqtt.TransportProtocol="${mtp_encrypt}"
uci -q set obuspa.$dhcp_mqtt.ProtocolVersion='5.0'
uci -q set obuspa."${dhcp_mqtt}".BrokerAddress="${ip}"
uci -q set obuspa."${dhcp_mqtt}".BrokerPort="${port}"
uci -q set obuspa."${dhcp_mqtt}".TransportProtocol="${mtp_encrypt}"
uci -q set obuspa."${dhcp_mqtt}".ProtocolVersion='5.0'
if [ -z "${dhcp_mtp}" ]; then
sec=$(uci -q add obuspa mtp)
uci -q rename obuspa."${sec}"='dhcpmtp'
uci -q set obuspa.dhcpmtp="mtp"
dhcp_mtp="dhcpmtp"
uci -q set obuspa.$dhcp_mtp.Enable='1'
uci -q set obuspa."${dhcp_mtp}".Enable='1'
fi
agent_topic=$(get_agent_topic)
uci -q set obuspa.$dhcp_mtp.Port=""
uci -q set obuspa.$dhcp_mtp.EnableEncryption=""
uci -q set obuspa.$dhcp_mtp.Protocol='MQTT'
uci -q set obuspa.$dhcp_mtp.ResponseTopicConfigured="${agent_topic}"
uci -q set obuspa.$dhcp_mtp.mqtt="${dhcp_mqtt}"
uci -q delete obuspa."${dhcp_mtp}".Port
uci -q delete obuspa."${dhcp_mtp}".EnableEncryption
uci -q set obuspa."${dhcp_mtp}".Protocol='MQTT'
uci -q set obuspa."${dhcp_mtp}".ResponseTopicConfigured="${agent_topic}"
uci -q set obuspa."${dhcp_mtp}".mqtt="${dhcp_mqtt}"
uci_change=1
fi
else
if [ "${ct_proto}" == "WebSocket" ]; then
conf_ip="$(uci -q get obuspa.$dhcp_controller.Host)"
conf_port="$(uci -q get obuspa.$dhcp_mtp.Port)"
conf_encr="$(uci -q get obuspa.$dhcp_mtp.EnableEncryption)"
if [ "${ct_proto}" = "WebSocket" ]; then
conf_ip="$(uci -q get obuspa."${dhcp_controller}".Host)"
conf_port="$(uci -q get obuspa."${dhcp_mtp}".Port)"
conf_encr="$(uci -q get obuspa."${dhcp_mtp}".EnableEncryption)"
if [ -n "${ip}" ] && [ "${conf_ip}" != "${ip}" ]; then
uci -q set obuspa.$dhcp_controller.Host="${ip}"
uci -q set obuspa."${dhcp_controller}".Host="${ip}"
uci_change=1
fi
if [ -n "${port}" ] && [ "${conf_port}" != "${port}" ]; then
uci -q set obuspa.$dhcp_mtp.Port="${port}"
uci -q set obuspa.$dhcp_controller.Port="${port}"
uci -q set obuspa."${dhcp_mtp}".Port="${port}"
uci -q set obuspa."${dhcp_controller}".Port="${port}"
uci_change=1
fi
if [ -n "${mtp_encrypt}" ] && [ "${conf_encr}" != "${mtp_encrypt}" ]; then
uci -q set obuspa.$dhcp_mtp.EnableEncryption="${mtp_encrypt}"
uci -q set obuspa.$dhcp_controller.EnableEncryption="${mtp_encrypt}"
uci -q set obuspa."${dhcp_mtp}".EnableEncryption="${mtp_encrypt}"
uci -q set obuspa."${dhcp_controller}".EnableEncryption="${mtp_encrypt}"
uci_change=1
fi
else
conf_ip="$(uci -q get obuspa.$dhcp_mqtt.BrokerAddress)"
conf_port="$(uci -q get obuspa.$dhcp_mqtt.BrokerPort)"
conf_encr="$(uci -q get obuspa.$dhcp_mqtt.TransportProtocol)"
conf_ip=$(uci -q get obuspa."${dhcp_mqtt}".BrokerAddress)
conf_port=$(uci -q get obuspa."${dhcp_mqtt}".BrokerPort)
conf_encr=$(uci -q get obuspa."${dhcp_mqtt}".TransportProtocol)
if [ -n "${port}" ] && [ "${conf_port}" != "${port}" ]; then
uci -q set obuspa.$dhcp_mqtt.BrokerPort="${port}"
uci -q set obuspa."${dhcp_mqtt}".BrokerPort="${port}"
uci_change=1
fi
if [ -n "${mtp_encrypt}" ] && [ "${conf_encr}" != "${mtp_encrypt}" ]; then
uci -q set obuspa.$dhcp_mqtt.TransportProtocol="${mtp_encrypt}"
uci -q set obuspa."${dhcp_mqtt}".TransportProtocol="${mtp_encrypt}"
uci_change=1
fi
if [ -n "${ip}" ] && [ "${conf_ip}" != "${ip}" ]; then
uci -q set obuspa.$dhcp_mqtt.BrokerAddress="${ip}"
uci -q set obuspa."${dhcp_mqtt}".BrokerAddress="${ip}"
uci_change=1
fi
fi
fi
else
uci -q del obuspa.dhcpmtp
uci -q del obuspa.dhcpmqtt
# Only setup a new controller, only if mandatory param present
if [ -n "${ENDPOINT_ID}" ] && [ -n "${URL}" ]; then
uci -q delete obuspa.dhcpmtp
uci -q delete obuspa.dhcpmqtt
sec=$(uci -q add obuspa controller)
uci -q rename obuspa."${sec}"='dhcpcontroller'
uci -q set obuspa.dhcpcontroller.dhcp_discovered="1"
uci -q set obuspa.dhcpcontroller.EndpointID="${ENDPOINT_ID}"
uci -q set obuspa.dhcpcontroller.ProvisioningCode="${PROV_CODE}"
uci -q set obuspa.dhcpcontroller.Protocol="${offered_proto}"
uci -q set obuspa.dhcpcontroller.assigned_role_name="$(get_access_role)"
uci -q set obuspa.dhcpcontroller.Enable='1'
uci -q set obuspa.dhcpcontroller="controller"
uci -q set obuspa.dhcpcontroller.dhcp_discovered="1"
uci -q set obuspa.dhcpcontroller.EndpointID="${ENDPOINT_ID}"
uci -q set obuspa.dhcpcontroller.ProvisioningCode="${PROV_CODE}"
uci -q set obuspa.dhcpcontroller.Protocol="${offered_proto}"
uci -q set obuspa.dhcpcontroller.assigned_role_name="$(get_access_role)"
uci -q set obuspa.dhcpcontroller.Enable='1'
if [ -n "${offered_proto}" ]; then
if [ "${offered_proto}" == "MQTT" ]; then
user="$(uci -q get obuspa.global.username)"
pass="$(uci -q get obuspa.global.password)"
if [ -n "${offered_proto}" ]; then
if [ "${offered_proto}" = "MQTT" ]; then
user="$(uci -q get obuspa.global.username)"
pass="$(uci -q get obuspa.global.password)"
uci -q set obuspa.dhcpcontroller.Topic="${topic}"
uci -q set obuspa.dhcpcontroller.mqtt='dhcpmqtt'
uci -q set obuspa.dhcpcontroller.Topic="${topic}"
uci -q set obuspa.dhcpcontroller.mqtt='dhcpmqtt'
sec=$(uci -q add obuspa mqtt)
uci -q rename obuspa."${sec}"='dhcpmqtt'
uci -q set obuspa.dhcpmqtt.BrokerAddress="${ip}"
uci -q set obuspa.dhcpmqtt.BrokerPort="${port}"
uci -q set obuspa.dhcpmqtt.TransportProtocol="${mtp_encrypt}"
uci -q set obuspa.dhcpmqtt.Enable='1'
uci -q set obuspa.dhcpmqtt.ProtocolVersion='5.0'
uci -q set obuspa.dhcpmqtt.Username="${user}"
uci -q set obuspa.dhcpmqtt.Password="${pass}"
uci -q set obuspa.dhcpmqtt="mqtt"
uci -q set obuspa.dhcpmqtt.BrokerAddress="${ip}"
uci -q set obuspa.dhcpmqtt.BrokerPort="${port}"
uci -q set obuspa.dhcpmqtt.TransportProtocol="${mtp_encrypt}"
uci -q set obuspa.dhcpmqtt.Enable='1'
uci -q set obuspa.dhcpmqtt.ProtocolVersion='5.0'
uci -q set obuspa.dhcpmqtt.Username="${user}"
uci -q set obuspa.dhcpmqtt.Password="${pass}"
agent_topic=$(get_agent_topic)
sec=$(uci -q add obuspa mtp)
uci -q rename obuspa."${sec}"='dhcpmtp'
uci -q set obuspa.dhcpmtp.Protocol='MQTT'
uci -q set obuspa.dhcpmtp.ResponseTopicConfigured="${agent_topic}"
uci -q set obuspa.dhcpmtp.Enable='1'
uci -q set obuspa.dhcpmtp.mqtt='dhcpmqtt'
else
uci -q set obuspa.dhcpcontroller.Path="${topic}"
uci -q set obuspa.dhcpcontroller.Host="${ip}"
uci -q set obuspa.dhcpcontroller.Port="${port}"
uci -q set obuspa.dhcpcontroller.EnableEncryption="${mtp_encrypt}"
agent_topic=$(get_agent_topic)
uci -q set obuspa.dhcpmtp="mtp"
uci -q set obuspa.dhcpmtp.Protocol='MQTT'
uci -q set obuspa.dhcpmtp.ResponseTopicConfigured="${agent_topic}"
uci -q set obuspa.dhcpmtp.Enable='1'
uci -q set obuspa.dhcpmtp.mqtt='dhcpmqtt'
else
uci -q set obuspa.dhcpcontroller.Path="${topic}"
uci -q set obuspa.dhcpcontroller.Host="${ip}"
uci -q set obuspa.dhcpcontroller.Port="${port}"
uci -q set obuspa.dhcpcontroller.EnableEncryption="${mtp_encrypt}"
sec=$(uci -q add obuspa mtp)
uci -q rename obuspa."${sec}"='dhcpmtp'
uci -q set obuspa.dhcpmtp.Protocol='WebSocket'
uci -q set obuspa.dhcpmtp.Port="${port}"
uci -q set obuspa.dhcpmtp.Enable='1'
uci -q set obuspa.dhcpmtp.EnableEncryption="${mtp_encrypt}"
uci -q set obuspa.dhcpmtp="mtp"
uci -q set obuspa.dhcpmtp.Protocol='WebSocket'
uci -q set obuspa.dhcpmtp.Port="${port}"
uci -q set obuspa.dhcpmtp.Enable='1'
uci -q set obuspa.dhcpmtp.EnableEncryption="${mtp_encrypt}"
fi
fi
uci_change=1
fi
uci_change=1
fi
if [ ${uci_change} -eq 1 ]; then
if [ -f "${OBUSPA_BOOT_MARKER}" ]; then
rm -f "${OBUSPA_BOOT_MARKER}"
fi
log "# Reloading obuspa as dhcp config changed"
ubus call uci commit '{"config":"obuspa"}'
fi

View File

@@ -0,0 +1,28 @@
diff --git a/src/core/database.c b/src/core/database.c
index 7ad9dae..edebd7c 100644
--- a/src/core/database.c
+++ b/src/core/database.c
@@ -955,6 +955,7 @@ void DATABASE_Dump(void)
int OpenUspDatabase(char *db_file)
{
int err;
+ char *err_msg = 0;
// Exit if unable to open the database
err = sqlite3_open(db_file, &db_handle);
@@ -965,6 +966,15 @@ int OpenUspDatabase(char *db_file)
return USP_ERR_INTERNAL_ERROR;
}
+ // Execute the PRAGMA statement
+ const char *sql = "PRAGMA journal_mode = MEMORY;";
+ err = sqlite3_exec(db_handle, sql, 0, 0, &err_msg);
+ if (err != SQLITE_OK) {
+ USP_LOG_Error("%s: Failed to set journal_mode: %s", __func__, err_msg);
+ sqlite3_free(err_msg);
+ return USP_ERR_INTERNAL_ERROR;
+ }
+
// Exit if unable to create the data model parameter table (if it does not already exist)
#define CREATE_TABLE_STR "create table if not exists data_model (hash integer, instances text, value text, primary key (hash, instances));"
err = sqlite3_exec(db_handle, CREATE_TABLE_STR, NULL, NULL, NULL);

View File

@@ -0,0 +1,23 @@
diff --git a/src/core/database.c b/src/core/database.c
index 7ad9dae..0bf9c90 100644
--- a/src/core/database.c
+++ b/src/core/database.c
@@ -1479,3 +1479,7 @@ int GetAllEntriesForParameter(db_hash_t hash, kv_vector_t *kvv)
return result;
}
+void DATABASE_force_reset_file()
+{
+ schedule_factory_reset_init = true;
+}
diff --git a/src/core/database.h b/src/core/database.h
index c88cf3a..376aa7a 100644
--- a/src/core/database.h
+++ b/src/core/database.h
@@ -67,5 +67,6 @@ void DATABASE_Dump(void);
int DATABASE_ReadDataModelInstanceNumbers(bool remove_unknown_params);
db_hash_t DATABASE_GetMigratedHash(db_hash_t hash);
+void DATABASE_force_reset_file();
#endif

View File

@@ -5,13 +5,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=parental-control
PKG_VERSION:=1.3.1
PKG_VERSION:=1.4.1
LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/network/parental-control.git
PKG_SOURCE_VERSION:=b1e5b3f81f08271bdaf9cb4bda8a7696a27be3c6
PKG_SOURCE_VERSION:=bd852e8b0a6528893917fb89e2ea27a8920f6280
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
endif

View File

@@ -12,7 +12,9 @@ validate_global_section() {
uci_validate_section parentalcontrol globals globals \
'enable:bool:1' \
'loglevel:uinteger:3' \
'queue_num:uinteger:53' \
'bundle_path:string' \
'default_wan_interface:string:wan' \
'urlfilter:bool'
}
@@ -24,11 +26,12 @@ remove_fw_rules() {
}
configure_fw_rules() {
local enable urlfilter
local enable urlfilter queue_num
config_load parentalcontrol
config_get_bool enable globals enable 0
config_get_bool urlfilter globals urlfilter 0
config_get queue_num globals queue_num 53
remove_fw_rules
@@ -37,6 +40,11 @@ configure_fw_rules() {
return 0
fi
if [ "${queue_num}" -lt 0 ] || [ "${queue_num}" -gt 65535 ]; then
log "ERROR: queue_num not in 0-65535"
return 1
fi
if [ "${urlfilter}" -eq "1" ]; then
if [ ! -f "${OVERRIDE_JSON}" ]; then
# throw error
@@ -48,11 +56,11 @@ configure_fw_rules() {
hw_nat -! > /dev/null 2>&1
fi
if which conntrack > /dev/null 2>&1; then
conntrack -F > /dev/null 2>&1
flush_conntrack_for_hosts
fi
# this is for urlfilter daemon
add_iptables_nfqueue_rules
add_iptables_nfqueue_rules "$queue_num"
fi
fi
@@ -107,7 +115,7 @@ start_service() {
procd_open_instance "parentalcontrol"
procd_set_param command nice -n 10 "${PROG}" # Lower priority
procd_append_param command -l ${loglevel}
procd_append_param command -l "${loglevel}"
procd_set_param respawn
procd_close_instance
}
@@ -120,11 +128,19 @@ stop_service() {
}
reload_service() {
local arg="$1"
ret=$(ubus call service list '{"name":"parentalcontrol"}' | jsonfilter -qe '@.parentalcontrol.instances.parentalcontrol.running')
if [ "$ret" != "true" ]; then
stop
start
else
if [ "$arg" = "network" ]; then
pidof_sync="$(pidof sync_bundles.sh)"
[ -n "$pidof_sync" ] && kill "$pidof_sync"
sleep 5
fi
configure_fw_rules
copy_dhcp_leases
ubus send parentalcontrol.reload
@@ -132,6 +148,19 @@ reload_service() {
}
service_triggers() {
local enable urlfilter default_wan_interface
validate_global_section || {
return 1
}
if [ "${urlfilter}" = "1" ] && [ "$enable" = "1" ] && [ -n "$default_wan_interface" ]; then
log "Adding interface trigger for $default_wan_interface"
procd_open_trigger
procd_add_interface_trigger "interface.*.up" "$default_wan_interface" /etc/init.d/parentalcontrol reload "network"
procd_close_trigger
fi
procd_add_reload_trigger "parentalcontrol"
procd_add_reload_trigger "schedules"
}

View File

@@ -438,102 +438,118 @@ add_internet_schedule_rules() {
}
add_iptables_nfqueue_rules() {
local filter_used
local queue_num="$1"
# Check if urlfilter used
if ! uci show parentalcontrol | grep -q profile_urlfilter; then
return
fi
# Check if urlfilter used
if ! uci show parentalcontrol | grep -q profile_urlfilter; then
return
fi
# IPv4 rules
iptables -w -nL FORWARD | grep -iqE "NFQUEUE"
if [ "$?" -ne 0 ]; then
# capture DNS responses (UDP/TCP sport 53) in FORWARD
iptables -w -I FORWARD 1 -p tcp --sport 53 -j NFQUEUE --queue-num 0 --queue-bypass
iptables -w -I FORWARD 1 -p udp --sport 53 -j NFQUEUE --queue-num 0 --queue-bypass
# IPv4
# FORWARD
if ! iptables -w -nL | grep -q "URLFILTER_FORWARD"; then
iptables -w -N URLFILTER_FORWARD
iptables -w -I FORWARD 1 -j URLFILTER_FORWARD
# INPUT: DNS replies to router, skip loopback
iptables -w -I INPUT 1 -p tcp --sport 53 ! -i lo -j NFQUEUE --queue-num 0 --queue-bypass
iptables -w -I INPUT 1 -p udp --sport 53 ! -i lo -j NFQUEUE --queue-num 0 --queue-bypass
# capture DNS responses (sport 53)
iptables -w -A URLFILTER_FORWARD -p tcp --sport 53 -j NFQUEUE --queue-num $queue_num --queue-bypass
iptables -w -A URLFILTER_FORWARD -p udp --sport 53 -j NFQUEUE --queue-num $queue_num --queue-bypass
# OUTPUT: DNS replies from router, skip loopback
iptables -w -I OUTPUT 1 -p tcp --sport 53 ! -o lo -j NFQUEUE --queue-num 0 --queue-bypass
iptables -w -I OUTPUT 1 -p udp --sport 53 ! -o lo -j NFQUEUE --queue-num 0 --queue-bypass
# HTTP/HTTPS flows
iptables -w -A URLFILTER_FORWARD -p tcp --match multiport --ports 80,443 -j NFQUEUE --queue-num $queue_num --queue-bypass
iptables -w -A URLFILTER_FORWARD -p udp --match multiport --ports 80,443 -j NFQUEUE --queue-num $queue_num --queue-bypass
fi
# HTTP/HTTPS flows for urlfilter
iptables -w -I FORWARD 1 -p tcp --match multiport --ports 80,443 -j NFQUEUE --queue-num 0 --queue-bypass
iptables -w -I FORWARD 1 -p udp --match multiport --ports 80,443 -j NFQUEUE --queue-num 0 --queue-bypass
# INPUT
if ! iptables -w -nL | grep -q "URLFILTER_INPUT"; then
iptables -w -N URLFILTER_INPUT
iptables -w -I INPUT 1 -j URLFILTER_INPUT
# disable acceleration for https packet so that they can be read by urlfilter
ebtables --concurrent -A FORWARD -p ip --ip-protocol 6 --ip-destination-port 443 -j SKIPLOG 2> /dev/null
ebtables --concurrent -A FORWARD -p ip --ip-protocol 6 --ip-source-port 53 -j SKIPLOG 2> /dev/null
ebtables --concurrent -A FORWARD -p ip --ip-protocol 17 --ip-source-port 53 -j SKIPLOG 2> /dev/null
fi
iptables -w -A URLFILTER_INPUT -p tcp --sport 53 ! -i lo -j NFQUEUE --queue-num $queue_num --queue-bypass
iptables -w -A URLFILTER_INPUT -p udp --sport 53 ! -i lo -j NFQUEUE --queue-num $queue_num --queue-bypass
fi
# IPv6 rules
ip6tables -w -nL FORWARD | grep -iqE "NFQUEUE"
if [ "$?" -ne 0 ]; then
# capture DNS responses (UDP/TCP sport 53) in FORWARD
ip6tables -w -I FORWARD 1 -p tcp --sport 53 -j NFQUEUE --queue-num 0 --queue-bypass
ip6tables -w -I FORWARD 1 -p udp --sport 53 -j NFQUEUE --queue-num 0 --queue-bypass
# OUTPUT
if ! iptables -w -nL | grep -q "URLFILTER_OUTPUT"; then
iptables -w -N URLFILTER_OUTPUT
iptables -w -I OUTPUT 1 -j URLFILTER_OUTPUT
# INPUT: DNS replies to router, skip loopback
ip6tables -w -I INPUT 1 -p tcp --sport 53 ! -i lo -j NFQUEUE --queue-num 0 --queue-bypass
ip6tables -w -I INPUT 1 -p udp --sport 53 ! -i lo -j NFQUEUE --queue-num 0 --queue-bypass
iptables -w -A URLFILTER_OUTPUT -p tcp --sport 53 ! -o lo -j NFQUEUE --queue-num $queue_num --queue-bypass
iptables -w -A URLFILTER_OUTPUT -p udp --sport 53 ! -o lo -j NFQUEUE --queue-num $queue_num --queue-bypass
fi
# OUTPUT: DNS replies from router, skip loopback
ip6tables -w -I OUTPUT 1 -p tcp --sport 53 ! -o lo -j NFQUEUE --queue-num 0 --queue-bypass
ip6tables -w -I OUTPUT 1 -p udp --sport 53 ! -o lo -j NFQUEUE --queue-num 0 --queue-bypass
# ebtables bypass for IPv4
ebtables --concurrent -A FORWARD -p ip --ip-protocol 6 --ip-destination-port 443 -j SKIPLOG 2>/dev/null
ebtables --concurrent -A FORWARD -p ip --ip-protocol 6 --ip-source-port 53 -j SKIPLOG 2>/dev/null
ebtables --concurrent -A FORWARD -p ip --ip-protocol 17 --ip-source-port 53 -j SKIPLOG 2>/dev/null
# HTTP/HTTPS flows for urlfilter
ip6tables -w -I FORWARD 1 -p tcp --match multiport --ports 80,443 -j NFQUEUE --queue-num 0 --queue-bypass
ip6tables -w -I FORWARD 1 -p udp --match multiport --ports 80,443 -j NFQUEUE --queue-num 0 --queue-bypass
# IPv6
# FORWARD
if ! ip6tables -w -nL | grep -q "URLFILTER_FORWARD6"; then
ip6tables -w -N URLFILTER_FORWARD6
ip6tables -w -I FORWARD 1 -j URLFILTER_FORWARD6
# disable acceleration for https packet so that they can be read by urlfilter
ebtables --concurrent -A FORWARD -p ip6 --ip6-protocol 6 --ip6-destination-port 443 -j SKIPLOG 2> /dev/null
ebtables --concurrent -A FORWARD -p ip6 --ip6-protocol 6 --ip6-source-port 53 -j SKIPLOG 2> /dev/null
ebtables --concurrent -A FORWARD -p ip6 --ip6-protocol 17 --ip6-source-port 53 -j SKIPLOG 2> /dev/null
fi
ip6tables -w -A URLFILTER_FORWARD6 -p tcp --sport 53 -j NFQUEUE --queue-num $queue_num --queue-bypass
ip6tables -w -A URLFILTER_FORWARD6 -p udp --sport 53 -j NFQUEUE --queue-num $queue_num --queue-bypass
ip6tables -w -A URLFILTER_FORWARD6 -p tcp --match multiport --ports 80,443 -j NFQUEUE --queue-num $queue_num --queue-bypass
ip6tables -w -A URLFILTER_FORWARD6 -p udp --match multiport --ports 80,443 -j NFQUEUE --queue-num $queue_num --queue-bypass
fi
# INPUT
if ! ip6tables -w -nL | grep -q "URLFILTER_INPUT6"; then
ip6tables -w -N URLFILTER_INPUT6
ip6tables -w -I INPUT 1 -j URLFILTER_INPUT6
ip6tables -w -A URLFILTER_INPUT6 -p tcp --sport 53 ! -i lo -j NFQUEUE --queue-num $queue_num --queue-bypass
ip6tables -w -A URLFILTER_INPUT6 -p udp --sport 53 ! -i lo -j NFQUEUE --queue-num $queue_num --queue-bypass
fi
# OUTPUT
if ! ip6tables -w -nL | grep -q "URLFILTER_OUTPUT6"; then
ip6tables -w -N URLFILTER_OUTPUT6
ip6tables -w -I OUTPUT 1 -j URLFILTER_OUTPUT6
ip6tables -w -A URLFILTER_OUTPUT6 -p tcp --sport 53 ! -o lo -j NFQUEUE --queue-num $queue_num --queue-bypass
ip6tables -w -A URLFILTER_OUTPUT6 -p udp --sport 53 ! -o lo -j NFQUEUE --queue-num $queue_num --queue-bypass
fi
# ebtables bypass for IPv6
ebtables --concurrent -A FORWARD -p ip6 --ip6-protocol 6 --ip6-destination-port 443 -j SKIPLOG 2>/dev/null
ebtables --concurrent -A FORWARD -p ip6 --ip6-protocol 6 --ip6-source-port 53 -j SKIPLOG 2>/dev/null
ebtables --concurrent -A FORWARD -p ip6 --ip6-protocol 17 --ip6-source-port 53 -j SKIPLOG 2>/dev/null
}
remove_iptables_nfqueue_rules() {
iptables -w -nL FORWARD | grep -iqE "NFQUEUE"
if [ "$?" -eq 0 ]; then
# DNS response rules
iptables -w -D FORWARD -p tcp --sport 53 -j NFQUEUE --queue-num 0 --queue-bypass
iptables -w -D FORWARD -p udp --sport 53 -j NFQUEUE --queue-num 0 --queue-bypass
iptables -w -D INPUT -p tcp --sport 53 ! -i lo -j NFQUEUE --queue-num 0 --queue-bypass
iptables -w -D INPUT -p udp --sport 53 ! -i lo -j NFQUEUE --queue-num 0 --queue-bypass
iptables -w -D OUTPUT -p tcp --sport 53 ! -o lo -j NFQUEUE --queue-num 0 --queue-bypass
iptables -w -D OUTPUT -p udp --sport 53 ! -o lo -j NFQUEUE --queue-num 0 --queue-bypass
# IPv4
for chain in URLFILTER_FORWARD URLFILTER_INPUT URLFILTER_OUTPUT; do
if iptables -w -nL | grep -q "$chain"; then
iptables -w -D FORWARD -j $chain 2>/dev/null
iptables -w -D INPUT -j $chain 2>/dev/null
iptables -w -D OUTPUT -j $chain 2>/dev/null
iptables -w -F $chain
iptables -w -X $chain
fi
done
# HTTP/HTTPS
iptables -w -D FORWARD -p tcp --match multiport --ports 80,443 -j NFQUEUE --queue-num 0 --queue-bypass
iptables -w -D FORWARD -p udp --match multiport --ports 80,443 -j NFQUEUE --queue-num 0 --queue-bypass
ebtables --concurrent -D FORWARD -p ip --ip-protocol 6 --ip-destination-port 443 -j SKIPLOG 2>/dev/null
ebtables --concurrent -D FORWARD -p ip --ip-protocol 6 --ip-source-port 53 -j SKIPLOG 2>/dev/null
ebtables --concurrent -D FORWARD -p ip --ip-protocol 17 --ip-source-port 53 -j SKIPLOG 2>/dev/null
ebtables --concurrent -D FORWARD -p ip --ip-protocol 6 --ip-destination-port 443 -j SKIPLOG 2> /dev/null
ebtables --concurrent -D FORWARD -p ip --ip-protocol 6 --ip-source-port 53 -j SKIPLOG 2> /dev/null
ebtables --concurrent -D FORWARD -p ip --ip-protocol 17 --ip-source-port 53 -j SKIPLOG 2> /dev/null
fi
# IPv6
for chain in URLFILTER_FORWARD6 URLFILTER_INPUT6 URLFILTER_OUTPUT6; do
if ip6tables -w -nL | grep -q "$chain"; then
ip6tables -w -D FORWARD -j $chain 2>/dev/null
ip6tables -w -D INPUT -j $chain 2>/dev/null
ip6tables -w -D OUTPUT -j $chain 2>/dev/null
ip6tables -w -F $chain
ip6tables -w -X $chain
fi
done
ip6tables -w -nL FORWARD | grep -iqE "NFQUEUE"
if [ "$?" -eq 0 ]; then
# DNS response rules
ip6tables -w -D FORWARD -p tcp --sport 53 -j NFQUEUE --queue-num 0 --queue-bypass
ip6tables -w -D FORWARD -p udp --sport 53 -j NFQUEUE --queue-num 0 --queue-bypass
ip6tables -w -D INPUT -p tcp --sport 53 ! -i lo -j NFQUEUE --queue-num 0 --queue-bypass
ip6tables -w -D INPUT -p udp --sport 53 ! -i lo -j NFQUEUE --queue-num 0 --queue-bypass
ip6tables -w -D OUTPUT -p tcp --sport 53 ! -o lo -j NFQUEUE --queue-num 0 --queue-bypass
ip6tables -w -D OUTPUT -p udp --sport 53 ! -o lo -j NFQUEUE --queue-num 0 --queue-bypass
# HTTP/HTTPS
ip6tables -w -D FORWARD -p tcp --match multiport --ports 80,443 -j NFQUEUE --queue-num 0 --queue-bypass
ip6tables -w -D FORWARD -p udp --match multiport --ports 80,443 -j NFQUEUE --queue-num 0 --queue-bypass
ebtables --concurrent -D FORWARD -p ip6 --ip6-protocol 6 --ip6-destination-port 443 -j SKIPLOG 2> /dev/null
ebtables --concurrent -D FORWARD -p ip6 --ip6-protocol 6 --ip6-source-port 53 -j SKIPLOG 2> /dev/null
ebtables --concurrent -D FORWARD -p ip6 --ip6-protocol 17 --ip6-source-port 53 -j SKIPLOG 2> /dev/null
fi
ebtables --concurrent -D FORWARD -p ip6 --ip6-protocol 6 --ip6-destination-port 443 -j SKIPLOG 2>/dev/null
ebtables --concurrent -D FORWARD -p ip6 --ip6-protocol 6 --ip6-source-port 53 -j SKIPLOG 2>/dev/null
ebtables --concurrent -D FORWARD -p ip6 --ip6-protocol 17 --ip6-source-port 53 -j SKIPLOG 2>/dev/null
}
remove_internet_schedule_rules() {
@@ -551,6 +567,62 @@ remove_internet_schedule_rules() {
fi
}
# Global array for resolved IPs
URLFILTER_IPS=""
# Resolve hostname or MAC to IP from lease_file
get_host_ip() {
local host="$1"
local ip
local lease_file="/tmp/dhcp.leases"
[ -f "$lease_file" ] || lease_file="/etc/parentalcontrol/dhcp.leases"
[ -f "$lease_file" ] || { log "Error: get_host_ip(): No DHCP lease file found."; return 1; }
# try DHCP lease lookup
ip="$(awk -v h="$host" '
{
mac=$2; ipaddr=$3; name=$4
if (h == name || h == mac) { print ipaddr; exit }
}' "$lease_file")"
[ -n "$ip" ] && URLFILTER_IPS="$URLFILTER_IPS $ip"
}
# Process each profile section
resolve_profile_hosts() {
local section="$1"
local hostlist
config_get hostlist "$section" host
[ -z "$hostlist" ] && return
for h in $hostlist; do
get_host_ip "$h"
done
}
# Main function to collect IPs and delete conntrack entries
flush_conntrack_for_hosts() {
URLFILTER_IPS=""
local count max
config_foreach resolve_profile_hosts profile
URLFILTER_IPS="$(echo "$URLFILTER_IPS" | tr ' ' '\n' | sort -u | xargs)"
for ip in $URLFILTER_IPS; do
count=0
max=1000
while conntrack -D -s "$ip" >/dev/null 2>&1; do
count=$((count+1))
if [ $count -ge $max ]; then
log "Warning: Forced to stop conntrack delete after $max deletions for $ip (possible loop)"
break
fi
done
done
}
OVERRIDE_JSON="/etc/parentalcontrol/urlbundle_override.json"
DM_PLUGIN_PATH="/usr/share/bbfdm/micro_services/parentalcontrol/urlbundle_override.json"

View File

@@ -161,7 +161,23 @@ handle_download_url() {
# If the URL is HTTP, fetch the file size
local bundle_file_size
if echo "$sanitized_url" | grep -qE "^https?://"; then
bundle_file_size="$(curl -I "$sanitized_url" 2>&1 | grep -i 'content-length' | cut -d: -f2 | xargs)"
bundle_file_header="$(curl -Is --max-time 30 "$sanitized_url" 2>/var/log/urlfilter_curl_err.log)"
curl_rc=$?
case $curl_rc in
0)
# Success
;;
6|7|28|35|52|55|56)
log_info "handle_download_url: URL not reachable (curl rc=$curl_rc): ${sanitized_url}"
return 1
;;
*)
log_info "handle_download_url: unexpected curl rc=$curl_rc for ${sanitized_url}"
;;
esac
bundle_file_size="$(echo "$bundle_file_header" | grep -i 'content-length' | cut -d: -f2 | xargs)"
[ -z "$bundle_file_size" ] && bundle_file_size=0
else
# If it's a file:// URL, get the file size from the filesystem

View File

@@ -30,7 +30,7 @@ define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) \
CC="$(TARGET_CC)" \
LDFLAGS="$(TARGET_LDFLAGS)" \
pam_wrapped
all_wrapped
endef
define Package/$(PKG_NAME)/install
@@ -40,8 +40,8 @@ define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/lib/security
$(INSTALL_BIN) $(PKG_BUILD_DIR)/pam_passwdqc.so $(1)/usr/lib/security/
$(INSTALL_DIR) $(1)/etc/uci-defaults/
$(INSTALL_BIN) ./files/passwdqc.uci_default $(1)/etc/uci-defaults/99-add_passwdqc_pam
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/pwqcheck $(1)/usr/sbin/
endef
$(eval $(call BuildPackage,$(PKG_NAME)))

View File

@@ -1,19 +0,0 @@
#!/bin/sh
CONFIG_FILE="/etc/pam.d/common-password"
# for some reason setting to 8 makes passwdqc accept minimum 12 letter password with this configuration
# if we set it to 12 then we need atleast 16 characters and so on
# passphrase = 0 means no space separated words
# rest can be figured out from passwdqc man page
MODULE_LINE="password requisite pam_passwdqc.so min=disabled,disabled,disabled,disabled,8 max=20 passphrase=0 retry=3 enforce=everyone"
# Ensure the file exists before modifying
[ -f "$CONFIG_FILE" ] || exit 0
# Check if pam_passwdqc is already in the file
if ! grep -q "pam_passwdqc.so" "$CONFIG_FILE"; then
# Insert before pam_unix.so
sed -i "/pam_unix.so/ i\\$MODULE_LINE" "$CONFIG_FILE"
fi
exit 0

View File

@@ -1,7 +1,7 @@
if PACKAGE_sshmngr
choice
prompt "Select backend for SSH management"
default SSHMNGR_BACKEND_OPENSSH
default SSHMNGR_BACKEND_OPENSSH_PAM
depends on PACKAGE_sshmngr
help
Select which backend daemon to use for SSH

View File

@@ -5,11 +5,11 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=sulu-base
PKG_VERSION:=5.1.2
PKG_VERSION:=5.1.8
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/websdk/sulu.git
PKG_SOURCE_VERSION:=6ee43863415b54c312a56e113a7a91d5ae25df28
PKG_SOURCE_VERSION:=24cb862a27b4282668b434044a20fdc2c437316b
PKG_MIRROR_HASH:=skip
SULU_MOD:=core

View File

@@ -5,12 +5,12 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=sulu-builder
PKG_VERSION:=5.1.2
PKG_VERSION:=5.1.8
PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/websdk/sulu-builder.git
PKG_SOURCE_VERSION:=cca6a777e46584c888a1a06fafa75f7a063b803d
PKG_SOURCE_VERSION:=89f778534565e4ee9cea80fe881e9739c83d4c57
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_SOURCE_VERSION)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_SOURCE_VERSION).tar.gz
PKG_BUILD_DIR:=$(BUILD_DIR)/sulu-$(PKG_VERSION)/sulu-builder-$(PKG_SOURCE_VERSION)

View File

@@ -4,7 +4,6 @@
. /lib/functions.sh
. /usr/share/libubox/jshn.sh
#. /lib/functions/iopsys-environment.sh
RESTART_REQ=0
_RESTART_SERVICES="0"
@@ -170,18 +169,20 @@ _create_mosquitto_acl() {
users="$(_get_sulu_user_roles)"
if [ -f "${ACL_FILE}" ]; then
acl_users="$(awk '/^user/ {print $2}' "${ACL_FILE}")"
for user in ${users}; do
if ! grep -q "$user" "${acl_users}"; then
acl_users="$(awk '/^user / {print $2}' "${ACL_FILE}")"
for user in ${acl_users}; do
if ! echo "$users" | grep -qwF "$user"; then
rm -f "${ACL_FILE}"
RESTART_REQ="1"
break
fi
done
fi
touch "${ACL_FILE}"
[ -f "${ACL_FILE}" ] || touch "${ACL_FILE}"
agentid="$(_get_agent_id)"
for user in ${users}; do
if ! grep -q "user $user" "${ACL_FILE}"; then
if ! grep -qxF "user $user" "${ACL_FILE}"; then
{
echo "user ${user}"
echo "topic read /usp/${agentid}/${user}/controller/reply-to"
@@ -200,9 +201,7 @@ _create_mosquitto_acl() {
}
update_obuspa_config() {
RESTART_REQ=0
uci_load obuspa
_update_obuspa_config_rbac
uci_commit obuspa
@@ -218,7 +217,7 @@ configure_sulu() {
generate_sulu_conn_config
}
while getopts ":rq" opt; do
while getopts ":r" opt; do
case ${opt} in
r)
_RESTART_SERVICES="1"

View File

@@ -1,15 +1,16 @@
#!/bin/sh
. /lib/functions.sh
UCI_TEMPLATE="/etc/nginx/uci.conf.template"
if [ ! -f "/etc/config/mosquitto" ]; then
echo "Local mosquitto broker not available"
return 0
logger -t sulu.ucidefault "Local mosquitto broker not available"
return 1
fi
if [ ! -f "${UCI_TEMPLATE}" ]; then
echo "nginx utils not installed, sulu can't run"
return 0
logger -t sulu.ucidefault "nginx utils not installed, sulu can't run"
return 1
fi
update_nginx_uci_template()
@@ -19,7 +20,7 @@ update_nginx_uci_template()
port="$(uci -q get mosquitto.sulu.port)"
port="${port:-9009}"
if ! grep -q "upstream websocket" ${UCI_TEMPLATE}; then
if ! grep -w "upstream websocket" ${UCI_TEMPLATE} | grep -wq "127.0.0.1:${port}"; then
sed -i '/#UCI_HTTP_CONFIG$/i\ map $http_upgrade $connection_upgrade { default upgrade; "" close; }' ${UCI_TEMPLATE}
sed -i "/#UCI_HTTP_CONFIG$/i\ upstream websocket { server 127.0.0.1:${port}; }" ${UCI_TEMPLATE}
fi
@@ -27,37 +28,30 @@ update_nginx_uci_template()
add_sulu_config_to_mosquitto()
{
if ! uci_get mosquitto sulu >/dev/null 2>&1; then
uci_add mosquitto listener sulu
uci_set mosquitto sulu enabled 1
uci_set mosquitto sulu port '9009'
uci_set mosquitto sulu no_remote_access '1'
uci_set mosquitto sulu protocol 'websockets'
uci_set mosquitto sulu auth_plugin '/usr/lib/mosquitto_auth_shadow.so'
uci_set mosquitto sulu acl_file '/etc/sulu/mqtt.acl'
fi
uci_add mosquitto listener sulu
uci_set mosquitto sulu enabled 1
uci_set mosquitto sulu port '9009'
uci_set mosquitto sulu no_remote_access '1'
uci_set mosquitto sulu protocol 'websockets'
uci_set mosquitto sulu auth_plugin '/usr/lib/mosquitto_auth_shadow.so'
uci_set mosquitto sulu acl_file '/etc/sulu/mqtt.acl'
}
add_sulu_userinterface_uci()
{
uci_load userinterface
if ! uci_get userinterface _sulu_s >/dev/null 2>&1; then
if [ -f "/etc/config/userinterface" ]; then
uci_add userinterface http_access _sulu_s
uci_set userinterface _sulu_s path_prefix '/sulu'
uci_set userinterface _sulu_s port '8443'
uci_add_list userinterface _sulu_s _nginx_include '/etc/sulu/nginx.locations'
uci_set userinterface _sulu_s _nginx_include '/etc/sulu/nginx.locations'
uci_set userinterface _sulu_s _nginx_uci_manage_ssl 'self-signed'
uci_set userinterface _sulu_s _nginx_ssl_certificate '/etc/nginx/conf.d/_lan.crt'
uci_set userinterface _sulu_s _nginx_ssl_certificate_key '/etc/nginx/conf.d/_lan.key'
uci_set userinterface _sulu_s _nginx_ssl_session_cache 'none'
uci_set userinterface _sulu_s _nginx_error_page '503 /maintenance.html'
uci_set userinterface _sulu_s protocol 'HTTPS'
uci_add_list userinterface _sulu_s role 'admin'
uci_add_list userinterface _sulu_s role 'user'
fi
uci_set userinterface _sulu_s role 'admin user'
if ! uci_get userinterface _suluredirect >/dev/null 2>&1; then
uci_add userinterface http_access _suluredirect
uci_set userinterface _suluredirect redirect '_sulu_s'
uci_set userinterface _suluredirect protocol 'HTTP'

View File

@@ -2,23 +2,16 @@
. /lib/functions.sh
uci_load nginx
# this is to make sure to not mess up existing config
if uci_get nginx _sulu_s >/dev/null 2>&1; then
exit 0
fi
update_default_nginx_listner() {
if [ ! -f /etc/config/nginx ]; then
return
if [ ! -f "/etc/config/nginx" ]; then
return 0
fi
if ! uci_get nginx _lan >/dev/null 2>&1; then
return
return 0
fi
if ! opkg list-installed |grep -q "luci "; then
if ! opkg list-installed | grep -q "^luci "; then
echo "Luci not installed, removing luci config"
uci_remove nginx _lan
uci_remove nginx _redirect2ssl
@@ -28,7 +21,7 @@ update_default_nginx_listner() {
uci_add_list nginx _lan listen "[::]:8443 ssl default_server"
if ! uci_get nginx _redirect2ssl >/dev/null 2>&1; then
return
return 0
fi
uci_remove nginx _redirect2ssl listen
@@ -39,17 +32,19 @@ update_default_nginx_listner() {
}
move_sulu_to_443_and_80() {
uci_load userinterface
if [ ! -f /etc/config/userinterface ]; then
return
if ! config_load userinterface; then
return 0
fi
set_port() {
local protocol
local protocol port
config_get protocol "$1" protocol
if [ "$protocol" == "HTTPS" ]; then
config_get port "$1" port
if [ "$protocol" == "HTTPS" ] && [ "${port}" -eq "8443" ]; then
uci_set userinterface "$1" port "443"
elif [ "$protocol" == "HTTP" ]; then
elif [ "$protocol" == "HTTP" ] && [ "${port}" -eq "8080" ]; then
uci_set userinterface "$1" port "80"
fi
}

View File

@@ -5,11 +5,11 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=sulu-theme-genexis
PKG_VERSION:=5.1.2
PKG_VERSION:=5.1.8
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/gnx/sulu-theme-genexis
PKG_SOURCE_VERSION:=bf58defd238eaf4d9e42df68942df2c8f7c4f136
PKG_SOURCE_VERSION:=d329108aa49a0d57325cd8e639c80ba70c126f3f
PKG_MIRROR_HASH:=skip
include ../sulu-builder/sulu.mk

View File

@@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=sulu-vendorext
PKG_VERSION:=0.0.1
PKG_VERSION:=0.0.4
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
@@ -22,16 +22,11 @@ define Build/Compile
endef
define Package/sulu-vendorext/install
$(BBFDM_INSTALL_MS_PLUGIN) ./extn/X_GENEXIS_EU_CWMP.json $(1) sysmngr
$(BBFDM_INSTALL_MS_PLUGIN) ./extn/X_GENEXIS_EU_extra_info.json $(1) sysmngr
$(BBFDM_INSTALL_MS_PLUGIN) ./extn/X_GENEXIS_EU_guest_wifi_5.json $(1) sysmngr
$(BBFDM_INSTALL_MS_PLUGIN) ./extn/X_GENEXIS_EU.json $(1) sysmngr
$(BBFDM_INSTALL_MS_PLUGIN) ./extn/X_GENEXIS_EU_mesh.json $(1) sysmngr
$(BBFDM_INSTALL_MS_PLUGIN) ./extn/X_GENEXIS_EU_voip.json $(1) sysmngr
$(BBFDM_INSTALL_MS_PLUGIN) ./extn/X_GENEXIS_EU_wan.json $(1) sysmngr
$(BBFDM_INSTALL_MS_PLUGIN) ./extn/X_GENEXIS_EU_guest_wifi_2_4.json $(1) sysmngr
$(BBFDM_INSTALL_MS_PLUGIN) ./extn/X_GENEXIS_EU_firewall.json $(1) firewallmngr
$(BBFDM_REGISTER_SERVICES) ./bbfdm_service.json $(1) suluvendorext
$(BBFDM_INSTALL_MS_DM) ./extn/X_IOWRT_EU_MAPController.json $(1) suluvendorext
$(CP) ./files/* $(1)/
endef

View File

@@ -1,12 +1,12 @@
{
"daemon": {
"enable": "1",
"service_name": "hostmngr",
"service_name": "suluvendorext",
"unified_daemon": false,
"services": [
{
"parent_dm": "Device.",
"object": "Hosts"
"object": "X_IOWRT_EU_MAPController"
}
],
"config": {

View File

@@ -1,182 +0,0 @@
{
"Device.DeviceInfo.X_GENEXIS_EU.CWMPManagementServer.": {
"type": "object",
"protocols": [
"usp"
],
"access": false,
"array": false,
"dependency": "file:/etc/config/cwmp",
"EnableCWMP": {
"type": "boolean",
"version": "2.15",
"read": true,
"write": true,
"protocols": [
"usp"
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "cwmp",
"section": {
"name": "cpe"
},
"option": {
"name": "enable"
}
}
}
]
},
"log_to_console": {
"type": "boolean",
"version": "2.15",
"read": true,
"write": true,
"protocols": [
"usp"
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "cwmp",
"section": {
"name": "cpe"
},
"option": {
"name": "log_to_console"
}
}
}
]
}
},
"Device.DeviceInfo.X_GENEXIS_EU.CWMPManagementServer.acs.": {
"type": "object",
"version": "2.15",
"protocols": [
"usp"
],
"access": false,
"array": false,
"dependency": "file:/etc/config/cwmp",
"url": {
"type": "string",
"version": "2.15",
"read": true,
"write": true,
"protocols": [
"usp"
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "cwmp",
"section": {
"name": "acs"
},
"option": {
"name": "url"
}
}
}
]
},
"userid": {
"type": "string",
"version": "2.15",
"read": true,
"write": true,
"protocols": [
"usp"
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "cwmp",
"section": {
"name": "acs"
},
"option": {
"name": "userid"
}
}
}
]
},
"password": {
"type": "string",
"version": "2.15",
"read": true,
"write": true,
"protocols": [
"usp"
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "cwmp",
"section": {
"name": "acs"
},
"option": {
"name": "passwd"
}
}
}
]
},
"periodic_interval_enable": {
"type": "boolean",
"version": "2.15",
"read": true,
"write": true,
"protocols": [
"usp"
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "cwmp",
"section": {
"name": "acs"
},
"option": {
"name": "periodic_inform_enable"
}
}
}
]
},
"periodic_inform_interval": {
"type": "int",
"version": "2.15",
"read": true,
"write": true,
"protocols": [
"usp"
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "cwmp",
"section": {
"name": "acs"
},
"option": {
"name": "periodic_inform_interval"
}
}
}
]
}
}
}

View File

@@ -1,180 +0,0 @@
{
"Device.DeviceInfo.X_GENEXIS_EU.external_info.": {
"type": "object",
"version": "1.00",
"protocols": [
"cwmp",
"usp"
],
"access": false,
"array": false,
"support_link": {
"type": "string",
"version": "1.00",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "heimgard",
"section": {
"name": "help_support"
},
"option": {
"name": "support_link"
}
}
}
]
},
"faq_link": {
"type": "string",
"version": "1.00",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "heimgard",
"section": {
"name": "help_support"
},
"option": {
"name": "faq_link"
}
}
}
]
},
"contact_link": {
"type": "string",
"version": "1.00",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "heimgard",
"section": {
"name": "help_support"
},
"option": {
"name": "contact_link"
}
}
}
]
},
"contact_phone": {
"type": "string",
"version": "1.00",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "heimgard",
"section": {
"name": "help_support"
},
"option": {
"name": "contact_phone"
}
}
}
]
},
"contact_times": {
"type": "string",
"version": "1.00",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "heimgard",
"section": {
"name": "help_support"
},
"option": {
"name": "contact_times"
}
}
}
]
},
"livechat_link": {
"type": "string",
"version": "1.00",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "heimgard",
"section": {
"name": "help_support"
},
"option": {
"name": "livechat_link"
}
}
}
]
},
"extra_info": {
"type": "string",
"version": "1.00",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "heimgard",
"section": {
"name": "help_support"
},
"option": {
"name": "extra_info"
}
}
}
]
}
}
}

View File

@@ -1,723 +0,0 @@
{
"Device.Firewall.X_GENEXIS_EU.": {
"type": "object",
"protocols": [
"cwmp",
"usp"
],
"access": false,
"array": false,
"Mode": {
"type": "string",
"enumerations": [
"Low",
"low",
"Medium",
"medium",
"High",
"high",
"Custom",
"custom"
],
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "string",
"mapping": [
{
"rpc": "get",
"type": "ubus",
"ubus": {
"object": "firewall_mode",
"method": "get",
"key": "mode"
}
},
{
"rpc": "set",
"type": "ubus",
"ubus": {
"object": "firewall_mode",
"method": "set",
"args": {
"mode": "@Value"
}
}
}
]
},
"Input": {
"type": "string",
"enumerations": [
"ACCEPT",
"REJECT",
"DROP"
],
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "string",
"mapping": [
{
"type": "uci",
"uci": {
"file": "firewall",
"section": {
"name": "@defaults[0]"
},
"option": {
"name": "input"
}
}
}
]
},
"Forward": {
"type": "string",
"enumerations": [
"ACCEPT",
"REJECT",
"DROP"
],
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "string",
"mapping": [
{
"type": "uci",
"uci": {
"file": "firewall",
"section": {
"name": "@defaults[0]"
},
"option": {
"name": "forward"
}
}
}
]
},
"Output": {
"type": "string",
"enumerations": [
"ACCEPT",
"REJECT",
"DROP"
],
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "string",
"mapping": [
{
"type": "uci",
"uci": {
"file": "firewall",
"section": {
"name": "@defaults[0]"
},
"option": {
"name": "output"
}
}
}
]
},
"Drop_invalid": {
"type": "boolean",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "boolean",
"mapping": [
{
"type": "uci",
"uci": {
"file": "firewall",
"section": {
"name": "@defaults[0]"
},
"option": {
"name": "drop_invalid"
}
}
}
]
},
"Synflood_protect": {
"type": "boolean",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "boolean",
"mapping": [
{
"type": "uci",
"uci": {
"file": "firewall",
"section": {
"name": "@defaults[0]"
},
"option": {
"name": "synflood_protect"
}
}
}
]
},
"ZoneNumberOfEntries": {
"type": "unsignedInt",
"protocols": [
"cwmp",
"usp"
],
"read": true,
"write": false,
"mapping": [
{
"type": "uci",
"uci": {
"file": "firewall",
"section": {
"type": "zone"
},
"option": {
"name": "@Count"
}
}
}
]
},
"Device.Firewall.X_GENEXIS_EU.Zone.{i}.": {
"type": "object",
"protocols": [
"cwmp",
"usp"
],
"access": true,
"array": true,
"mapping": {
"type": "uci",
"uci": {
"file": "firewall",
"section": {
"type": "zone"
},
"dmmapfile": "dmmap_firewall"
}
},
"Name": {
"type": "string",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "string",
"mapping": [
{
"type": "uci",
"uci": {
"file": "firewall",
"section": {
"type": "zone",
"index": "@i-1"
},
"option": {
"name": "name"
}
}
}
]
},
"Network": {
"type": "string",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"list": {
"datatype": "string"
},
"mapping": [
{
"type": "uci",
"uci": {
"file": "firewall",
"section": {
"type": "zone",
"index": "@i-1"
},
"option": {
"name": "network"
}
}
}
]
},
"Masq": {
"type": "boolean",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "boolean",
"mapping": [
{
"type": "uci",
"uci": {
"file": "firewall",
"section": {
"type": "zone",
"index": "@i-1"
},
"option": {
"name": "masq"
}
}
}
]
},
"Masq_src": {
"type": "string",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"list": {
"datatype": "string"
},
"mapping": [
{
"type": "uci",
"uci": {
"file": "firewall",
"section": {
"type": "zone",
"index": "@i-1"
},
"option": {
"name": "masq_src"
}
}
}
]
},
"Masq_dest": {
"type": "string",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"list": {
"datatype": "string"
},
"mapping": [
{
"type": "uci",
"uci": {
"file": "firewall",
"section": {
"type": "zone",
"index": "@i-1"
},
"option": {
"name": "masq_dest"
}
}
}
]
},
"Masq_allow_invalid": {
"type": "boolean",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "boolean",
"mapping": [
{
"type": "uci",
"uci": {
"file": "firewall",
"section": {
"type": "zone",
"index": "@i-1"
},
"option": {
"name": "masq_allow_invalid"
}
}
}
]
},
"Mtu_fix": {
"type": "boolean",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"description": "MSS clamping",
"datatype": "boolean",
"mapping": [
{
"type": "uci",
"uci": {
"file": "firewall",
"section": {
"type": "zone",
"index": "@i-1"
},
"option": {
"name": "mtu_fix"
}
}
}
]
},
"Input": {
"type": "string",
"enumerations": [
"ACCEPT",
"REJECT",
"DROP"
],
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "string",
"mapping": [
{
"type": "uci",
"uci": {
"file": "firewall",
"section": {
"type": "zone",
"index": "@i-1"
},
"option": {
"name": "input"
}
}
}
]
},
"Forward": {
"type": "string",
"enumerations": [
"ACCEPT",
"REJECT",
"DROP"
],
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "string",
"mapping": [
{
"type": "uci",
"uci": {
"file": "firewall",
"section": {
"type": "zone",
"index": "@i-1"
},
"option": {
"name": "forward"
}
}
}
]
},
"Output": {
"type": "string",
"enumerations": [
"ACCEPT",
"REJECT",
"DROP"
],
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "string",
"mapping": [
{
"type": "uci",
"uci": {
"file": "firewall",
"section": {
"type": "zone",
"index": "@i-1"
},
"option": {
"name": "output"
}
}
}
]
},
"Family": {
"type": "string",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "string",
"mapping": [
{
"type": "uci",
"uci": {
"file": "firewall",
"section": {
"type": "zone",
"index": "@i-1"
},
"option": {
"name": "family"
}
}
}
]
},
"Log": {
"type": "unsignedInt",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "unsignedInt",
"mapping": [
{
"type": "uci",
"uci": {
"file": "firewall",
"section": {
"type": "zone",
"index": "@i-1"
},
"option": {
"name": "log"
}
}
}
]
},
"Device": {
"type": "string",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"list": {
"datatype": "string"
},
"mapping": [
{
"type": "uci",
"uci": {
"file": "firewall",
"section": {
"type": "zone",
"index": "@i-1"
},
"option": {
"name": "device"
}
}
}
]
},
"Subnet": {
"type": "string",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"list": {
"datatype": "string"
},
"mapping": [
{
"type": "uci",
"uci": {
"file": "firewall",
"section": {
"type": "zone",
"index": "@i-1"
},
"option": {
"name": "subnet"
}
}
}
]
},
"Auto_helper": {
"type": "boolean",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "boolean",
"mapping": [
{
"type": "uci",
"uci": {
"file": "firewall",
"section": {
"type": "zone",
"index": "@i-1"
},
"option": {
"name": "auto_helper"
}
}
}
]
}
},
"ForwardingNumberOfEntries": {
"type": "unsignedInt",
"protocols": [
"cwmp",
"usp"
],
"read": true,
"write": false,
"mapping": [
{
"type": "uci",
"uci": {
"file": "firewall",
"section": {
"type": "forwarding"
},
"option": {
"name": "@Count"
}
}
}
]
},
"Device.Firewall.X_GENEXIS_EU.Forwarding.{i}.": {
"type": "object",
"protocols": [
"cwmp",
"usp"
],
"access": true,
"array": true,
"mapping": {
"type": "uci",
"uci": {
"file": "firewall",
"section": {
"type": "forwarding"
},
"dmmapfile": "dmmap_firewall"
}
},
"Src": {
"type": "string",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "string",
"mapping": [
{
"type": "uci",
"uci": {
"file": "firewall",
"section": {
"type": "forwarding",
"index": "@i-1"
},
"option": {
"name": "src"
}
}
}
]
},
"Dest": {
"type": "string",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "string",
"mapping": [
{
"type": "uci",
"uci": {
"file": "firewall",
"section": {
"type": "forwarding",
"index": "@i-1"
},
"option": {
"name": "dest"
}
}
}
]
}
}
}
}

View File

@@ -1,168 +0,0 @@
{
"Device.DeviceInfo.X_GENEXIS_EU.guest2.": {
"type": "object",
"version": "1.00",
"protocols": [
"cwmp",
"usp"
],
"access": false,
"array": false,
"ssid": {
"type": "string",
"version": "1.00",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"mapping": [
{
"rpc": "get",
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"name": "guest2"
},
"option": {
"name": "ssid"
}
}
},
{
"rpc": "set",
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"name": "guest2"
},
"option": {
"name": "ssid"
}
}
}
]
},
"encryption": {
"type": "string",
"version": "1.00",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"mapping": [
{
"rpc": "get",
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"name": "guest2"
},
"option": {
"name": "encryption"
}
}
},
{
"rpc": "set",
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"name": "guest2"
},
"option": {
"name": "encryption"
}
}
}
]
},
"key": {
"type": "string",
"version": "1.00",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"mapping": [
{
"rpc": "get",
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"name": "guest2"
},
"option": {
"name": "key"
}
}
},
{
"rpc": "set",
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"name": "guest2"
},
"option": {
"name": "key"
}
}
}
]
},
"enabled": {
"type": "boolean",
"version": "1.00",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"mapping": [
{
"rpc": "get",
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"name": "guest2"
},
"option": {
"name": "enabled"
}
}
},
{
"rpc": "set",
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"name": "guest2"
},
"option": {
"name": "enabled"
}
}
}
]
}
}
}

View File

@@ -1,167 +0,0 @@
{
"Device.DeviceInfo.X_GENEXIS_EU.guest5.": {
"type": "object",
"version": "1.00",
"protocols": [
"cwmp",
"usp"
],
"access": false,
"array": false,
"ssid": {
"type": "string",
"version": "1.00",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"mapping": [
{
"rpc": "get",
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"name": "guest5"
},
"option": {
"name": "ssid"
}
}
},
{
"rpc": "set",
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"name": "guest5"
},
"option": {
"name": "ssid"
}
}
}
]
},
"encryption": {
"type": "string",
"version": "1.00",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"mapping": [
{
"rpc": "get",
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"name": "guest5"
},
"option": {
"name": "encryption"
}
}
},
{
"rpc": "set",
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"name": "guest5"
},
"option": {
"name": "encryption"
}
}
}
]
},
"key": {
"type": "string",
"version": "1.00",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"mapping": [
{
"rpc": "get",
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"name": "guest5"
},
"option": {
"name": "key"
}
}
},
{
"rpc": "set",
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"name": "guest5"
},
"option": {
"name": "key"
}
}
}
]
},
"enabled": {
"type": "boolean",
"version": "1.00",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"mapping": [
{
"rpc": "get",
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"name": "guest5"
},
"option": {
"name": "enabled"
}
}
},
{
"rpc": "set",
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"name": "guest5"
},
"option": {
"name": "enabled"
}
}
}
]
}
}
}

View File

@@ -1,416 +0,0 @@
{
"Device.DeviceInfo.X_GENEXIS_EU_mesh.": {
"type": "object",
"protocols": [
"cwmp",
"usp"
],
"access": false,
"array": false,
"meshmode": {
"type": "string",
"version": "1.00",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"mapping": [
{
"rpc": "get",
"type": "ubus",
"ubus": {
"object": "meshmode",
"method": "status",
"key": "mode"
}
},
{
"rpc": "set",
"type": "ubus",
"ubus": {
"object": "meshmode",
"method": "change_meshmode",
"args": {
"mode": "@Value"
}
}
}
]
},
"easymesh_controller_enabled": {
"type": "boolean",
"version": "1.00",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"default": true,
"mapping": [
{
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"name": "controller"
},
"option": {
"name": "enabled"
}
}
}
]
},
"enable_sta_steer": {
"type": "boolean",
"version": "1.00",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"name": "@sta_steering[0]"
},
"option": {
"name": "enable_sta_steer"
}
}
}
]
},
"use_bcn_metrics": {
"type": "boolean",
"version": "1.00",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"name": "@sta_steering[0]"
},
"option": {
"name": "use_bcn_metrics"
}
}
}
]
},
"sta_steering_enabled": {
"type": "boolean",
"version": "1.00",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"name": "@sta_steering[0]"
},
"option": {
"name": "enabled"
}
}
}
]
},
"ApNumberOfEntries": {
"type": "unsignedInt",
"protocols": [
"cwmp",
"usp"
],
"read": true,
"write": false,
"mapping": [
{
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"type": "ap"
},
"option": {
"name": "@Count"
}
}
}
]
},
"Device.DeviceInfo.X_GENEXIS_EU_mesh.ap.{i}.": {
"type": "object",
"protocols": [
"cwmp",
"usp"
],
"access": true,
"array": true,
"mapping": {
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"type": "ap"
},
"dmmapfile": "dmmap_mapcontroller"
}
},
"ssid": {
"type": "string",
"version": "1.00",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "string",
"mapping": [
{
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"type": "ap",
"index": "@{i-1}"
},
"option": {
"name": "ssid"
}
}
}
]
},
"band": {
"type": "unsignedInt",
"version": "1.00",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"enumerations": [
"2",
"5",
"6"
],
"datatype": "string",
"mapping": [
{
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"type": "ap",
"index": "@{i-1}"
},
"option": {
"name": "band"
}
}
}
]
},
"encryption": {
"type": "string",
"version": "1.00",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"enumerations": [
"sae",
"sae+aes",
"psk2",
"psk2+aes",
"sae-mixed",
"sae-mixed+aes",
"none",
"psk-mixed",
"psk-mixed+aes",
"psk",
"psk+aes"
],
"datatype": "string",
"mapping": [
{
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"type": "ap",
"index": "@{i-1}"
},
"option": {
"name": "encryption"
}
}
}
]
},
"key": {
"type": "string",
"version": "1.00",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "string",
"mapping": [
{
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"type": "ap",
"index": "@{i-1}"
},
"option": {
"name": "key"
}
}
}
]
},
"vid": {
"type": "unsignedInt",
"version": "1.00",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "string",
"mapping": [
{
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"type": "ap",
"index": "@{i-1}"
},
"option": {
"name": "vid"
}
}
}
]
},
"ap_type": {
"type": "string",
"version": "1.00",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"enumerations": [
"fronthaul",
"backhaul",
"combined"
],
"datatype": "string",
"mapping": [
{
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"type": "ap",
"index": "@{i-1}"
},
"option": {
"name": "type"
}
}
}
]
},
"builtin": {
"type": "boolean",
"version": "1.00",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "boolean",
"mapping": [
{
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"type": "ap",
"index": "@{i-1}"
},
"option": {
"name": "builtin"
}
}
}
]
},
"enabled": {
"type": "boolean",
"version": "1.00",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"datatype": "boolean",
"default": true,
"mapping": [
{
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"type": "ap",
"index": "@{i-1}"
},
"option": {
"name": "enabled"
}
}
}
]
}
}
}
}

View File

@@ -1,73 +0,0 @@
{
"json_plugin_version": 2,
"Device.Services.VoiceService.{i}.SIP.Client.{i}.": {
"type": "object",
"protocols": [
"cwmp",
"usp"
],
"access": true,
"array": true,
"X_GENEXIS_EU_reset": {
"type": "string",
"read": false,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"mapping": [
{
"rpc": "set",
"type": "ubus",
"ubus": {
"object": "voip",
"method": "reset",
"args": {
"sip": "@Value"
}
}
}
]
},
"X_GENEXIS_EU_reset()": {
"type": "command",
"async": true,
"protocols": [
"usp"
],
"input": {
"sip": {
"type": "string",
"read": "true",
"write": "true",
"protocols": [
"usp"
]
}
},
"output": {
"result": {
"type": "string",
"read": "true",
"write": "false",
"protocols": [
"usp"
]
}
},
"mapping": [
{
"type": "ubus",
"ubus": {
"object": "voip",
"method": "reset",
"args": {
"sip": "@Input.sip"
}
}
}
]
}
}
}

View File

@@ -0,0 +1,206 @@
{
"json_plugin_version": 2,
"Device.X_IOWRT_EU_MAPController.": {
"type": "object",
"protocols": [
"usp"
],
"access": false,
"array": false,
"Device.X_IOWRT_EU_MAPController.Controller.": {
"type": "object",
"protocols": [
"usp"
],
"access": false,
"array": false,
"dependency": "file:/etc/config/mapcontroller",
"Enable": {
"type": "boolean",
"read": true,
"write": true,
"protocols": [
"usp"
],
"default": true,
"mapping": [
{
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"name": "controller"
},
"option": {
"name": "enabled"
}
}
}
]
},
"ChannelPlan": {
"type": "unsignedInt",
"read": true,
"write": true,
"protocols": [
"usp"
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"name": "controller"
},
"option": {
"name": "channel_plan_interval"
}
}
}
]
},
"AllowBackgroundDFS": {
"type": "unsignedInt",
"read": true,
"write": true,
"protocols": [
"usp"
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"name": "controller"
},
"option": {
"name": "bgdfs_interval"
}
}
}
]
},
"TrafficSeparation": {
"type": "boolean",
"read": true,
"write": true,
"protocols": [
"usp"
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"name": "controller"
},
"option": {
"name": "traffic_separation"
}
}
}
]
},
"InitialChannelScan": {
"type": "boolean",
"read": true,
"write": true,
"protocols": [
"usp"
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"name": "controller"
},
"option": {
"name": "initial_scan"
}
}
}
]
}
},
"Device.X_IOWRT_EU_MAPController.STASteering.": {
"type": "object",
"protocols": [
"usp"
],
"access": false,
"array": false,
"dependency": "file:/etc/config/mapcontroller",
"STASteering": {
"type": "boolean",
"read": true,
"write": true,
"protocols": [
"usp"
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"name": "sta_steering"
},
"option": {
"name": "enable_sta_steer"
}
}
}
]
},
"BackhaulSTASteering": {
"type": "boolean",
"read": true,
"write": true,
"protocols": [
"usp"
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"name": "sta_steering"
},
"option": {
"name": "enable_bsta_steer"
}
}
}
]
},
"BandSteering": {
"type": "boolean",
"read": true,
"write": true,
"protocols": [
"usp"
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "mapcontroller",
"section": {
"name": "sta_steering"
},
"option": {
"name": "bandsteer"
}
}
}
]
}
}
}
}

View File

@@ -1,92 +0,0 @@
#!/bin/sh /etc/rc.common
START=97
USE_PROCD=1
start_service() {
# --- STEP 1: process fronthaul APs with mld_id ---
mld_ids=$(uci show mapcontroller | grep "^mapcontroller.@ap\[" | cut -d'=' -f1 | while read -r ap; do
[ "$(uci -q get "$ap.type")" = "fronthaul" ] || continue
uci -q get "$ap.mld_id"
done | sort -u | grep -v '^$')
for mld_id in $mld_ids; do
ap_list=""
ssid_ref=""
key_ref=""
ssid_mismatch=0
# collect all fronthaul APs with this mld_id
for ap in $(uci show mapcontroller | grep "^mapcontroller.@ap\[" | cut -d'=' -f1); do
[ "$(uci -q get "$ap.type")" = "fronthaul" ] || continue
cur_id=$(uci -q get "$ap.mld_id")
[ "$cur_id" = "$mld_id" ] || continue
cur_ssid=$(uci -q get "$ap.ssid")
cur_key=$(uci -q get "$ap.key")
ap_list="$ap_list $ap"
if [ -z "$ssid_ref" ]; then
ssid_ref="$cur_ssid"
key_ref="$cur_key"
elif [ "$cur_ssid" != "$ssid_ref" ]; then
ssid_mismatch=1
fi
done
if [ "$ssid_mismatch" -eq 1 ]; then
for ap in $ap_list; do
logger -t mldsync "Removing mld_id from $ap due to SSID mismatch"
uci -q delete "$ap.mld_id"
done
else
for mld in $(uci show mapcontroller | grep "^mapcontroller.@mld\[" | cut -d'=' -f1); do
[ "$(uci -q get "$mld.id")" = "$mld_id" ] || continue
logger -t mldsync "Updating $mld with ssid=$ssid_ref and key=$key_ref"
uci -q set "$mld.ssid=$ssid_ref"
uci -q set "$mld.key=$key_ref"
done
fi
done
# --- STEP 2: handle fronthaul APs with no mld_id but same SSID ---
for ssid in $(uci show mapcontroller | grep "^mapcontroller.@ap\[" | cut -d'=' -f1 | while read -r ap; do
[ "$(uci -q get "$ap.type")" = "fronthaul" ] || continue
[ -z "$(uci -q get "$ap.mld_id")" ] || continue
uci -q get "$ap.ssid"
done | sort | uniq); do
ap_group=""
key_ref=""
count=0
for ap in $(uci show mapcontroller | grep "^mapcontroller.@ap\[" | cut -d'=' -f1); do
[ "$(uci -q get "$ap.type")" = "fronthaul" ] || continue
[ "$(uci -q get "$ap.ssid")" = "$ssid" ] || continue
[ -z "$(uci -q get "$ap.mld_id")" ] || continue
ap_group="$ap_group $ap"
key_ref=$(uci -q get "$ap.key")
count=$((count + 1))
done
[ "$count" -lt 2 ] && continue
for ap in $ap_group; do
logger -t mldsync "Assigning mld_id=1 to $ap (ssid=$ssid)"
uci -q set "$ap.mld_id=1"
done
for mld in $(uci show mapcontroller | grep "^mapcontroller.@mld\[" | cut -d'=' -f1); do
[ "$(uci -q get "$mld.id")" = "1" ] || continue
logger -t mldsync "Updating $mld with ssid=$ssid and key=$key_ref (from unassigned group)"
uci -q set "$mld.ssid=$ssid"
uci -q set "$mld.key=$key_ref"
done
done
uci -q commit mapcontroller
}
service_triggers() {
procd_add_reload_trigger "mapcontroller"
}

View File

@@ -2,8 +2,9 @@
# shellcheck disable=SC1091,SC3043,SC3043
. /usr/share/libubox/jshn.sh
. /lib/functions/network.sh
persistent_file="/opconf/user.json"
persistent_file="/tmp/sulu.json"
init_json() {
json_init
@@ -14,7 +15,33 @@ init_json() {
fi
if ! json_select "wan" >/dev/null; then
local current_dev=""
local current_proto=""
local current_vid=""
local current_mtu=""
local current_username=""
local current_password=""
local default_gw_interface=""
# Load current settings
network_find_wan default_gw_interface
[ -z "${default_gw_interface}" ] && default_gw_interface="wan"
current_dev="$(uci -q get network."${default_gw_interface}".device)"
current_proto="$(uci -q get network."${default_gw_interface}".proto || echo "dhcp")"
current_vid="$(uci -q get network."${current_dev}".vid)"
current_mtu="$(uci -q get network."${default_gw_interface}".mtu)"
if [ "pppoe" = "${current_proto}" ]; then
current_username="$(uci -q get network."${default_gw_interface}".username)"
current_password="$(uci -q get network."${default_gw_interface}".password)"
fi
json_add_array "wan"
json_add_object
json_add_string "name" "wan"
json_add_string "proto" "${current_proto}"
[ -n "${current_vid}" ] && json_add_int "vlan_id" "${current_vid}"
[ -n "${current_mtu}" ] && json_add_int "mtu" "${current_mtu}"
[ -n "${current_username}" ] && json_add_string "username" "${current_username}"
[ -n "${current_password}" ] && json_add_string "password" "${current_password}"
json_close_object
fi
json_close_object
json_close_object
@@ -31,11 +58,13 @@ save_and_exit() {
save_userconf() {
json_dump >"${persistent_file}"
opconf "${persistent_file}"
# reload opconf to apply changes from persistent file, discarding output
opconf "${persistent_file}" > /dev/null 2>&1
# Commit network changes
ubus call uci commit '{"config": "network"}'
}
# Create skeleton file if it doesn't exists after that load in user.json
# Create skeleton file if it doesn't exists after that load in $persistent_file
init_json
go_L2() {
@@ -132,6 +161,9 @@ set_wan_param() {
vid | vland_id)
json_add_int "vlan_id" "${value}"
;;
mtu)
json_add_int "mtu" "${value}"
;;
*)
logger "sulu_functions: Unkown name '${name}' in set_wan_param"
;;
@@ -139,7 +171,7 @@ set_wan_param() {
json_close_object
json_select ..
json_select ..
logger -s "Name: '${name}'='${value}'"
logger -s "sulu_functions Name: '${name}'='${value}'"
save_userconf
json_set_namespace old_cb
}
@@ -158,7 +190,7 @@ get_wan_value() {
*) ;;
esac
for json_file in /opconf/*.json; do
for json_file in /opconf/*.json ${persistent_file}; do
value_from_opconf="$(jsonfilter -e "@.network.wan[@.name='wan'].${variable_name}" <"${json_file}")"
[ -n "${value_from_opconf}" ] && final_config="${value_from_opconf}"
done

View File

@@ -1,144 +0,0 @@
#!/bin/sh
. /usr/share/libubox/jshn.sh
get_fwmode() {
uci -q get firewall.globals.mode || echo "custom"
}
set_fwmode() {
local mode=$1
local allow_gw_rule="allow_gw_in"
local services="http https smtp pop3 imap ssh"
local ports="80 443 25 110 143 22"
uci set firewall.globals.mode="$mode"
# Set some defaults and start from a clean slate
uci set firewall.lan.input='ACCEPT'
uci set firewall.lan.output='ACCEPT'
uci set firewall.lan.forward='ACCEPT'
uci set firewall.wan.input='REJECT'
uci set firewall.wan.output='ACCEPT'
uci set firewall.wan.forward='REJECT'
# remove rules from low mode
uci -q delete firewall.${allow_gw_rule}
# remove rules from high mode
for service in $services; do
uci -q delete firewall.allow_${service}_out
done
# handle any custom zones and forwardings
for zone in $(uci show firewall | grep "=zone" | cut -d'.' -f2 | cut -d'=' -f1); do
if [ "$zone" == "lan" ] || [ "$zone" == "wan" ]; then
continue
fi
if [ "$mode" == "custom" ]; then
uci set firewall.${zone}.enabled=1
else
uci set firewall.${zone}.enabled=0
fi
done
for forwarding in $(uci show firewall | grep "=forwarding" | cut -d'.' -f2 | cut -d'=' -f1); do
if [ "$forwarding" == "default_fwd_1" ]; then
continue
fi
if [ "$mode" == "custom" ]; then
uci set firewall.${forwarding}.enabled=1
else
uci set firewall.${forwarding}.enabled=0
fi
done
# Now set mode specific presets
case "$mode" in
low)
# add rule for incoming gateway
json_load "$(ubus call heimgard.wan status)"
json_get_var gateway gateway
uci set firewall.${allow_gw_rule}=rule
uci set firewall.${allow_gw_rule}.name='Allow-Gateway-In'
uci set firewall.${allow_gw_rule}.src='wan'
uci set firewall.${allow_gw_rule}.src_ip="$gateway"
uci set firewall.${allow_gw_rule}.target='ACCEPT'
uci reorder firewall.${allow_gw_rule}=1
;;
medium)
uci set firewall.wan.input='DROP'
uci set firewall.wan.forward='DROP'
;;
high)
uci set firewall.wan.input='DROP'
uci set firewall.wan.output='REJECT'
uci set firewall.wan.forward='DROP'
# add rules for outgoing services
i=1
for service in $services; do
port=$(echo $ports | cut -d' ' -f$i)
uci set firewall.allow_${service}_out=rule
uci set firewall.allow_${service}_out.name="Allow-${service}-Out"
uci set firewall.allow_${service}_out.src='lan'
uci set firewall.allow_${service}_out.dest='wan'
uci set firewall.allow_${service}_out.proto='tcp'
uci set firewall.allow_${service}_out.dest_port="$port"
uci set firewall.allow_${service}_out.target='ACCEPT'
uci reorder firewall.allow_${service}_out=1
i=$((i + 1))
done
;;
custom)
uci -q delete firewall.globals.mode # keep or not keep?
# in custom mode we will get additional usp calls to set config directly towards uci
;;
esac
ubus call uci commit '{"config": "firewall"}'
logger -t "firewall.ubus" "Commited and applied new firewall config"
}
fwmode="$(get_fwmode)"
case "$1" in
list)
echo '{ "get" : {}, "set" : {"mode":"String"}}'
;;
call)
case "$2" in
get)
if [ -n "$fwmode" ]; then
echo '{"mode": "'"$fwmode"'"}'
else
echo '{"error": "Could not detect mode"}'
fi
;;
set)
# Read the JSON object provided for the arguments
read -r input
json_load "${input}"
json_get_var mode mode
mode=$(echo "$mode" | tr 'A-Z' 'a-z')
case "$mode" in
low | medium | high | custom)
if [ "$mode" == "$fwmode" ]; then
echo '{"status": "No change"}'
return
fi
set_fwmode "$mode"
echo '{"status": "Ok"}'
;;
*)
echo '{"error": "Incorrect mode ('"$mode"')"}'
;;
esac
;;
esac
;;
esac

View File

@@ -99,7 +99,7 @@ call)
read -r input
_param="$(echo "$input" | jsonfilter -e '@.param')"
value="$(echo "$input" | jsonfilter -e '@.value')"
logger -t "heimgard.wan" "_param: ${_param} value: ${value}"
logger -t "genexis.wan" "_param: ${_param} value: ${value}"
json_init
reply="$(set_wan_param "$_param" "$value")"
json_add_string "status" "${reply}"

View File

@@ -7,10 +7,9 @@ init_json
get_netmode() {
local _netmode
local persistent_file="/opconf/user.json"
if [ -f "${persistent_file}" ]; then
json_init
json_load_file '/opconf/user.json'
json_load_file "${persistent_file}"
if json_select netmode; then
json_get_var _netmode current "unknown"
json_select ..

View File

@@ -1,32 +0,0 @@
#!/bin/sh
. /usr/share/libubox/jshn.sh
case "$1" in
list)
echo '{ "reset" : {"sip": "string"} }'
;;
call)
case "$2" in
reset)
read input;
sip=`echo $input | jsonfilter -e '@.sip'`
if [ "$sip" == "" ] || [ ! $(uci -q get asterisk.$sip) ]; then
result="incorrect parameter $input"
else
ubus call uci set '{"config":"asterisk", "section":"'$sip'", "values": {"enable":"0"}}'
ubus call uci commit '{"config":"asterisk"}'
ubus call uci set '{"config":"asterisk", "section":"'$sip'", "values": {"enable":"1"}}'
ubus call uci commit '{"config":"asterisk"}'
result="ok"
fi
json_init
json_add_string "status" "$result"
json_dump
;;
esac
;;
esac

View File

@@ -85,6 +85,7 @@ migrate_timemngr_config() {
fi
uci -q delete system.ntp
return 0
}
migrate_timemngr_config

View File

@@ -5,13 +5,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=tr143
PKG_VERSION:=1.1.3.1
PKG_VERSION:=1.1.3.2
LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/bbf/tr143d.git
PKG_SOURCE_VERSION:=1a10867d639afeb535d6c639b95b25648eb4ef7b
PKG_SOURCE_VERSION:=54c76c7afd4eb45d929f3512e96f572f2ad4e2ea
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
endif

21
usermngr/Config.in Normal file
View File

@@ -0,0 +1,21 @@
if PACKAGE_usermngr
config USERMNGR_SECURITY_HARDENING
bool "Security hardening mechanisms"
default y
help
Enable this option to use PAM based faillock, passwdqc, faildelay for security hardening.
config USERMNGR_ENABLE_AUTH_VENDOR_EXT
depends on USERMNGR_SECURITY_HARDENING
bool "Exposes vendor datamodel extensions for AuthenticationPolicy"
default y
help
Enable this option to expose TR181 vendor extensions for AuthenticationPolicy.
config USERMNGR_VENDOR_PREFIX
depends on USERMNGR_ENABLE_AUTH_VENDOR_EXT
string "Package specific datamodel Vendor Prefix for TR181 extensions"
default ""
endif

View File

@@ -5,13 +5,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=usermngr
PKG_VERSION:=1.3.10
PKG_VERSION:=1.4.4
LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/bbf/usermngr.git
PKG_SOURCE_VERSION:=37db3e216e508b19228479f39b935caa61815d06
PKG_SOURCE_VERSION:=defe0165931a1cee032ff2bd9e9911a4f1874e18
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
endif
@@ -28,9 +28,14 @@ define Package/usermngr
SECTION:=utils
CATEGORY:=Utilities
SUBMENU:=TRx69
DEPENDS:= +shadow-utils +libopenssl +libuci +libubox +ubus
DEPENDS:=+shadow-utils +libopenssl +libuci +libubox +ubus
DEPENDS+=+libbbfdm-api +libbbfdm-ubus +bbfdmd
DEPENDS+=+@BUSYBOX_CONFIG_ADDUSER +@BUSYBOX_CONFIG_DELUSER +@BUSYBOX_CONFIG_ADDGROUP +@BUSYBOX_CONFIG_DELGROUP +shadow-usermod
DEPENDS+=+@BUSYBOX_CONFIG_CMP
DEPENDS+=+@USERMNGR_SECURITY_HARDENING:SHADOW_UTILS_USE_PAM
DEPENDS+=+@USERMNGR_SECURITY_HARDENING:BUSYBOX_CONFIG_PAM
DEPENDS+=+USERMNGR_SECURITY_HARDENING:linux-pam
DEPENDS+=+USERMNGR_SECURITY_HARDENING:passwdqc
TITLE:=Package to add Device.Users. datamodel support
endef
@@ -38,12 +43,32 @@ define Package/usermngr/description
Package to add Device.Users. datamodel support
endef
define Package/$(PKG_NAME)/config
source "$(SOURCE)/Config.in"
endef
ifeq ($(LOCAL_DEV),1)
define Build/Prepare
$(CP) -rf ~/git/usermngr/* $(PKG_BUILD_DIR)/
endef
endif
ifeq ($(CONFIG_USERMNGR_SECURITY_HARDENING),y)
MAKE_FLAGS += USERMNGR_SECURITY_HARDENING=y
endif
ifeq ($(CONFIG_USERMNGR_ENABLE_AUTH_VENDOR_EXT),y)
MAKE_FLAGS += USERMNGR_ENABLE_AUTH_VENDOR_EXT=y
endif
ifeq ($(CONFIG_USERMNGR_VENDOR_PREFIX),"")
VENDOR_PREFIX = $(CONFIG_BBF_VENDOR_PREFIX)
else
VENDOR_PREFIX = $(CONFIG_USERMNGR_VENDOR_PREFIX)
endif
TARGET_CFLAGS += -DBBF_VENDOR_PREFIX=\\\"$(VENDOR_PREFIX)\\\"
define Package/usermngr/install
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DIR) $(1)/etc/config
@@ -52,6 +77,13 @@ define Package/usermngr/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) ./files/etc/uci-defaults/91-sync-shells $(1)/etc/uci-defaults/
$(INSTALL_BIN) ./files/etc/uci-defaults/91-sync-roles $(1)/etc/uci-defaults/
ifeq ($(CONFIG_USERMNGR_SECURITY_HARDENING),y)
$(INSTALL_BIN) ./files/etc/uci-defaults/91-security-hardening $(1)/etc/uci-defaults/
$(INSTALL_BIN) ./files/etc/uci-defaults/91-set-ssh-pam $(1)/etc/uci-defaults/
else
$(INSTALL_BIN) ./files/etc/uci-defaults/91-disabled-security $(1)/etc/uci-defaults/
$(INSTALL_BIN) ./files/etc/uci-defaults/91-unset-ssh-pam $(1)/etc/uci-defaults/
endif
$(INSTALL_BIN) ./files/etc/init.d/users $(1)/etc/init.d/users
$(INSTALL_BIN) ./files/etc/config/users $(1)/etc/config/users
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/usermngr $(1)/usr/sbin/usermngr

View File

@@ -6,11 +6,189 @@ USE_PROCD=1
PROG=/usr/sbin/usermngr
# List of required .so files
REQUIRED_MODULES="
/usr/lib/security/pam_faildelay.so
/usr/lib/security/pam_faillock.so
/usr/lib/security/pam_unix.so
/usr/lib/security/pam_deny.so
/usr/lib/security/pam_permit.so
/usr/lib/security/pam_passwdqc.so
"
check_required_modules() {
for mod in $REQUIRED_MODULES; do
if [ ! -f "$mod" ]; then
logger -p err -t usermngr "ERROR: Cannot setup security policy, missing PAM module: $mod"
return 1
fi
done
return 0
}
write_line() {
local filepath="$1"
local line="$2"
echo "$line" >> "$filepath"
}
compare_and_replace() {
local src dst
src="$1"
dst="$2"
if [ ! -f "$dst" ] || ! cmp -s "$src" "$dst"; then
cp "$src" "$dst"
logger -t pam_policy_setup "Updated $dst"
fi
}
update_auth() {
# Write /etc/pam.d/common-auth
local tmp_file pam_file
tmp_file="/tmp/common-auth"
pam_file="/etc/pam.d/common-auth"
local auth_enabled="${1}"
local enabled="${2}"
local faildelay="$(uci -q get users.authentication_policy.fail_delay)"
local faillock_lockout_time="$(uci -q get users.authentication_policy.faillock_lockout_time)"
local faillock_attempts="$(uci -q get users.authentication_policy.faillock_attempts)"
[ -n "$faildelay" ] || faildelay=3
[ -n "$faillock_attempts" ] || faillock_attempts=6
[ -n "$faillock_lockout_time" ] || faillock_lockout_time=300
# Convert seconds to microseconds for pam_faildelay
local faildelay_usec=$((faildelay * 1000000))
rm -f "$tmp_file"
touch "$tmp_file"
if [ "${auth_enabled}" -eq 1 ] && [ "${enabled}" -eq 1 ]; then
write_line "$tmp_file" "auth optional pam_faildelay.so delay=$faildelay_usec"
write_line "$tmp_file" "auth required pam_faillock.so preauth deny=$faillock_attempts even_deny_root unlock_time=$faillock_lockout_time"
fi
write_line "$tmp_file" "auth sufficient pam_unix.so nullok_secure"
if [ "${auth_enabled}" -eq 1 ] && [ "${enabled}" -eq 1 ]; then
write_line "$tmp_file" "auth [default=die] pam_faillock.so authfail audit deny=$faillock_attempts even_deny_root unlock_time=$faillock_lockout_time"
write_line "$tmp_file" ""
fi
write_line "$tmp_file" "auth requisite pam_deny.so"
write_line "$tmp_file" "auth required pam_permit.so"
compare_and_replace "$tmp_file" "$pam_file"
}
build_pam_passwdqc_line() {
local base="password requisite pam_passwdqc.so"
local k v line
for line in $(uci show users.passwdqc 2>/dev/null); do
case "$line" in
users.passwdqc=*) continue ;;
users.passwdqc.enabled=*) continue ;;
esac
k="${line%%=*}"
k="${k#users.passwdqc.}"
v="${line#*=}"
v="${v%\'}"
v="${v#\'}"
base="$base $k=$v"
done
echo "$base"
}
# NOTE:
# for some reason setting min 8 makes passwdqc accept minimum 12 letter password with this configuration
# if we set it to 12 then we need atleast 16 characters and so on
# passphrase = 0 means no space separated words
# passphrase = N means the number of words required for a passphrase or 0 to disable the support for user-chosen passphrases.
# rest can be figured out from passwdqc man page
update_password() {
local tmp_file pam_file enabled line
tmp_file="/tmp/common-password"
pam_file="/etc/pam.d/common-password"
local auth_enabled="${1}"
rm -f "$tmp_file"
touch "$tmp_file"
# Check if section exists
if uci -q get users.passwdqc >/dev/null 2>&1; then
# if enabled is not present it is assumed to be 0
enabled=$(uci -q get users.passwdqc.enabled || echo "0")
if [ "${auth_enabled}" -eq 1 ] && [ "${enabled}" -eq 1 ]; then
line="$(build_pam_passwdqc_line)"
write_line "$tmp_file" "$line"
fi
fi
write_line "$tmp_file" "password [success=1 default=ignore] pam_unix.so obscure sha512"
write_line "$tmp_file" ""
write_line "$tmp_file" "password requisite pam_deny.so"
write_line "$tmp_file" "password required pam_permit.so"
compare_and_replace "$tmp_file" "$pam_file"
}
update_account() {
# Write /etc/pam.d/common-account
local tmp_file pam_file
tmp_file="/tmp/common-account"
pam_file="/etc/pam.d/common-account"
local auth_enabled="${1}"
local enabled="${2}"
rm -f "$tmp_file"
touch "$tmp_file"
if [ "${auth_enabled}" -eq 1 ] && [ "${enabled}" -eq 1 ]; then
write_line "$tmp_file" "account required pam_faillock.so"
fi
write_line "$tmp_file" "account [success=1 new_authtok_reqd=done default=ignore] pam_unix.so"
write_line "$tmp_file" ""
write_line "$tmp_file" "account requisite pam_deny.so"
write_line "$tmp_file" "account required pam_permit.so"
compare_and_replace "$tmp_file" "$pam_file"
}
handle_security_policy() {
local auth_enabled enabled
# Read UCI values
auth_enabled="$(uci -q get users.users.auth_policy_enable || echo 0)"
enabled="$(uci -q get users.authentication_policy.enabled || echo 0)"
# if any .so files are missing, then we cannot setup security
if ! check_required_modules; then
return
fi
update_auth "${auth_enabled}" "${enabled}"
update_account "${auth_enabled}" "${enabled}"
update_password "${auth_enabled}"
}
start_service() {
local loglevel
loglevel="$(uci -q get users.users.loglevel)"
handle_security_policy
procd_open_instance usermngr
procd_set_param command $PROG
@@ -28,6 +206,7 @@ reload_service() {
stop
start
else
handle_security_policy
ubus send usermngr.reload
fi

View File

@@ -0,0 +1,16 @@
#!/bin/sh
# Remove auth_policy_enable from global
if uci -q get users.users; then
uci -q set users.users.auth_policy_enable=''
else
uci -q set users.users='users'
fi
# Remove authentication_policy section
uci -q del users.authentication_policy
# Remove passwdqc section
uci -q del users.passwdqc
exit 0

View File

@@ -0,0 +1,30 @@
#!/bin/sh
# Create global section
if ! uci -q get users.users; then
uci -q set users.users='users'
fi
uci -q set users.users.auth_policy_enable='1'
# Create default authentication_policy section if missing
if ! uci -q get users.authentication_policy; then
uci -q set users.authentication_policy='authentication_policy'
uci -q set users.authentication_policy.enabled='1'
uci -q set users.authentication_policy.fail_delay='3'
uci -q set users.authentication_policy.faillock_attempts='6'
uci -q set users.authentication_policy.faillock_lockout_time='300'
fi
# Create default passwdqc section if missing
if ! uci -q get users.passwdqc; then
uci -q set users.passwdqc='passwdqc'
uci -q set users.passwdqc.enabled='1'
uci -q set users.passwdqc.min='disabled,disabled,disabled,8,8'
uci -q set users.passwdqc.max='20'
uci -q set users.passwdqc.passphrase='0'
uci -q set users.passwdqc.retry='3'
uci -q set users.passwdqc.enforce='everyone'
fi
exit 0

View File

@@ -0,0 +1,7 @@
#!/bin/sh
if [ -f /etc/config/sshd ]; then
uci -q set sshd.@sshd[0].UsePAM=1
fi
exit 0

View File

@@ -0,0 +1,8 @@
#!/bin/sh
if [ -f /etc/config/sshd ]; then
uci -q set sshd.@sshd[0].UsePAM=0
fi
exit 0

View File

@@ -5,13 +5,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=wifidmd
PKG_VERSION:=1.1.33.2
PKG_VERSION:=1.1.33.4
LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/bbf/wifidmd.git
PKG_SOURCE_VERSION:=900fdca6e18dce382c99fbfcbca81b7e90cc5598
PKG_SOURCE_VERSION:=9fe191bb4b8c442668ad98c9b2119274f513ea5d
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
endif

View File

@@ -4,7 +4,7 @@ menu "Configurations"
config WIFIMNGR_CACHE_SCANRESULTS
bool "Cache scan results"
default y
default n
endmenu
endif

View File

@@ -6,12 +6,12 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=wifimngr
PKG_VERSION:=17.7.6
PKG_VERSION:=17.7.8
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=e16058225dc5e9fb819029fff48cb3a5cc658a98
PKG_SOURCE_VERSION:=f0c953cfbfbde7fc0a2b37378de3417412418791
PKG_SOURCE_URL:=https://dev.iopsys.eu/hal/wifimngr.git
PKG_MAINTAINER:=Anjan Chanda <anjan.chanda@genexis.eu>
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz