Isn't the existing logic broken? (perhaps insufficient comments/documentation in this method for me to conclude either way ... the intention maybe is unclear)
```
if [ $? -eq 0 ] ; then
if echo "$OUT" | egrep -vq 'has no|not found'; then
return 0
fi
else
# Checking the dns servers failed. Assuming no .local unicast dns, but
# remove the nameserver cache so we recheck the next time we're triggered
rm -f ${NS_CACHE}
fi
```
later it's used only here
```
if dns_has_local ; then
# .local from dns server, disabling avahi
disable_avahi
else
# no .local from dns server, enabling avahi
enable_avahi
fi
```
When host call fails (even with timeout), it returns "1" claiming "dns_has_local()=true".
{{{
fermulator@fermmy:~$ OUT="Host local. not found: 3(NXDOMAIN)"
fermulator@fermmy:~$ if echo "$OUT" | egrep -vq 'has no|not found'; then echo "RETURN 0"; else echo "RETURN 1"; fi
RETURN 1
}}}
At least the additional wrapping of timeout (workaround) doesn't make it any worse I suppose ...
We should also consider:
``` fermmy: ~$ host -t soa local. fermmy: ~$ echo $?
# CLEAN
fermulator@
Host local. not found: 3(NXDOMAIN)
fermulator@
1
# BROKEN (host hangs) fermmy: ~$ LC_ALL=C /usr/bin/timeout 1 host -t soa local. 2>&1 fermmy: ~$ echo $?
fermulator@
fermulator@
124
# timeout fermmy: ~$ timeout 1 sleep 2 fermmy: ~$ echo $?
fermulator@
fermulator@
124
# no timeout fermmy: ~$ timeout 5 sleep 1 fermmy: ~$ echo $?
fermulator@
fermulator@
0
```
Isn't the existing logic broken? (perhaps insufficient comments/ documentation in this method for me to conclude either way ... the intention maybe is unclear)
```
if [ $? -eq 0 ] ; then
if echo "$OUT" | egrep -vq 'has no|not found'; then
return 0
fi
else
# Checking the dns servers failed. Assuming no .local unicast dns, but
# remove the nameserver cache so we recheck the next time we're triggered
rm -f ${NS_CACHE}
fi
```
later it's used only here
```
if dns_has_local ; then
# .local from dns server, disabling avahi
disable_avahi
else
# no .local from dns server, enabling avahi
enable_avahi
fi
```
When host call fails (even with timeout), it returns "1" claiming "dns_has_ local() =true". fermmy: ~$ OUT="Host local. not found: 3(NXDOMAIN)" fermmy: ~$ if echo "$OUT" | egrep -vq 'has no|not found'; then echo "RETURN 0"; else echo "RETURN 1"; fi
{{{
fermulator@
fermulator@
RETURN 1
}}}
At least the additional wrapping of timeout (workaround) doesn't make it any worse I suppose ...