Skip to content

Commit e810f0a

Browse files
committed
pbr: update to 1.1.8-34
* bugfix: json init was destroying procd_triggers and screwing boot up fixes #27194 * improvement: explicit printf calls in get_text Signed-off-by: Stan Grishin <[email protected]>
1 parent 1e391d0 commit e810f0a

File tree

2 files changed

+80
-76
lines changed

2 files changed

+80
-76
lines changed

net/pbr/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk
55

66
PKG_NAME:=pbr
77
PKG_VERSION:=1.1.8
8-
PKG_RELEASE:=32
8+
PKG_RELEASE:=34
99
PKG_LICENSE:=AGPL-3.0-or-later
1010
PKG_MAINTAINER:=Stan Grishin <[email protected]>
1111

net/pbr/files/etc/init.d/pbr

Lines changed: 79 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ output_okbn() { output 1 "$_OKB_\n"; output 2 "$__OKB__\n"; }
168168
output_fail() { output 1 "$_FAIL_"; output 2 "$__FAIL__\n"; }
169169
output_failn() { output 1 "$_FAIL_\n"; output 2 "$__FAIL__\n"; }
170170
output_error() { output "${_ERROR_} $*!\n"; }
171-
output_warning() { output "${_WARNING_} $*!\n"; }
171+
output_warning() { output "${_WARNING_} $*.\n"; }
172172
quiet_mode() {
173173
case "$1" in
174174
on) verbosity=0;;
@@ -358,65 +358,63 @@ try() {
358358
}
359359

