Fix bug #8953 - winbind can hang as nbt_getdc() has no timeout.
[ddiss/samba.git] / source3 / libsmb / dsgetdcname.c
index 63621ed52fdac50bde9c1ea1567289b0bb531696..442f8edc56b0fd8aafa897be331480e6cb80f795 100644 (file)
@@ -629,7 +629,7 @@ static NTSTATUS discover_dc_dns(TALLOC_CTX *mem_ctx,
                 * back to netbios lookups is that our DNS server doesn't know
                 * anything about the DC's   -- jerry */
 
-               if (!is_zero_addr((struct sockaddr *)(void *)&r->ss)) {
+               if (!is_zero_addr(&r->ss)) {
                        count++;
                        continue;
                }
@@ -950,26 +950,13 @@ static NTSTATUS process_dc_netbios(TALLOC_CTX *mem_ctx,
                        return NT_STATUS_UNSUCCESSFUL;
                }
 
-               if (send_getdc_request(msg_ctx,
-                                      &dclist[i].ss, domain_name,
-                                      NULL, nt_version, dgm_id))
-               {
-                       int k;
-                       smb_msleep(300);
-                       for (k=0; k<5; k++) {
-                               if (receive_getdc_response(mem_ctx,
-                                                          &dclist[i].ss,
-                                                          domain_name,
-                                                          dgm_id,
-                                                          &nt_version,
-                                                          &dc_name,
-                                                          &r)) {
-                                       store_cache = true;
-                                       namecache_store(dc_name, NBT_NAME_SERVER, 1, &ip_list);
-                                       goto make_reply;
-                               }
-                               smb_msleep(1500);
-                       }
+               status = nbt_getdc(msg_ctx, 10, &dclist[i].ss, domain_name,
+                                  NULL, nt_version,
+                                  mem_ctx, &nt_version, &dc_name, &r);
+               if (NT_STATUS_IS_OK(status)) {
+                       store_cache = true;
+                       namecache_store(dc_name, NBT_NAME_SERVER, 1, &ip_list);
+                       goto make_reply;
                }
 
                if (name_status_find(domain_name,