The branch, v3-3-test has been updated
       via  b63b4028ed8823626a956bb437e275a1b1432483 (commit)
       via  df554493c74ea611bfc5d890a4c2eca6eb3106d1 (commit)
      from  f84fe8b0025850b31560f149ebaa27cf5a504694 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-3-test


- Log -----------------------------------------------------------------
commit b63b4028ed8823626a956bb437e275a1b1432483
Author: Günther Deschner <[EMAIL PROTECTED]>
Date:   Fri Nov 21 17:33:22 2008 +0100

    krb5_locator: use wbcLookupDomainControllerEx() for query.
    
    Guenther

commit df554493c74ea611bfc5d890a4c2eca6eb3106d1
Author: Günther Deschner <[EMAIL PROTECTED]>
Date:   Sat Sep 27 03:09:07 2008 +0200

    s3-winbindd: use new, richer structures in WINBINDD_DSGETDCNAME 
implementation.
    
    Guenther

-----------------------------------------------------------------------

Summary of changes:
 source/Makefile.in                     |    6 ++--
 source/nsswitch/winbind_krb5_locator.c |   39 +++++++++-----------
 source/winbindd/winbindd_locator.c     |   61 +++++++++++++++++++++-----------
 3 files changed, 61 insertions(+), 45 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/Makefile.in b/source/Makefile.in
index 6d8cc81..a25efb5 100644
--- a/source/Makefile.in
+++ b/source/Makefile.in
@@ -1083,7 +1083,7 @@ LDBDEL_OBJ = $(LDB_CMDLINE_OBJ) lib/ldb/tools/ldbdel.o
 LDBMODIFY_OBJ = $(LDB_CMDLINE_OBJ) lib/ldb/tools/ldbmodify.o
 
 WINBIND_KRB5_LOCATOR_OBJ1 = nsswitch/winbind_krb5_locator.o
-WINBIND_KRB5_LOCATOR_OBJ = $(WINBIND_KRB5_LOCATOR_OBJ1) $(WBCOMMON_OBJ) 
$(LIBREPLACE_OBJ)
+WINBIND_KRB5_LOCATOR_OBJ = $(WINBIND_KRB5_LOCATOR_OBJ1) $(LIBREPLACE_OBJ)
 
 POPT_OBJ=popt/findme.o popt/popt.o popt/poptconfig.o \
           popt/popthelp.o popt/poptparse.o
@@ -2192,9 +2192,9 @@ bin/[EMAIL PROTECTED]@: $(BINARY_PREREQS) $(VLP_OBJ) 
@LIBTALLOC_SHARED@ @LIBTDB_SHARED@
                $(LDAP_LIBS) $(KRB5LIBS) $(LIBS) $(LIBTALLOC_LIBS) 
$(LIBTDB_LIBS) \
                @[EMAIL PROTECTED] [EMAIL PROTECTED]@NSSSONAMEVERSIONSUFFIX@
 
-bin/[EMAIL PROTECTED]@: $(BINARY_PREREQS) $(WINBIND_KRB5_LOCATOR_OBJ)
+bin/[EMAIL PROTECTED]@: $(BINARY_PREREQS) $(WINBIND_KRB5_LOCATOR_OBJ) 
@LIBWBCLIENT_SHARED@
        @echo "Linking $@"
-       @$(SHLD) $(LDSHFLAGS) -o $@ $(WINBIND_KRB5_LOCATOR_OBJ) \
+       @$(SHLD) $(LDSHFLAGS) -o $@ $(WINBIND_KRB5_LOCATOR_OBJ) $(WINBIND_LIBS) 
\
                @[EMAIL PROTECTED] [EMAIL PROTECTED]
 
 bin/[EMAIL PROTECTED]@: $(BINARY_PREREQS) $(PAM_WINBIND_OBJ) 
@LIBTALLOC_SHARED@ @LIBWBCLIENT_SHARED@
diff --git a/source/nsswitch/winbind_krb5_locator.c 
b/source/nsswitch/winbind_krb5_locator.c
index 7eecd13..b9e35bd 100644
--- a/source/nsswitch/winbind_krb5_locator.c
+++ b/source/nsswitch/winbind_krb5_locator.c
@@ -18,6 +18,7 @@
 */
 
 #include "nsswitch/winbind_client.h"