360360
get_text() {
361-
local r
362-
case "$1" in
363-
errorConfigValidation) r="Config ($packageConfigFile) validation failure!";;
364-
errorNoNft) r="Resolver set support (${resolver_set}) requires nftables, but nft binary cannot be found!";;
365-
errorResolverNotSupported) r="Resolver set (${resolver_set}) is not supported on this system!";;
366-
errorServiceDisabled) r="The ${packageName} service is currently disabled";;
367-
errorNoWanGateway) r="The ${serviceName} service failed to discover WAN gateway!";;
368-
errorNoWanInterface) r="The %s interface not found, you need to set the 'pbr.config.procd_wan_interface' option!";;
369-
errorNoWanInterfaceHint) r="Refer to https://docs.openwrt.melmac.ca/pbr/#procd_wan_interface.";;
370-
errorNftsetNameTooLong) r="The nft set name '%s' is longer than allowed 255 characters!";;
371-
errorUnexpectedExit) r="Unexpected exit or service termination: '%s'!";;
372-
errorPolicyNoSrcDest) r="Policy '%s' has no source/destination parameters!";;
373-
errorPolicyNoInterface) r="Policy '%s' has no assigned interface!";;
374-
errorPolicyNoDns) r="Policy '%s' has no assigned DNS!";;
375-
errorPolicyProcessNoInterfaceDns) r="Interface '%s' has no assigned DNS!";;
376-
errorPolicyUnknownInterface) r="Policy '%s' has an unknown interface!";;
377-
errorPolicyProcessCMD) r="'%s'!";;
378-
errorFailedSetup) r="Failed to set up '%s'!";;
379-
errorFailedReload) r="Failed to reload '%s'!";;
380-
errorUserFileNotFound) r="Custom user file '%s' not found or empty!";;
381-
errorUserFileSyntax) r="Syntax error in custom user file '%s'!";;
382-
errorUserFileRunning) r="Error running custom user file '%s'!";;
383-
errorUserFileNoCurl) r="Use of 'curl' is detected in custom user file '%s', but 'curl' isn't installed!";;
384-
errorNoGateways) r="Failed to set up any gateway!";;
385-
errorResolver) r="Resolver '%s'!";;
386-
errorPolicyProcessNoIpv6) r="Skipping IPv6 policy '%s' as IPv6 support is disabled!";;
387-
errorPolicyProcessUnknownFwmark) r="Unknown packet mark for interface '%s'!";;
388-
errorPolicyProcessMismatchFamily) r="Mismatched IP family between in policy '%s'!";;
389-
errorPolicyProcessUnknownProtocol) r="Unknown protocol in policy '%s'!";;
390-
errorPolicyProcessInsertionFailed) r="Insertion failed for both IPv4 and IPv6 for policy '%s'!";;
391-
errorPolicyProcessInsertionFailedIpv4) r="Insertion failed for IPv4 for policy '%s'!";;
392-
errorPolicyProcessUnknownEntry) r="Unknown entry in policy '%s'!";;
393-
errorInterfaceRoutingEmptyValues) r="Received empty tid/mark or interface name when setting up routing!";;
394-
errorFailedToResolve) r="Failed to resolve '%s'!";;
395-
errorTryFailed) r="Command failed: %s";;
396-
errorNftFileInstall) r="Failed to install fw4 nft file '%s'!";;
397-
errorDownloadUrlNoHttps) r="Failed to download '%s', HTTPS is not supported!";;
398-
errorDownloadUrl) r="Failed to download '%s'!";;
399-
errorNoDownloadWithSecureReload) r="Policy '%s' refers to URL which can't be downloaded in 'secure_reload' mode!";;
400-
errorFileSchemaRequiresCurl) r="The file:// schema requires curl, but it's not detected on this system!";;
401-
errorIncompatibleUserFile) r="Incompatible custom user file detected '%s'!";;
402-
errorDefaultFw4TableMissing) r="Default fw4 table '%s' is missing!";;
403-
errorDefaultFw4ChainMissing) r="Default fw4 chain '%s' is missing!";;
404-
errorRequiredBinaryMissing) r="Required binary '%s' is missing!";;
405-
errorInterfaceRoutingUnknownDevType) r="Unknown IPv6 Link type for device '%s'!";;
406-
errorUplinkDown) r="Uplink/WAN interface is still down, increase value of 'procd_boot_trigger_delay' option";;
407-
warningInvalidOVPNConfig) r="Invalid OpenVPN config for '%s' interface.";;
408-
warningResolverNotSupported) r="Resolver set (${resolver_set}) is not supported on this system.";;
409-
warningPolicyProcessCMD) r="'%s'";;
410-
warningTorUnsetParams) r="Please unset 'src_addr', 'src_port' and 'dest_port' for policy '%s'.";;
411-
warningTorUnsetProto) r="Please unset 'proto' or set 'proto' to 'all' for policy '%s'.";;
412-
warningTorUnsetChainNft) r="Please unset 'chain' or set 'chain' to 'prerouting' for policy '%s'.";;
413-
warningOutdatedWebUIApp) r="The WebUI application is outdated (version %s), please update it.";;
414-
warningBadNftCallsInUserFile) r="Incompatible nft calls detected in user include file, disabling fw4 nft file support.";;
415-
warningDnsmasqInstanceNoConfdir) r="Dnsmasq instance '%s' targeted in settings, but it doesn't have its own confdir.";;
416-
warningDhcpLanForce) r="Please set 'dhcp.%s.force=1' to speed up service start-up.";;
417-
*) r="Unknown error '%s'!";;
361+
local r="$1"; shift;
362+
case "$r" in
363+
errorConfigValidation) printf "Config (%s) validation failure" "$$packageConfigFile";;
364+
errorNoNft) printf "Resolver set support (%s) requires nftables, but nft binary cannot be found" "$resolver_set";;
365+
errorResolverNotSupported) printf "Resolver set (%s) is not supported on this system" "$resolver_set";;
366+
errorServiceDisabled) printf "The %s service is currently disabled" "$packageName";;
367+
errorNoWanGateway) printf "The %s service failed to discover WAN gateway" "$serviceName";;
368+
errorNoWanInterface) printf "The %s interface not found, you need to set the 'pbr.config.procd_wan_interface' option" "$@";;
369+
errorNoWanInterfaceHint) printf "Refer to %s" 'https://docs.openwrt.melmac.ca/pbr/#procd_wan_interface';;
370+
errorNftsetNameTooLong) printf "The nft set name '%s' is longer than allowed 255 characters" "$@";;
371+
errorUnexpectedExit) printf "Unexpected exit or service termination: '%s'" "$@";;
372+
errorPolicyNoSrcDest) printf "Policy '%s' has no source/destination parameters" "$@";;
373+
errorPolicyNoInterface) printf "Policy '%s' has no assigned interface" "$@";;
374+
errorPolicyNoDns) printf "Policy '%s' has no assigned DNS" "$@";;
375+
errorPolicyProcessNoInterfaceDns) printf "Interface '%s' has no assigned DNS" "$@";;
376+
errorPolicyUnknownInterface) printf "Policy '%s' has an unknown interface" "$@";;
377+
errorPolicyProcessCMD) printf "'%s'" "$@";;
378+
errorFailedSetup) printf "Failed to set up '%s'" "$@";;
379+
errorFailedReload) printf "Failed to reload '%s'" "$@";;
380+
errorUserFileNotFound) printf "Custom user file '%s' not found or empty" "$@";;
381+
errorUserFileSyntax) printf "Syntax error in custom user file '%s'" "$@";;
382+
errorUserFileRunning) printf "Error running custom user file '%s'" "$@";;
383+
errorUserFileNoCurl) printf "Use of 'curl' is detected in custom user file '%s', but 'curl' isn't installed" "$@";;
384+
errorNoGateways) printf "Failed to set up any gateway";;
385+
errorResolver) printf "Resolver '%s'" "$@";;
386+
errorPolicyProcessNoIpv6) printf "Skipping IPv6 policy '%s' as IPv6 support is disabled" "$@";;
387+
errorPolicyProcessUnknownFwmark) printf "Unknown packet mark for interface '%s'" "$@";;
388+
errorPolicyProcessMismatchFamily) printf "Mismatched IP family between in policy '%s'" "$@";;
389+
errorPolicyProcessUnknownProtocol) printf "Unknown protocol in policy '%s'" "$@";;
390+
errorPolicyProcessInsertionFailed) printf "Insertion failed for both IPv4 and IPv6 for policy '%s'" "$@";;
391+
errorPolicyProcessInsertionFailedIpv4) printf "Insertion failed for IPv4 for policy '%s'" "$@";;
392+
errorPolicyProcessUnknownEntry) printf "Unknown entry in policy '%s'" "$@";;
393+
errorInterfaceRoutingEmptyValues) printf "Received empty tid/mark or interface name when setting up routing";;
394+
errorFailedToResolve) printf "Failed to resolve '%s'" "$@";;
395+
errorTryFailed) printf "Command failed: %s" "$@";;
396+
errorNftFileInstall) printf "Failed to install fw4 nft file '%s'" "$@";;
397+
errorDownloadUrlNoHttps) printf "Failed to download '%s', HTTPS is not supported" "$@";;
398+
errorDownloadUrl) printf "Failed to download '%s'" "$@";;
399+
errorNoDownloadWithSecureReload) printf "Policy '%s' refers to URL which can't be downloaded in 'secure_reload' mode" "$@";;
400+
errorFileSchemaRequiresCurl) printf "The file:// schema requires curl, but it's not detected on this system";;
401+
errorIncompatibleUserFile) printf "Incompatible custom user file detected '%s'" "$@";;
402+
errorDefaultFw4TableMissing) printf "Default fw4 table '%s' is missing" "$@";;
403+
errorDefaultFw4ChainMissing) printf "Default fw4 chain '%s' is missing" "$@";;
404+
errorRequiredBinaryMissing) printf "Required binary '%s' is missing" "$@";;
405+
errorInterfaceRoutingUnknownDevType) printf "Unknown IPv6 Link type for device '%s'" "$@";;
406+
errorUplinkDown) printf "Uplink/WAN interface is still down, increase value of 'procd_boot_trigger_delay' option";;
407+
warningInvalidOVPNConfig) printf "Invalid OpenVPN config for '%s' interface" "$@";;
408+
warningResolverNotSupported) printf "Resolver set (%s) is not supported on this system" "$resolver_set";;
409+
warningPolicyProcessCMD) printf "'%s'" "$@";;
410+
warningTorUnsetParams) printf "Please unset 'src_addr', 'src_port' and 'dest_port' for policy '%s'" "$@";;
411+
warningTorUnsetProto) printf "Please unset 'proto' or set 'proto' to 'all' for policy '%s'" "$@";;
412+
warningTorUnsetChainNft) printf "Please unset 'chain' or set 'chain' to 'prerouting' for policy '%s'" "$@";;
413+
warningOutdatedWebUIApp) printf "The WebUI application is outdated (version %s), please update it" "$@";;
414+
warningDnsmasqInstanceNoConfdir) printf "Dnsmasq instance '%s' targeted in settings, but it doesn't have its own confdir" "$@";;
415+
warningDhcpLanForce) printf "Please set 'dhcp.%s.force=1' to speed up service start-up" "$@";;
416+
*) printf "Unknown error/warning '%s'" "$@";;
418417
esac
419-
echo "$r"
420418
}
421419

