check-blacklist.sh: Fix potential false positive
[mgsautils.git] / host / check-blacklist.sh
index 76c6e708543be9f32650d6b7f97c0529b1041e46..a00e0181593ab37faadabbb16e94adfb856b5403 100755 (executable)
@@ -10,9 +10,10 @@ END
        exit 255
 fi
 
-ip=$(dig a "$1" +short)
-if [ -n "$ip" ]
+if ip=$(dig a "$1" +short) && [ -n "$ip" ]
 then
-       bl=$(dig a "$(printf "%s." "$ip" | tac -s.)$2" +short)
-       [ -n "$bl" ] && { echo "$ip is blacklisted."; exit 1; } || echo "$ip is not blacklisted."
+       bl=$(dig a "$(printf "%s." "$ip" | tac -s.)$2" +short) \
+               && [ -n "$bl" ] && { echo "$ip is blacklisted ($bl)."; exit 1; } || echo "$ip is not blacklisted."
+else
+       echo "Could not resolve $1!"
 fi