diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2019-01-09 13:38:57 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-01-09 13:38:57 +0100 |
commit | 6ca8e347fed8c24655df692f22694baf7c572770 (patch) | |
tree | 5ec15986d0e68b418f3475176af642e57b6b2c8b | |
parent | 841912311252c861d34f5356cb32acc95f008b0f (diff) | |
download | busybox-w32-6ca8e347fed8c24655df692f22694baf7c572770.tar.gz busybox-w32-6ca8e347fed8c24655df692f22694baf7c572770.tar.bz2 busybox-w32-6ca8e347fed8c24655df692f22694baf7c572770.zip |
nslookup: return exitcode 1 on resolution errors
function old new delta
nslookup_main 757 760 +3
send_queries 1690 1677 -13
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/nslookup.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/networking/nslookup.c b/networking/nslookup.c index cd3c00003..24e09d4f0 100644 --- a/networking/nslookup.c +++ b/networking/nslookup.c | |||
@@ -257,7 +257,7 @@ int nslookup_main(int argc, char **argv) | |||
257 | struct ns { | 257 | struct ns { |
258 | const char *name; | 258 | const char *name; |
259 | len_and_sockaddr *lsa; | 259 | len_and_sockaddr *lsa; |
260 | int failures; | 260 | //UNUSED: int failures; |
261 | int replies; | 261 | int replies; |
262 | }; | 262 | }; |
263 | 263 | ||
@@ -320,6 +320,7 @@ struct globals { | |||
320 | struct query *query; | 320 | struct query *query; |
321 | char *search; | 321 | char *search; |
322 | smalluint have_search_directive; | 322 | smalluint have_search_directive; |
323 | smalluint exitcode; | ||
323 | } FIX_ALIASING; | 324 | } FIX_ALIASING; |
324 | #define G (*(struct globals*)bb_common_bufsiz1) | 325 | #define G (*(struct globals*)bb_common_bufsiz1) |
325 | #define INIT_G() do { \ | 326 | #define INIT_G() do { \ |
@@ -593,7 +594,7 @@ static int send_queries(struct ns *ns) | |||
593 | 594 | ||
594 | /* Retry immediately on SERVFAIL */ | 595 | /* Retry immediately on SERVFAIL */ |
595 | if (rcode == 2) { | 596 | if (rcode == 2) { |
596 | ns->failures++; | 597 | //UNUSED: ns->failures++; |
597 | if (servfail_retry) { | 598 | if (servfail_retry) { |
598 | servfail_retry--; | 599 | servfail_retry--; |
599 | write(pfd.fd, G.query[qn].query, G.query[qn].qlen); | 600 | write(pfd.fd, G.query[qn].query, G.query[qn].qlen); |
@@ -612,9 +613,12 @@ static int send_queries(struct ns *ns) | |||
612 | if (rcode != 0) { | 613 | if (rcode != 0) { |
613 | printf("** server can't find %s: %s\n", | 614 | printf("** server can't find %s: %s\n", |
614 | G.query[qn].name, rcodes[rcode]); | 615 | G.query[qn].name, rcodes[rcode]); |
616 | G.exitcode = EXIT_FAILURE; | ||
615 | } else { | 617 | } else { |
616 | if (parse_reply(reply, recvlen) < 0) | 618 | if (parse_reply(reply, recvlen) < 0) { |
617 | printf("*** Can't find %s: Parse error\n", G.query[qn].name); | 619 | printf("*** Can't find %s: Parse error\n", G.query[qn].name); |
620 | G.exitcode = EXIT_FAILURE; | ||
621 | } | ||
618 | } | 622 | } |
619 | bb_putchar('\n'); | 623 | bb_putchar('\n'); |
620 | n_replies++; | 624 | n_replies++; |
@@ -988,7 +992,7 @@ int nslookup_main(int argc UNUSED_PARAM, char **argv) | |||
988 | free(G.query); | 992 | free(G.query); |
989 | } | 993 | } |
990 | 994 | ||
991 | return EXIT_SUCCESS; | 995 | return G.exitcode; |
992 | } | 996 | } |
993 | 997 | ||
994 | #endif | 998 | #endif |