pbr: update to 1.1.8-34

* bugfix: json init was destroying procd_triggers and screwing boot up
  fixes https://github.com/openwrt/packages/issues/27194
* improvement: explicit printf calls in get_text

Signed-off-by: Stan Grishin <stangri@melmac.ca>
This commit is contained in:
Stan Grishin
2025-08-10 01:41:34 +00:00
parent 1e391d0520
commit e810f0afae
2 changed files with 80 additions and 76 deletions

View File

@@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=pbr PKG_NAME:=pbr
PKG_VERSION:=1.1.8 PKG_VERSION:=1.1.8
PKG_RELEASE:=32 PKG_RELEASE:=34
PKG_LICENSE:=AGPL-3.0-or-later PKG_LICENSE:=AGPL-3.0-or-later
PKG_MAINTAINER:=Stan Grishin <stangri@melmac.ca> PKG_MAINTAINER:=Stan Grishin <stangri@melmac.ca>

View File

@@ -168,7 +168,7 @@ output_okbn() { output 1 "$_OKB_\n"; output 2 "$__OKB__\n"; }
output_fail() { output 1 "$_FAIL_"; output 2 "$__FAIL__\n"; } output_fail() { output 1 "$_FAIL_"; output 2 "$__FAIL__\n"; }
output_failn() { output 1 "$_FAIL_\n"; output 2 "$__FAIL__\n"; } output_failn() { output 1 "$_FAIL_\n"; output 2 "$__FAIL__\n"; }
output_error() { output "${_ERROR_} $*!\n"; } output_error() { output "${_ERROR_} $*!\n"; }
output_warning() { output "${_WARNING_} $*!\n"; } output_warning() { output "${_WARNING_} $*.\n"; }
quiet_mode() { quiet_mode() {
case "$1" in case "$1" in
on) verbosity=0;; on) verbosity=0;;
@@ -358,65 +358,63 @@ try() {
} }
get_text() { get_text() {
local r local r="$1"; shift;
case "$1" in case "$r" in
errorConfigValidation) r="Config ($packageConfigFile) validation failure!";; errorConfigValidation) printf "Config (%s) validation failure" "$$packageConfigFile";;
errorNoNft) r="Resolver set support (${resolver_set}) requires nftables, but nft binary cannot be found!";; errorNoNft) printf "Resolver set support (%s) requires nftables, but nft binary cannot be found" "$resolver_set";;
errorResolverNotSupported) r="Resolver set (${resolver_set}) is not supported on this system!";; errorResolverNotSupported) printf "Resolver set (%s) is not supported on this system" "$resolver_set";;
errorServiceDisabled) r="The ${packageName} service is currently disabled";; errorServiceDisabled) printf "The %s service is currently disabled" "$packageName";;
errorNoWanGateway) r="The ${serviceName} service failed to discover WAN gateway!";; errorNoWanGateway) printf "The %s service failed to discover WAN gateway" "$serviceName";;
errorNoWanInterface) r="The %s interface not found, you need to set the 'pbr.config.procd_wan_interface' option!";; errorNoWanInterface) printf "The %s interface not found, you need to set the 'pbr.config.procd_wan_interface' option" "$@";;
errorNoWanInterfaceHint) r="Refer to https://docs.openwrt.melmac.ca/pbr/#procd_wan_interface.";; errorNoWanInterfaceHint) printf "Refer to %s" 'https://docs.openwrt.melmac.ca/pbr/#procd_wan_interface';;
errorNftsetNameTooLong) r="The nft set name '%s' is longer than allowed 255 characters!";; errorNftsetNameTooLong) printf "The nft set name '%s' is longer than allowed 255 characters" "$@";;
errorUnexpectedExit) r="Unexpected exit or service termination: '%s'!";; errorUnexpectedExit) printf "Unexpected exit or service termination: '%s'" "$@";;
errorPolicyNoSrcDest) r="Policy '%s' has no source/destination parameters!";; errorPolicyNoSrcDest) printf "Policy '%s' has no source/destination parameters" "$@";;
errorPolicyNoInterface) r="Policy '%s' has no assigned interface!";; errorPolicyNoInterface) printf "Policy '%s' has no assigned interface" "$@";;
errorPolicyNoDns) r="Policy '%s' has no assigned DNS!";; errorPolicyNoDns) printf "Policy '%s' has no assigned DNS" "$@";;
errorPolicyProcessNoInterfaceDns) r="Interface '%s' has no assigned DNS!";; errorPolicyProcessNoInterfaceDns) printf "Interface '%s' has no assigned DNS" "$@";;
errorPolicyUnknownInterface) r="Policy '%s' has an unknown interface!";; errorPolicyUnknownInterface) printf "Policy '%s' has an unknown interface" "$@";;
errorPolicyProcessCMD) r="'%s'!";; errorPolicyProcessCMD) printf "'%s'" "$@";;
errorFailedSetup) r="Failed to set up '%s'!";; errorFailedSetup) printf "Failed to set up '%s'" "$@";;
errorFailedReload) r="Failed to reload '%s'!";; errorFailedReload) printf "Failed to reload '%s'" "$@";;
errorUserFileNotFound) r="Custom user file '%s' not found or empty!";; errorUserFileNotFound) printf "Custom user file '%s' not found or empty" "$@";;
errorUserFileSyntax) r="Syntax error in custom user file '%s'!";; errorUserFileSyntax) printf "Syntax error in custom user file '%s'" "$@";;
errorUserFileRunning) r="Error running custom user file '%s'!";; errorUserFileRunning) printf "Error running custom user file '%s'" "$@";;
errorUserFileNoCurl) r="Use of 'curl' is detected in custom user file '%s', but 'curl' isn't installed!";; errorUserFileNoCurl) printf "Use of 'curl' is detected in custom user file '%s', but 'curl' isn't installed" "$@";;
errorNoGateways) r="Failed to set up any gateway!";; errorNoGateways) printf "Failed to set up any gateway";;
errorResolver) r="Resolver '%s'!";; errorResolver) printf "Resolver '%s'" "$@";;
errorPolicyProcessNoIpv6) r="Skipping IPv6 policy '%s' as IPv6 support is disabled!";; errorPolicyProcessNoIpv6) printf "Skipping IPv6 policy '%s' as IPv6 support is disabled" "$@";;
errorPolicyProcessUnknownFwmark) r="Unknown packet mark for interface '%s'!";; errorPolicyProcessUnknownFwmark) printf "Unknown packet mark for interface '%s'" "$@";;
errorPolicyProcessMismatchFamily) r="Mismatched IP family between in policy '%s'!";; errorPolicyProcessMismatchFamily) printf "Mismatched IP family between in policy '%s'" "$@";;
errorPolicyProcessUnknownProtocol) r="Unknown protocol in policy '%s'!";; errorPolicyProcessUnknownProtocol) printf "Unknown protocol in policy '%s'" "$@";;
errorPolicyProcessInsertionFailed) r="Insertion failed for both IPv4 and IPv6 for policy '%s'!";; errorPolicyProcessInsertionFailed) printf "Insertion failed for both IPv4 and IPv6 for policy '%s'" "$@";;
errorPolicyProcessInsertionFailedIpv4) r="Insertion failed for IPv4 for policy '%s'!";; errorPolicyProcessInsertionFailedIpv4) printf "Insertion failed for IPv4 for policy '%s'" "$@";;
errorPolicyProcessUnknownEntry) r="Unknown entry in policy '%s'!";; errorPolicyProcessUnknownEntry) printf "Unknown entry in policy '%s'" "$@";;
errorInterfaceRoutingEmptyValues) r="Received empty tid/mark or interface name when setting up routing!";; errorInterfaceRoutingEmptyValues) printf "Received empty tid/mark or interface name when setting up routing";;
errorFailedToResolve) r="Failed to resolve '%s'!";; errorFailedToResolve) printf "Failed to resolve '%s'" "$@";;
errorTryFailed) r="Command failed: %s";; errorTryFailed) printf "Command failed: %s" "$@";;
errorNftFileInstall) r="Failed to install fw4 nft file '%s'!";; errorNftFileInstall) printf "Failed to install fw4 nft file '%s'" "$@";;
errorDownloadUrlNoHttps) r="Failed to download '%s', HTTPS is not supported!";; errorDownloadUrlNoHttps) printf "Failed to download '%s', HTTPS is not supported" "$@";;
errorDownloadUrl) r="Failed to download '%s'!";; errorDownloadUrl) printf "Failed to download '%s'" "$@";;
errorNoDownloadWithSecureReload) r="Policy '%s' refers to URL which can't be downloaded in 'secure_reload' mode!";; errorNoDownloadWithSecureReload) printf "Policy '%s' refers to URL which can't be downloaded in 'secure_reload' mode" "$@";;
errorFileSchemaRequiresCurl) r="The file:// schema requires curl, but it's not detected on this system!";; errorFileSchemaRequiresCurl) printf "The file:// schema requires curl, but it's not detected on this system";;
errorIncompatibleUserFile) r="Incompatible custom user file detected '%s'!";; errorIncompatibleUserFile) printf "Incompatible custom user file detected '%s'" "$@";;
errorDefaultFw4TableMissing) r="Default fw4 table '%s' is missing!";; errorDefaultFw4TableMissing) printf "Default fw4 table '%s' is missing" "$@";;
errorDefaultFw4ChainMissing) r="Default fw4 chain '%s' is missing!";; errorDefaultFw4ChainMissing) printf "Default fw4 chain '%s' is missing" "$@";;
errorRequiredBinaryMissing) r="Required binary '%s' is missing!";; errorRequiredBinaryMissing) printf "Required binary '%s' is missing" "$@";;
errorInterfaceRoutingUnknownDevType) r="Unknown IPv6 Link type for device '%s'!";; errorInterfaceRoutingUnknownDevType) printf "Unknown IPv6 Link type for device '%s'" "$@";;
errorUplinkDown) r="Uplink/WAN interface is still down, increase value of 'procd_boot_trigger_delay' option";; errorUplinkDown) printf "Uplink/WAN interface is still down, increase value of 'procd_boot_trigger_delay' option";;
warningInvalidOVPNConfig) r="Invalid OpenVPN config for '%s' interface.";; warningInvalidOVPNConfig) printf "Invalid OpenVPN config for '%s' interface" "$@";;
warningResolverNotSupported) r="Resolver set (${resolver_set}) is not supported on this system.";; warningResolverNotSupported) printf "Resolver set (%s) is not supported on this system" "$resolver_set";;
warningPolicyProcessCMD) r="'%s'";; warningPolicyProcessCMD) printf "'%s'" "$@";;
warningTorUnsetParams) r="Please unset 'src_addr', 'src_port' and 'dest_port' for policy '%s'.";; warningTorUnsetParams) printf "Please unset 'src_addr', 'src_port' and 'dest_port' for policy '%s'" "$@";;
warningTorUnsetProto) r="Please unset 'proto' or set 'proto' to 'all' for policy '%s'.";; warningTorUnsetProto) printf "Please unset 'proto' or set 'proto' to 'all' for policy '%s'" "$@";;
warningTorUnsetChainNft) r="Please unset 'chain' or set 'chain' to 'prerouting' for policy '%s'.";; warningTorUnsetChainNft) printf "Please unset 'chain' or set 'chain' to 'prerouting' for policy '%s'" "$@";;
warningOutdatedWebUIApp) r="The WebUI application is outdated (version %s), please update it.";; warningOutdatedWebUIApp) printf "The WebUI application is outdated (version %s), please update it" "$@";;
warningBadNftCallsInUserFile) r="Incompatible nft calls detected in user include file, disabling fw4 nft file support.";; warningDnsmasqInstanceNoConfdir) printf "Dnsmasq instance '%s' targeted in settings, but it doesn't have its own confdir" "$@";;
warningDnsmasqInstanceNoConfdir) r="Dnsmasq instance '%s' targeted in settings, but it doesn't have its own confdir.";; warningDhcpLanForce) printf "Please set 'dhcp.%s.force=1' to speed up service start-up" "$@";;
warningDhcpLanForce) r="Please set 'dhcp.%s.force=1' to speed up service start-up.";; *) printf "Unknown error/warning '%s'" "$@";;
*) r="Unknown error '%s'!";;
esac esac
echo "$r"
} }
process_url() { process_url() {
@@ -572,9 +570,9 @@ load_environment() {
} }
local param="$1" validation_result="$2" local param="$1" validation_result="$2"
[ -z "$load_environment_flag" ] || return 0 [ -z "$load_environment_flag" ] || return 0
json init
case "$param" in case "$param" in
on_boot|on_start) on_boot|on_start)
json init
output 1 "Loading environment ($param) " output 1 "Loading environment ($param) "
load_package_config "$param" load_package_config "$param"
if [ "$enabled" -eq '0' ]; then if [ "$enabled" -eq '0' ]; then
@@ -598,6 +596,7 @@ load_environment() {
output 1 "$_OK_\n" output 1 "$_OK_\n"
;; ;;
on_stop) on_stop)
json init
output 1 "Loading environment ($param) " output 1 "Loading environment ($param) "
load_package_config "$param" load_package_config "$param"
load_network "$param" load_network "$param"
@@ -870,20 +869,19 @@ json() {
{ json_load_file "$runningStatusFile" || json_init; } >/dev/null 2>&1 { json_load_file "$runningStatusFile" || json_init; } >/dev/null 2>&1
case "$action" in case "$action" in
'get') 'get')
if json_select "$param" >/dev/null 2>&1; then json_select "$param" >/dev/null 2>&1 || return
if [ -n "$value" ]; then if [ -n "$value" ]; then
{ {
if json_select "$value"; then if json_select "$value"; then
json_get_var 'i' "${info:-code}" json_get_var 'i' "${info:-code}"
json_select .. json_select ..
fi
} >/dev/null 2>&1
else
json_get_keys i
fi fi
printf "%b" "$i" } >/dev/null 2>&1
json_select .. else
json_get_keys i
fi fi
printf "%b" "$i"
json_select ..
return return
;; ;;
'add') 'add')
@@ -2020,9 +2018,13 @@ on_interface_reload() {
start_service() { start_service() {
local resolverStoredHash resolverNewHash i param="$1" reloadedIface k local resolverStoredHash resolverNewHash i param="$1" reloadedIface k
[ -n "$pbr_boot_flag" ] && return 0 # [ -n "$pbr_boot_flag" ] && return 0
[ "$param" = 'on_boot' ] && return 0 # [ "$param" = 'on_boot' ] && return 0
load_environment "${param:-on_start}" "$(load_validate_config)" || return 1 load_environment "${param:-on_start}" "$(load_validate_config)" || return 1
if [ -n "$pbr_boot_flag" ] || [ "$param" = 'on_boot' ]; then
[ -n "$wanGW" ] || return 0
unset pbr_boot_flag
fi
output "Processing environment (${param:-on_start}) " output "Processing environment (${param:-on_start}) "
is_wan_up "$param" || { output_error "$(get_text 'errorUplinkDown')"; return 1; } is_wan_up "$param" || { output_error "$(get_text 'errorUplinkDown')"; return 1; }
@@ -2226,7 +2228,9 @@ service_triggers() {
procd_close_validate procd_close_validate
if [ -n "$pbr_boot_flag" ] && is_integer "$procd_boot_trigger_delay"; then if [ -n "$pbr_boot_flag" ] && is_integer "$procd_boot_trigger_delay"; then
output "Setting trigger (on_boot) " output "Setting trigger (on_boot) "
procd_add_raw_trigger "interface.*.up" "$procd_boot_trigger_delay" "/etc/init.d/${packageName}" start && output_okn || output_failn procd_open_trigger
procd_add_raw_trigger "interface.*.up" "$procd_boot_trigger_delay" "/etc/init.d/${packageName}" start && output_okn || output_failn
procd_close_trigger
else else
procd_open_trigger procd_open_trigger
procd_add_config_trigger "config.change" 'openvpn' "/etc/init.d/${packageName}" reload 'on_openvpn_change' procd_add_config_trigger "config.change" 'openvpn' "/etc/init.d/${packageName}" reload 'on_openvpn_change'