+#include "libwbclient/wbclient.h"
 
 #ifndef DEBUG_KRB5
 #undef DEBUG_KRB5
@@ -244,54 +245,50 @@ static void smb_krb5_locator_close(void *private_data)
 
 static bool ask_winbind(const char *realm, char **dcname)
 {
-       NSS_STATUS status;
-       struct winbindd_request request;
-       struct winbindd_response response;
+       wbcErr wbc_status;
        const char *dc = NULL;
+       struct wbcDomainControllerInfoEx *dc_info = NULL;
+       uint32_t flags;
 
-       ZERO_STRUCT(request);
-       ZERO_STRUCT(response);
+       flags = WBC_LOOKUP_DC_KDC_REQUIRED |
+               WBC_LOOKUP_DC_IS_DNS_NAME |
+               WBC_LOOKUP_DC_RETURN_DNS_NAME |
+               WBC_LOOKUP_DC_IP_REQUIRED;
 
-       request.data.dsgetdcname.flags = 0x40020600;
-                       /* DS_KDC_REQUIRED |
-                       DS_IS_DNS_NAME |
-                       DS_RETURN_DNS_NAME |
-                       DS_IP_REQUIRED */
+       wbc_status = wbcLookupDomainControllerEx(realm, NULL, NULL, flags, 
&dc_info);
 
-       strncpy(request.data.dsgetdcname.domain_name, realm,
-               sizeof(request.data.dsgetdcname.domain_name)-1);
-
-       status = winbindd_request_response(WINBINDD_DSGETDCNAME,
-                                          &request, &response);
-       if (status != NSS_STATUS_SUCCESS) {
+       if (!WBC_ERROR_IS_OK(wbc_status)) {
 #ifdef DEBUG_KRB5
                fprintf(stderr,"[%5u]: smb_krb5_locator_lookup: failed with: 
%s\n",
-                       (unsigned int)getpid(), nss_err_str(status));
+                       (unsigned int)getpid(), wbcErrorString(wbc_status));
 #endif
                return false;
        }
 
-       if (response.data.dsgetdcname.dc_address[0] != '\0') {
-               dc = response.data.dsgetdcname.dc_address;
+       if (dc_info->dc_address) {
+               dc = dc_info->dc_address;
                if (dc[0] == '\\') dc++;
                if (dc[0] == '\\') dc++;
        }
 
-       if (!dc && response.data.dsgetdcname.dc_unc[0] != '\0') {
-               dc = response.data.dsgetdcname.dc_unc;
+       if (!dc && dc_info->dc_unc) {
+               dc = dc_info->dc_unc;
                if (dc[0] == '\\') dc++;
                if (dc[0] == '\\') dc++;
        }
 
        if (!dc) {
+               wbcFreeMemory(dc_info);
                return false;
        }
 
        *dcname = strdup(dc);
        if (!*dcname) {
+               wbcFreeMemory(dc_info);
                return false;
        }
 
+       wbcFreeMemory(dc_info);
        return true;
 }
 
diff --git a/source/winbindd/winbindd_locator.c 
b/source/winbindd/winbindd_locator.c
index b2a8bd7..b60d235 100644
--- a/source/winbindd/winbindd_locator.c
+++ b/source/winbindd/winbindd_locator.c
@@ -45,11 +45,15 @@ struct winbindd_child *locator_child(void)
 
 void winbindd_dsgetdcname(struct winbindd_cli_state *state)
 {
-       state->request.domain_name
-               [sizeof(state->request.domain_name)-1] = '\0';
+       state->request.data.dsgetdcname.domain_name
+               [sizeof(state->request.data.dsgetdcname.domain_name)-1] = '\0';
+       state->request.data.dsgetdcname.site_name
+               [sizeof(state->request.data.dsgetdcname.site_name)-1] = '\0';
+       state->request.data.dsgetdcname.domain_guid
+               [sizeof(state->request.data.dsgetdcname.domain_guid)-1] = '\0';
 
        DEBUG(3, ("[%5lu]: dsgetdcname for %s\n", (unsigned long)state->pid,
-                 state->request.domain_name));
+                 state->request.data.dsgetdcname.domain_name));
 
        sendto_child(state, locator_child());
 }
