Improvements to forwarding hosts in Postfix

- No more premature EOF and no more leaking of bash processes
- Log result
- Correctly treat non-CIDR entries
- Adapt to schema change from df71e97
- Correctly report SQL failure
This commit is contained in:
Michael Kuron
2017-04-22 14:28:37 +02:00
parent df71e97a09
commit 894d6234e9
2 changed files with 10 additions and 6 deletions

View File

@@ -1,11 +1,12 @@
#!/bin/bash
while true; do
read QUERY
while read QUERY; do
QUERY=($QUERY)
if [ "${QUERY[0]}" != "get" ]; then
echo "500 dunno"
continue
fi
echo $(curl -s http://172.22.1.251:8081/forwardinghosts.php?host=${QUERY[1]})
result=$(curl -s http://172.22.1.251:8081/forwardinghosts.php?host=${QUERY[1]})
logger -t whitelist_forwardinghosts -p mail.info "Look up ${QUERY[1]} on whitelist, result $result"
echo $result
done