Author: vlendec
Date: 2005-08-28 09:19:10 +0000 (Sun, 28 Aug 2005)
New Revision: 9709

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=9709

Log:
Fix two bugs found by Brian Moran: Any request sent to winbind while the child
in question is still initializing overwrites domain->dcname. Only overwrite if
the parent actually has sent a dcname and thus really knows it. Second,
ntlm_auth needs the error code, not just the fact it failed.

Jerry, the 3_0 part might qualify as a "recommended patch".

Thanks,

Volker

Modified:
   branches/SAMBA_3_0/source/nsswitch/winbindd_dual.c
   branches/SAMBA_3_0/source/nsswitch/winbindd_util.c
   trunk/source/nsswitch/winbindd_dual.c
   trunk/source/nsswitch/winbindd_util.c


Changeset:
Modified: branches/SAMBA_3_0/source/nsswitch/winbindd_dual.c
===================================================================
--- branches/SAMBA_3_0/source/nsswitch/winbindd_dual.c  2005-08-28 07:30:40 UTC 
(rev 9708)
+++ branches/SAMBA_3_0/source/nsswitch/winbindd_dual.c  2005-08-28 09:19:10 UTC 
(rev 9709)
@@ -158,9 +158,8 @@
                return;
        }
 
-       if (state->response->result == WINBINDD_OK)
-               SMB_ASSERT(cache_retrieve_response(child->pid,
-                                                  state->response));
+       SMB_ASSERT(cache_retrieve_response(child->pid,
+                                          state->response));
 
        DLIST_REMOVE(child->requests, state);
 
@@ -479,12 +478,11 @@
                        DEBUG(4,("child daemon request %d\n",
                                 (int)state.request.cmd));
 
+                       ZERO_STRUCT(state.response);
                        state.request.null_term = '\0';
                        child_process_request(child->domain, &state);
 
-                       if (state.response.result == WINBINDD_OK)
-                               cache_store_response(sys_getpid(),
-                                                    &state.response);
+                       cache_store_response(sys_getpid(), &state.response);
 
                        SAFE_FREE(state.response.extra_data);
 

Modified: branches/SAMBA_3_0/source/nsswitch/winbindd_util.c
===================================================================
--- branches/SAMBA_3_0/source/nsswitch/winbindd_util.c  2005-08-28 07:30:40 UTC 
(rev 9708)
+++ branches/SAMBA_3_0/source/nsswitch/winbindd_util.c  2005-08-28 09:19:10 UTC 
(rev 9709)
@@ -444,7 +444,9 @@
        state->request.data.init_conn.dcname
                [sizeof(state->request.data.init_conn.dcname)-1]='\0';
 
-       fstrcpy(domain->dcname, state->request.data.init_conn.dcname);
+       if (strlen(state->request.data.init_conn.dcname) > 0) {
+               fstrcpy(domain->dcname, state->request.data.init_conn.dcname);
+       }
 
        if (strlen(domain->dcname) > 0) {
                if (!resolve_name(domain->dcname, &ipaddr, 0x20)) {

Modified: trunk/source/nsswitch/winbindd_dual.c
===================================================================
--- trunk/source/nsswitch/winbindd_dual.c       2005-08-28 07:30:40 UTC (rev 
9708)
+++ trunk/source/nsswitch/winbindd_dual.c       2005-08-28 09:19:10 UTC (rev 
9709)
@@ -196,9 +196,8 @@
                return;
        }
 
-       if (state->response->result == WINBINDD_OK)
-               SMB_ASSERT(cache_retrieve_response(child->pid,
-                                                  state->response));
+       SMB_ASSERT(cache_retrieve_response(child->pid,
+                                          state->response));
 
        DLIST_REMOVE(child->requests, state);
 
@@ -526,13 +525,13 @@
 
                DEBUG(4,("child daemon request %d\n", (int)state.request.cmd));
 
+               ZERO_STRUCT(state.response);
                state.request.null_term = '\0';
                child_process_request(child->domain, &state);
 
                SAFE_FREE(state.request.extra_data);
 
-               if (state.response.result == WINBINDD_OK)
-                       cache_store_response(sys_getpid(), &state.response);
+               cache_store_response(sys_getpid(), &state.response);
 
                SAFE_FREE(state.response.extra_data);
 

Modified: trunk/source/nsswitch/winbindd_util.c
===================================================================
--- trunk/source/nsswitch/winbindd_util.c       2005-08-28 07:30:40 UTC (rev 
9708)
+++ trunk/source/nsswitch/winbindd_util.c       2005-08-28 09:19:10 UTC (rev 
9709)
@@ -444,7 +444,9 @@
        state->request.data.init_conn.dcname
                [sizeof(state->request.data.init_conn.dcname)-1]='\0';
 
-       fstrcpy(domain->dcname, state->request.data.init_conn.dcname);
+       if (strlen(state->request.data.init_conn.dcname) > 0) {
+               fstrcpy(domain->dcname, state->request.data.init_conn.dcname);
+       }
 
        if (strlen(domain->dcname) > 0) {
                if (!resolve_name(domain->dcname, &ipaddr, 0x20)) {

Reply via email to