@@ -94,44 +98,59 @@ static uint32_t get_dsgetdc_flags(uint32_t wbc_flags)
        return ds_flags;
 }
 
-
 static enum winbindd_result dual_dsgetdcname(struct winbindd_domain *domain,
                                             struct winbindd_cli_state *state)
 {
        NTSTATUS result;
        struct netr_DsRGetDCNameInfo *info = NULL;
-       const char *dc = NULL;
        uint32_t ds_flags = 0;
+       struct GUID guid, *guid_ptr = NULL;
+       const char *guid_str = NULL;
 
-       state->request.domain_name
-               [sizeof(state->request.domain_name)-1] = '\0';
+       state->request.data.dsgetdcname.domain_name
+               [sizeof(state->request.data.dsgetdcname.domain_name)-1] = '\0';
+       state->request.data.dsgetdcname.site_name
+               [sizeof(state->request.data.dsgetdcname.site_name)-1] = '\0';
+       state->request.data.dsgetdcname.domain_guid
+               [sizeof(state->request.data.dsgetdcname.domain_guid)-1] = '\0';
 
        DEBUG(3, ("[%5lu]: dsgetdcname for %s\n", (unsigned long)state->pid,
-                 state->request.domain_name));
+                 state->request.data.dsgetdcname.domain_name));
 
        ds_flags = get_dsgetdc_flags(state->request.flags);
 
-       result = dsgetdcname(state->mem_ctx, winbind_messaging_context(),
-                            state->request.domain_name,
-                            NULL, NULL, ds_flags, &info);
-
-       if (!NT_STATUS_IS_OK(result)) {
-               return WINBINDD_ERROR;
+       result = GUID_from_string(state->request.data.dsgetdcname.domain_guid,
+                                 &guid);
+       if (NT_STATUS_IS_OK(result) && !GUID_all_zero(&guid)) {
+               guid_ptr = &guid;
        }
 
-       if (info->dc_address) {
-               dc = strip_hostname(info->dc_address);
-       }
+       result = dsgetdcname(state->mem_ctx,
+                            winbind_messaging_context(),
+                            state->request.data.dsgetdcname.domain_name,
+                            guid_ptr,
+                            state->request.data.dsgetdcname.site_name,
+                            ds_flags,
+                            &info);
 
-       if ((!dc || !is_ipaddress_v4(dc)) && info->dc_unc) {
-               dc = strip_hostname(info->dc_unc);
+       if (!NT_STATUS_IS_OK(result)) {
+               return WINBINDD_ERROR;
        }
 
-       if (!dc || !*dc) {
+       guid_str = GUID_string(state->mem_ctx, &info->domain_guid);
+       if (!guid_str) {
                return WINBINDD_ERROR;
        }
 
-       fstrcpy(state->response.data.dc_name, dc);
+       fstrcpy(state->response.data.dsgetdcname.dc_unc, info->dc_unc);
+       fstrcpy(state->response.data.dsgetdcname.dc_address, info->dc_address);
+       state->response.data.dsgetdcname.dc_address_type = 
info->dc_address_type;
+       fstrcpy(state->response.data.dsgetdcname.domain_guid, guid_str);
+       fstrcpy(state->response.data.dsgetdcname.domain_name, 
info->domain_name);
+       fstrcpy(state->response.data.dsgetdcname.forest_name, 
info->forest_name);
+       state->response.data.dsgetdcname.dc_flags = info->dc_flags;
+       fstrcpy(state->response.data.dsgetdcname.dc_site_name, 
info->dc_site_name);
+       fstrcpy(state->response.data.dsgetdcname.client_site_name, 
info->client_site_name);
 
        return WINBINDD_OK;
 }


-- 
Samba Shared Repository

Reply via email to