422420
process_url() {
@@ -572,9 +570,9 @@ load_environment() {
572570
}
573571
local param="$1" validation_result="$2"
574572
[ -z "$load_environment_flag" ] || return 0
575-
json init
576573
case "$param" in
577574
on_boot|on_start)
575+
json init
578576
output 1 "Loading environment ($param) "
579577
load_package_config "$param"
580578
if [ "$enabled" -eq '0' ]; then
@@ -598,6 +596,7 @@ load_environment() {
598596
output 1 "$_OK_\n"
599597
;;
600598
on_stop)
599+
json init
601600
output 1 "Loading environment ($param) "
602601
load_package_config "$param"
603602
load_network "$param"
@@ -870,20 +869,19 @@ json() {
870869
{ json_load_file "$runningStatusFile" || json_init; } >/dev/null 2>&1
871870
case "$action" in
872871
'get')
873-
if json_select "$param" >/dev/null 2>&1; then
874-
if [ -n "$value" ]; then
875-
{
876-
if json_select "$value"; then
877-
json_get_var 'i' "${info:-code}"
878-
json_select ..
879-
fi
880-
} >/dev/null 2>&1
881-
else
882-
json_get_keys i
872+
json_select "$param" >/dev/null 2>&1 || return
873+
if [ -n "$value" ]; then
874+
{
875+
if json_select "$value"; then
876+
json_get_var 'i' "${info:-code}"
877+
json_select ..
883878
fi
884-
printf "%b" "$i"
885-
json_select ..
879+
} >/dev/null 2>&1
880+
else
881+
json_get_keys i
886882
fi
883+
printf "%b" "$i"
884+
json_select ..
887885
return
888886
;;
889887
'add')
@@ -2020,9 +2018,13 @@ on_interface_reload() {
20202018
start_service() {
20212019
local resolverStoredHash resolverNewHash i param="$1" reloadedIface k
20222020

2023-
[ -n "$pbr_boot_flag" ] && return 0
2024-
[ "$param" = 'on_boot' ] && return 0
2021+
# [ -n "$pbr_boot_flag" ] && return 0
2022+
# [ "$param" = 'on_boot' ] && return 0
20252023
load_environment "${param:-on_start}" "$(load_validate_config)" || return 1
2024+
if [ -n "$pbr_boot_flag" ] || [ "$param" = 'on_boot' ]; then
2025+
[ -n "$wanGW" ] || return 0
2026+
unset pbr_boot_flag
2027+
fi
20262028

20272029
output "Processing environment (${param:-on_start}) "
20282030
is_wan_up "$param" || { output_error "$(get_text 'errorUplinkDown')"; return 1; }
@@ -2226,7 +2228,9 @@ service_triggers() {
22262228
procd_close_validate
22272229
if [ -n "$pbr_boot_flag" ] && is_integer "$procd_boot_trigger_delay"; then
22282230
output "Setting trigger (on_boot) "
2229-
procd_add_raw_trigger "interface.*.up" "$procd_boot_trigger_delay" "/etc/init.d/${packageName}" start && output_okn || output_failn
2231+
procd_open_trigger
2232+
procd_add_raw_trigger "interface.*.up" "$procd_boot_trigger_delay" "/etc/init.d/${packageName}" start && output_okn || output_failn
2233+
procd_close_trigger
22302234
else
22312235
procd_open_trigger
22322236
procd_add_config_trigger "config.change" 'openvpn' "/etc/init.d/${packageName}" reload 'on_openvpn_change'

0 commit comments

Comments
 (0)