]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
winbindd: add retry to _wbint_DsGetDcName
authorRalph Boehme <slow@samba.org>
Mon, 12 Mar 2018 18:53:26 +0000 (19:53 +0100)
committerRalph Boehme <slow@samba.org>
Thu, 15 Mar 2018 14:46:10 +0000 (15:46 +0100)
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13332

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/winbindd/winbindd_dual_srv.c

index 4df2c5388c90fcda20a3fcde3f171a51e0324e31..1acba3a29e38dd9c7e74f8317fe32becc8048510 100644 (file)
@@ -547,6 +547,8 @@ NTSTATUS _wbint_DsGetDcName(struct pipes_struct *p, struct wbint_DsGetDcName *r)
        WERROR werr;
        unsigned int orig_timeout;
        struct dcerpc_binding_handle *b;
+       bool retry = false;
+       bool try_dsrgetdcname = false;
 
        if (domain == NULL) {
                return dsgetdcname(p->mem_ctx, server_messaging_context(),
@@ -556,6 +558,11 @@ NTSTATUS _wbint_DsGetDcName(struct pipes_struct *p, struct wbint_DsGetDcName *r)
                                   r->out.dc_info);
        }
 
+       if (domain->active_directory) {
+               try_dsrgetdcname = true;
+       }
+
+reconnect:
        status = cm_connect_netlogon(domain, &netlogon_pipe);
 
        reset_cm_connection_on_error(domain, NULL, status);
@@ -571,7 +578,7 @@ NTSTATUS _wbint_DsGetDcName(struct pipes_struct *p, struct wbint_DsGetDcName *r)
 
        orig_timeout = rpccli_set_timeout(netlogon_pipe, 35000);
 
-       if (domain->active_directory) {
+       if (try_dsrgetdcname) {
                status = dcerpc_netr_DsRGetDCName(b,
                        p->mem_ctx, domain->dcname,
                        r->in.domain_name, NULL, r->in.domain_guid,
@@ -579,23 +586,14 @@ NTSTATUS _wbint_DsGetDcName(struct pipes_struct *p, struct wbint_DsGetDcName *r)
                if (NT_STATUS_IS_OK(status) && W_ERROR_IS_OK(werr)) {
                        goto done;
                }
-               if (reset_cm_connection_on_error(domain, NULL, status)) {
-                       /* Re-initialize. */
-                       status = cm_connect_netlogon(domain, &netlogon_pipe);
-
-                       reset_cm_connection_on_error(domain, NULL, status);
-                       if (!NT_STATUS_IS_OK(status)) {
-                               DEBUG(10, ("Can't contact the NETLOGON pipe\n"));
-                               return status;
-                       }
-
-                       b = netlogon_pipe->binding_handle;
-
-                       /* This call can take a long time - allow the server to time out.
-                          35 seconds should do it. */
-
-                       orig_timeout = rpccli_set_timeout(netlogon_pipe, 35000);
+               if (!retry &&
+                   reset_cm_connection_on_error(domain, NULL, status))
+               {
+                       retry = true;
+                       goto reconnect;
                }
+               try_dsrgetdcname = false;
+               retry = false;
        }
 
        /*
@@ -618,7 +616,10 @@ NTSTATUS _wbint_DsGetDcName(struct pipes_struct *p, struct wbint_DsGetDcName *r)
                        r->in.domain_name, &dc_info->dc_unc, &werr);
        }
 
-       reset_cm_connection_on_error(domain, NULL, status);
+       if (!retry && reset_cm_connection_on_error(domain, b, status)) {
+               retry = true;
+               goto reconnect;
+       }
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(10, ("dcerpc_netr_Get[Any]DCName failed: %s\n",
                           nt_errstr(status)));