Fix group-ring script's INI parser silently returning empty on every lookup
_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.
This commit is contained in:
+18
-2
@@ -533,10 +533,26 @@ CONF_DIR="/etc/asterisk"
|
|||||||
|
|
||||||
_ini_get() {
|
_ini_get() {
|
||||||
# _ini_get <file> <section> <key>
|
# _ini_get <file> <section> <key>
|
||||||
|
# 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" '
|
awk -F'=' -v want="[$2]" -v key="$3" '
|
||||||
$0 == want { found=1; next }
|
$0 == want { found=1; next }
|
||||||
/^\[/ { found=0 }
|
/^\[/ { 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
|
' "$1" 2>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -558,7 +574,7 @@ for _ext in "${MEMBERS[@]}"; do
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo "$RING_LIST"
|
printf '%s' "$RING_LIST"
|
||||||
SCRIPT
|
SCRIPT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user