dig may return non-zero exit code on successful AXFR
Summary
If dig needs to retry an AXFR (e.g. fall back to alternate IP protocol) then it will return a non-zero exit code even if the transfer eventually succeeds. This is not the case for other queries. For example, an SOA query under the same conditions exits with success (zero).
Steps to reproduce
In my example v6 is broken on the host, but v4 still works. It's interesting to note that in addition to having different exit codes, the AXFR and SOA queries have different error reporting.
% ./dig @ns1.conundrum.com conundrum.com IN AXFR +noall +comment +stats
;; Connection to 2001:4900:1:213::2:10#53(2001:4900:1:213::2:10) for conundrum.com failed: permission denied.
; <<>> DiG 9.12.2-P1 <<>> @ns1.conundrum.com conundrum.com IN AXFR +noall +comment +stats
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4302
;; flags: qr aa; QUERY: 1, ANSWER: 104, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
; COOKIE: 489a259d9e607c3ee945cbdb5b7c2c8818762db301a0787a (good)
;; Query time: 66 msec
;; SERVER: 67.215.196.35#53(67.215.196.35)
;; WHEN: Tue Aug 21 15:15:20 UTC 2018
;; XFR size: 104 records (messages 1, bytes 2725)
% echo $?
9
% ./dig +norec @ns1.conundrum.com conundrum.com IN SOA +noall +comment +stats
; <<>> DiG 9.12.2-P1 <<>> +norec @ns1.conundrum.com conundrum.com IN SOA +noall +comment +stats
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7644
;; flags: qr aa; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 5
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
; COOKIE: 52efc18b6eea76a9b5680dc65b7c2cd1d5d078c2e9fb1327 (good)
;; Query time: 62 msec
;; SERVER: 67.215.196.35#53(67.215.196.35)
;; WHEN: Tue Aug 21 15:16:33 UTC 2018
;; MSG SIZE rcvd: 241
% echo $?
0
What is the current bug behavior?
dig returns a non-success error code when the query was successful.
What is the expected correct behavior?
dig should return success (zero)
Edited by Matthew Pounsett