diff options
author | Volker Lendecke <vlendec@samba.org> | 2006-08-28 09:19:30 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:38:57 -0500 |
commit | c52b3fb89f29110d2c2026a540e5dd39826bb799 (patch) | |
tree | c78a8876d311a2696627a4b910b58501c5e358e6 /source3/libsmb | |
parent | e09daab0157e1c9fc9ab29627f9ca612456eed8c (diff) | |
download | samba-c52b3fb89f29110d2c2026a540e5dd39826bb799.tar.gz samba-c52b3fb89f29110d2c2026a540e5dd39826bb799.tar.bz2 samba-c52b3fb89f29110d2c2026a540e5dd39826bb799.zip |
r17881: Another microstep towards better error reporting: Make get_sorted_dc_list
return NTSTATUS.
If we want to differentiate different name resolution problems we might want
to introduce yet another error class for Samba-internal errors. Things like no
route to host to the WINS server, a DNS server explicitly said host not found
etc might be worth passing up.
Because we can not stash everything into the existing NT_STATUS codes, what
about a Samba-specific error class like NT_STATUS_DOS and NT_STATUS_LDAP?
Volker
(This used to be commit 60a166f0347170dff38554bed46193ce1226c8c1)
Diffstat (limited to 'source3/libsmb')
-rw-r--r-- | source3/libsmb/namequery.c | 38 | ||||
-rw-r--r-- | source3/libsmb/namequery_dc.c | 3 |
2 files changed, 28 insertions, 13 deletions
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index 14dfd50829..62f21d94c7 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -1360,8 +1360,8 @@ BOOL get_pdc_ip(const char *domain, struct in_addr *ip) a domain. *********************************************************/ -static BOOL get_dc_list(const char *domain, struct ip_service **ip_list, - int *count, BOOL ads_only, int *ordered) +static NTSTATUS get_dc_list(const char *domain, struct ip_service **ip_list, + int *count, BOOL ads_only, int *ordered) { fstring resolve_order; char *saf_servername; @@ -1419,7 +1419,14 @@ static BOOL get_dc_list(const char *domain, struct ip_service **ip_list, if ( !*pserver ) { DEBUG(10,("get_dc_list: no preferred domain controllers.\n")); - return internal_resolve_name(domain, 0x1C, ip_list, count, resolve_order); + /* TODO: change return type of internal_resolve_name to + * NTSTATUS */ + if (internal_resolve_name(domain, 0x1C, ip_list, count, + resolve_order)) { + return NT_STATUS_OK; + } else { + return NT_STATUS_NO_LOGON_SERVERS; + } } DEBUG(3,("get_dc_list: preferred server list: \"%s\"\n", pserver )); @@ -1434,7 +1441,8 @@ static BOOL get_dc_list(const char *domain, struct ip_service **ip_list, p = pserver; while (next_token(&p,name,LIST_SEP,sizeof(name))) { if (strequal(name, "*")) { - if ( internal_resolve_name(domain, 0x1C, &auto_ip_list, &auto_count, resolve_order) ) + if (internal_resolve_name(domain, 0x1C, &auto_ip_list, + &auto_count, resolve_order)) num_addresses += auto_count; done_auto_lookup = True; DEBUG(8,("Adding %d DC's from auto lookup\n", auto_count)); @@ -1448,16 +1456,20 @@ static BOOL get_dc_list(const char *domain, struct ip_service **ip_list, if ( (num_addresses == 0) ) { if ( !done_auto_lookup ) { - return internal_resolve_name(domain, 0x1C, ip_list, count, resolve_order); + if (internal_resolve_name(domain, 0x1C, ip_list, count, resolve_order)) { + return NT_STATUS_OK; + } else { + return NT_STATUS_NO_LOGON_SERVERS; + } } else { DEBUG(4,("get_dc_list: no servers found\n")); - return False; + return NT_STATUS_NO_LOGON_SERVERS; } } if ( (return_iplist = SMB_MALLOC_ARRAY(struct ip_service, num_addresses)) == NULL ) { DEBUG(3,("get_dc_list: malloc fail !\n")); - return False; + return NT_STATUS_NO_MEMORY; } p = pserver; @@ -1535,22 +1547,24 @@ static BOOL get_dc_list(const char *domain, struct ip_service **ip_list, *ip_list = return_iplist; *count = local_count; - return (*count != 0); + return ( *count != 0 ? NT_STATUS_OK : NT_STATUS_NO_LOGON_SERVERS ); } /********************************************************************* Small wrapper function to get the DC list and sort it if neccessary. *********************************************************************/ -BOOL get_sorted_dc_list( const char *domain, struct ip_service **ip_list, int *count, BOOL ads_only ) +NTSTATUS get_sorted_dc_list( const char *domain, struct ip_service **ip_list, int *count, BOOL ads_only ) { BOOL ordered; + NTSTATUS status; DEBUG(8,("get_sorted_dc_list: attempting lookup using [%s]\n", (ads_only ? "ads" : lp_name_resolve_order()))); - if ( !get_dc_list(domain, ip_list, count, ads_only, &ordered) ) { - return False; + status = get_dc_list(domain, ip_list, count, ads_only, &ordered); + if (!NT_STATUS_IS_OK(status)) { + return status; } /* only sort if we don't already have an ordered list */ @@ -1558,5 +1572,5 @@ BOOL get_sorted_dc_list( const char *domain, struct ip_service **ip_list, int *c sort_ip_list2( *ip_list, *count ); } - return True; + return NT_STATUS_OK; } diff --git a/source3/libsmb/namequery_dc.c b/source3/libsmb/namequery_dc.c index b9a593bf2a..4afd04a98f 100644 --- a/source3/libsmb/namequery_dc.c +++ b/source3/libsmb/namequery_dc.c @@ -81,7 +81,8 @@ static BOOL rpc_dc_name(const char *domain, fstring srv_name, struct in_addr *ip /* get a list of all domain controllers */ - if ( !get_sorted_dc_list(domain, &ip_list, &count, False) ) { + if (!NT_STATUS_IS_OK(get_sorted_dc_list(domain, &ip_list, &count, + False))) { DEBUG(3, ("Could not look up dc's for domain %s\n", domain)); return False; } |