From 228add093774e7b92d721d02cde068b8fe50e9f2 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 24 Jul 2026 13:44:06 +0000 Subject: [PATCH] Fix group-ring script's INI parser silently returning empty on every lookup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _ini_get() in _pstn_write_personal_group_ring_script split on '=' and compared $1 == key without trimming whitespace, but configparser.write() (used to write pstn-groups.conf and pstn-permissions.conf) pads '=' with spaces by default. Every lookup — including the group's own members= line — silently returned empty, so group-owned personal DID ring-groups never actually rang anyone regardless of member tier/whitelist config. Trim whitespace around both the extracted key and value before comparing. Also switch the script's final echo to printf to remove any ambiguity in the dialplan's SHELL()-empty-string check. --- services/pstn-trunk.sh | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/services/pstn-trunk.sh b/services/pstn-trunk.sh index 3ef64e0..1bc114b 100644 --- a/services/pstn-trunk.sh +++ b/services/pstn-trunk.sh @@ -533,10 +533,26 @@ CONF_DIR="/etc/asterisk" _ini_get() { # _ini_get
+ # configparser.write() (used by every .conf writer in this project) pads + # '=' with spaces by default, so keys/values must be trimmed before + # comparing — a bare $1 == key here never matches and silently returns + # empty for every lookup, including the group's own members= line. awk -F'=' -v want="[$2]" -v key="$3" ' $0 == want { found=1; next } /^\[/ { found=0 } - found && $1 == key { sub(/^[^=]*=/, ""); print; exit } + found { + eq = index($0, "=") + if (eq > 0) { + k = substr($0, 1, eq-1) + gsub(/^[ \t]+|[ \t]+$/, "", k) + if (k == key) { + v = substr($0, eq+1) + gsub(/^[ \t]+|[ \t]+$/, "", v) + print v + exit + } + } + } ' "$1" 2>/dev/null } @@ -558,7 +574,7 @@ for _ext in "${MEMBERS[@]}"; do fi fi done -echo "$RING_LIST" +printf '%s' "$RING_LIST" SCRIPT }