diff options
| author | Andreas Schneider <asn@samba.org> | 2014-09-09 09:45:51 +0200 |
|---|---|---|
| committer | Andrew Bartlett <abartlet@samba.org> | 2014-12-18 06:47:40 +0100 |
| commit | cfb67cf623e541dd0b56241a30340419b9e5a393 (patch) | |
| tree | 7547eb5e5afab36a0ed0fbe425d361413979d6e9 /source3/utils | |
| parent | 5179a0b61fa4fcf1538f86c4a6e0e2a34703e232 (diff) | |
nmblookup: Return if the lookup was successful or not.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=10803
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Pair-Programmed-With: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/utils')
| -rw-r--r-- | source3/utils/nmblookup.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/source3/utils/nmblookup.c b/source3/utils/nmblookup.c index 9bbbc60eb7..78548e9d68 100644 --- a/source3/utils/nmblookup.c +++ b/source3/utils/nmblookup.c @@ -107,7 +107,7 @@ static char *query_flags(int flags) Do a node status query. ****************************************************************************/ -static void do_node_status(const char *name, +static bool do_node_status(const char *name, int type, struct sockaddr_storage *pss) { @@ -142,8 +142,10 @@ static void do_node_status(const char *name, extra.mac_addr[4], extra.mac_addr[5]); d_printf("\n"); TALLOC_FREE(addrs); + return true; } else { d_printf("No reply from %s\n\n",addr); + return false; } } @@ -201,7 +203,9 @@ static bool query_one(const char *lookup, unsigned int lookup_type) was valid - ie. name_query returned true. */ if (find_status) { - do_node_status(lookup, lookup_type, &ip_list[j]); + if (!do_node_status(lookup, lookup_type, &ip_list[j])) { + status = NT_STATUS_UNSUCCESSFUL; + } } } @@ -221,8 +225,9 @@ int main(int argc, const char *argv[]) fstring lookup; static bool find_master=False; static bool lookup_by_ip = False; - poptContext pc; + poptContext pc = NULL; TALLOC_CTX *frame = talloc_stackframe(); + int rc = 0; struct poptOption long_options[] = { POPT_AUTOHELP @@ -297,7 +302,8 @@ int main(int argc, const char *argv[]) if(!poptPeekArg(pc)) { poptPrintUsage(pc, stderr, 0); - exit(1); + rc = 1; + goto out; } if (!lp_load_global(get_dyn_CONFIGFILE())) { @@ -307,7 +313,8 @@ int main(int argc, const char *argv[]) load_interfaces(); if (!open_sockets()) { - return(1); + rc = 1; + goto out; } while(poptPeekArg(pc)) { @@ -321,7 +328,9 @@ int main(int argc, const char *argv[]) ip = interpret_addr2(lookup); in_addr_to_sockaddr_storage(&ss, ip); fstrcpy(lookup,"*"); - do_node_status(lookup, lookup_type, &ss); + if (!do_node_status(lookup, lookup_type, &ss)) { + rc = 1; + } continue; } @@ -341,6 +350,7 @@ int main(int argc, const char *argv[]) } if (!query_one(lookup, lookup_type)) { + rc = 1; d_printf( "name_query failed to find name %s", lookup ); if( 0 != lookup_type ) { d_printf( "#%02x", lookup_type ); @@ -349,7 +359,8 @@ int main(int argc, const char *argv[]) } } +out: poptFreeContext(pc); TALLOC_FREE(frame); - return(0); + return rc; } |
