[SCM] Samba Shared Repository - branch v3-3-test updated -
release-3-2-0pre2-4431-g10c20f2
Günther Deschner
gd at samba.org
Wed Nov 19 01:03:50 GMT 2008
The branch, v3-3-test has been updated
via 10c20f2beb2da17cff94e4beb5a228a07a276be1 (commit)
via 162af045bb616da6e9864a121dee91c21d67d86b (commit)
via 46942bad3818750c027eae62480e88b8cfa54875 (commit)
via 5d105f89f087dacd4eb52c0efe4795faf1037c2b (commit)
via ecafae21667f3b2a30cd5d0d5fc68bb01c7ef811 (commit)
via 2003edbc309d64ad76e1b924b3b5290ddd198104 (commit)
via b445624f6d28bd269ffb2b4db26343659fdd9390 (commit)
from e96bcb7c2a49f95dee2a50adb1ed3ba77b1cbe07 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-3-test
- Log -----------------------------------------------------------------
commit 10c20f2beb2da17cff94e4beb5a228a07a276be1
Author: Günther Deschner <gd at samba.org>
Date: Sat Sep 27 03:29:01 2008 +0200
wbclient: add wbcLookupDomainControllerEx call.
Guenther
commit 162af045bb616da6e9864a121dee91c21d67d86b
Author: Günther Deschner <gd at samba.org>
Date: Thu Oct 2 13:11:31 2008 +0200
wbclient: add wbcGuidToString and wbcStringToGuid helper functions.
Guenther
commit 46942bad3818750c027eae62480e88b8cfa54875
Author: Günther Deschner <gd at samba.org>
Date: Thu Oct 2 13:06:50 2008 +0200
wbclient: add wbcGuid structure.
Guenther
commit 5d105f89f087dacd4eb52c0efe4795faf1037c2b
Author: Günther Deschner <gd at samba.org>
Date: Thu Oct 2 13:07:14 2008 +0200
wbclient: add my copyright.
Guenther
commit ecafae21667f3b2a30cd5d0d5fc68bb01c7ef811
Author: Günther Deschner <gd at samba.org>
Date: Sat Sep 27 03:11:59 2008 +0200
krb5-locator: fix dsgetdcname caller.
Guenther
commit 2003edbc309d64ad76e1b924b3b5290ddd198104
Author: Günther Deschner <gd at samba.org>
Date: Sat Sep 27 03:11:33 2008 +0200
wbinfo: fix dsgetdcname caller.
Guenther
commit b445624f6d28bd269ffb2b4db26343659fdd9390
Author: Günther Deschner <gd at samba.org>
Date: Sat Sep 27 03:05:47 2008 +0200
s3-winbindd: add dsgetdcname request and reply to winbind structure.
Guenther
-----------------------------------------------------------------------
Summary of changes:
source/Makefile.in | 1 +
source/nsswitch/libwbclient/wbc_guid.c | 118 ++++++++++++++++++++++++
source/nsswitch/libwbclient/wbc_pam.c | 1 +
source/nsswitch/libwbclient/wbc_util.c | 139 +++++++++++++++++++++++++++++
source/nsswitch/libwbclient/wbclient.h | 44 +++++++++-
source/nsswitch/wbinfo.c | 14 +++-
source/nsswitch/winbind_krb5_locator.c | 27 +++++-
source/nsswitch/winbind_struct_protocol.h | 17 ++++
8 files changed, 352 insertions(+), 9 deletions(-)
create mode 100644 source/nsswitch/libwbclient/wbc_guid.c
Changeset truncated at 500 lines:
diff --git a/source/Makefile.in b/source/Makefile.in
index a5af0b2..685c688 100644
--- a/source/Makefile.in
+++ b/source/Makefile.in
@@ -1731,6 +1731,7 @@ LIBWBCLIENT_OBJ0 = nsswitch/libwbclient/wbclient.o \
nsswitch/libwbclient/wbc_pwd.o \
nsswitch/libwbclient/wbc_idmap.o \
nsswitch/libwbclient/wbc_sid.o \
+ nsswitch/libwbclient/wbc_guid.o \
nsswitch/libwbclient/wbc_pam.o
LIBWBCLIENT_OBJ = $(LIBWBCLIENT_OBJ0) \
$(WBCOMMON_OBJ) \
diff --git a/source/nsswitch/libwbclient/wbc_guid.c b/source/nsswitch/libwbclient/wbc_guid.c
new file mode 100644
index 0000000..0cb33e9
--- /dev/null
+++ b/source/nsswitch/libwbclient/wbc_guid.c
@@ -0,0 +1,118 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ Winbind client API
+
+ Copyright (C) Gerald (Jerry) Carter 2007
+
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 3 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/* Required Headers */
+
+#include "libwbclient.h"
+
+/** @brief Convert a binary GUID to a character string
+ *
+ * @param guid Binary Guid
+ * @param **guid_string Resulting character string
+ *
+ * @return #wbcErr
+ **/
+
+wbcErr wbcGuidToString(const struct wbcGuid *guid,
+ char **guid_string)
+{
+ wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+
+ if (!guid) {
+ wbc_status = WBC_ERR_INVALID_PARAM;
+ BAIL_ON_WBC_ERROR(wbc_status);
+ }
+
+ *guid_string = talloc_asprintf(NULL,
+ "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ guid->time_low, guid->time_mid,
+ guid->time_hi_and_version,
+ guid->clock_seq[0],
+ guid->clock_seq[1],
+ guid->node[0], guid->node[1],
+ guid->node[2], guid->node[3],
+ guid->node[4], guid->node[5]);
+ BAIL_ON_PTR_ERROR((*guid_string), wbc_status);
+
+ wbc_status = WBC_ERR_SUCCESS;
+
+done:
+ return wbc_status;
+}
+
+/** @brief Convert a character string to a binary GUID
+ *
+ * @param *str Character string
+ * @param guid Resulting binary GUID
+ *
+ * @return #wbcErr
+ **/
+
+wbcErr wbcStringToGuid(const char *str,
+ struct wbcGuid *guid)
+{
+ uint32_t time_low;
+ uint32_t time_mid, time_hi_and_version;
+ uint32_t clock_seq[2];
+ uint32_t node[6];
+ int i;
+ wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+
+ if (!guid) {
+ wbc_status = WBC_ERR_INVALID_PARAM;
+ BAIL_ON_WBC_ERROR(wbc_status);
+ }
+
+ if (!str) {
+ wbc_status = WBC_ERR_INVALID_PARAM;
+ BAIL_ON_WBC_ERROR(wbc_status);
+ }
+
+ if (11 == sscanf(str, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ &time_low, &time_mid, &time_hi_and_version,
+ &clock_seq[0], &clock_seq[1],
+ &node[0], &node[1], &node[2], &node[3], &node[4], &node[5])) {
+ wbc_status = WBC_ERR_SUCCESS;
+ } else if (11 == sscanf(str, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
+ &time_low, &time_mid, &time_hi_and_version,
+ &clock_seq[0], &clock_seq[1],
+ &node[0], &node[1], &node[2], &node[3], &node[4], &node[5])) {
+ wbc_status = WBC_ERR_SUCCESS;
+ }
+
+ BAIL_ON_WBC_ERROR(wbc_status);
+
+ guid->time_low = time_low;
+ guid->time_mid = time_mid;
+ guid->time_hi_and_version = time_hi_and_version;
+ guid->clock_seq[0] = clock_seq[0];
+ guid->clock_seq[1] = clock_seq[1];
+
+ for (i=0;i<6;i++) {
+ guid->node[i] = node[i];
+ }
+
+ wbc_status = WBC_ERR_SUCCESS;
+
+done:
+ return wbc_status;
+}
diff --git a/source/nsswitch/libwbclient/wbc_pam.c b/source/nsswitch/libwbclient/wbc_pam.c
index 20b42b6..70e2aa6 100644
--- a/source/nsswitch/libwbclient/wbc_pam.c
+++ b/source/nsswitch/libwbclient/wbc_pam.c
@@ -4,6 +4,7 @@
Winbind client API
Copyright (C) Gerald (Jerry) Carter 2007
+ Copyright (C) Guenther Deschner 2008
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
diff --git a/source/nsswitch/libwbclient/wbc_util.c b/source/nsswitch/libwbclient/wbc_util.c
index 8e01e6e..5aea884 100644
--- a/source/nsswitch/libwbclient/wbc_util.c
+++ b/source/nsswitch/libwbclient/wbc_util.c
@@ -550,3 +550,142 @@ done:
return wbc_status;
}
+
+static wbcErr wbc_create_domain_controller_info_ex(TALLOC_CTX *mem_ctx,
+ const struct winbindd_response *resp,
+ struct wbcDomainControllerInfoEx **_i)
+{
+ wbcErr wbc_status = WBC_ERR_SUCCESS;
+ struct wbcDomainControllerInfoEx *i;
+ struct wbcGuid guid;
+
+ i = talloc(mem_ctx, struct wbcDomainControllerInfoEx);
+ BAIL_ON_PTR_ERROR(i, wbc_status);
+
+ i->dc_unc = talloc_strdup(i, resp->data.dsgetdcname.dc_unc);
+ BAIL_ON_PTR_ERROR(i->dc_unc, wbc_status);
+
+ i->dc_address = talloc_strdup(i, resp->data.dsgetdcname.dc_address);
+ BAIL_ON_PTR_ERROR(i->dc_address, wbc_status);
+
+ i->dc_address_type = resp->data.dsgetdcname.dc_address_type;
+
+ wbc_status = wbcStringToGuid(resp->data.dsgetdcname.domain_guid, &guid);
+ if (WBC_ERROR_IS_OK(wbc_status)) {
+ i->domain_guid = talloc(i, struct wbcGuid);
+ BAIL_ON_PTR_ERROR(i->domain_guid, wbc_status);
+
+ *i->domain_guid = guid;
+ } else {
+ i->domain_guid = NULL;
+ }
+
+ i->domain_name = talloc_strdup(i, resp->data.dsgetdcname.domain_name);
+ BAIL_ON_PTR_ERROR(i->domain_name, wbc_status);
+
+ if (resp->data.dsgetdcname.forest_name[0] != '\0') {
+ i->forest_name = talloc_strdup(i,
+ resp->data.dsgetdcname.forest_name);
+ BAIL_ON_PTR_ERROR(i->forest_name, wbc_status);
+ } else {
+ i->forest_name = NULL;
+ }
+
+ i->dc_flags = resp->data.dsgetdcname.dc_flags;
+
+ if (resp->data.dsgetdcname.dc_site_name[0] != '\0') {
+ i->dc_site_name = talloc_strdup(i,
+ resp->data.dsgetdcname.dc_site_name);
+ BAIL_ON_PTR_ERROR(i->dc_site_name, wbc_status);
+ } else {
+ i->dc_site_name = NULL;
+ }
+
+ if (resp->data.dsgetdcname.client_site_name[0] != '\0') {
+ i->client_site_name = talloc_strdup(i,
+ resp->data.dsgetdcname.client_site_name);
+ BAIL_ON_PTR_ERROR(i->client_site_name, wbc_status);
+ } else {
+ i->client_site_name = NULL;
+ }
+
+ *_i = i;
+ i = NULL;
+
+done:
+ talloc_free(i);
+ return wbc_status;
+}
+
+/** @brief Get extended domain controller information
+ *
+ * @param domain Name of the domain to query for a DC
+ * @param guid Guid of the domain to query for a DC
+ * @param site Site of the domain to query for a DC
+ * @param flags Bit flags used to control the domain location query
+ * @param *dc_info Pointer to the returned extended domain controller information
+ *
+ * @return #wbcErr
+ *
+ **/
+
+wbcErr wbcLookupDomainControllerEx(const char *domain,
+ struct wbcGuid *guid,
+ const char *site,
+ uint32_t flags,
+ struct wbcDomainControllerInfoEx **dc_info)
+{
+ wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+ struct winbindd_request request;
+ struct winbindd_response response;
+
+ /* validate input params */
+
+ if (!domain || !dc_info) {
+ wbc_status = WBC_ERR_INVALID_PARAM;
+ BAIL_ON_WBC_ERROR(wbc_status);
+ }
+
+ ZERO_STRUCT(request);
+ ZERO_STRUCT(response);
+
+ request.data.dsgetdcname.flags = flags;
+
+ strncpy(request.data.dsgetdcname.domain_name, domain,
+ sizeof(request.data.dsgetdcname.domain_name)-1);
+
+ if (site) {
+ strncpy(request.data.dsgetdcname.site_name, site,
+ sizeof(request.data.dsgetdcname.site_name)-1);
+ }
+
+ if (guid) {
+ char *str = NULL;
+
+ wbc_status = wbcGuidToString(guid, &str);
+ BAIL_ON_WBC_ERROR(wbc_status);
+
+ strncpy(request.data.dsgetdcname.domain_guid, str,
+ sizeof(request.data.dsgetdcname.domain_guid)-1);
+
+ wbcFreeMemory(str);
+ }
+
+ /* Send request */
+
+ wbc_status = wbcRequestResponse(WINBINDD_DSGETDCNAME,
+ &request,
+ &response);
+ BAIL_ON_WBC_ERROR(wbc_status);
+
+ if (dc_info) {
+ wbc_status = wbc_create_domain_controller_info_ex(NULL,
+ &response,
+ dc_info);
+ BAIL_ON_WBC_ERROR(wbc_status);
+ }
+
+ wbc_status = WBC_ERR_SUCCESS;
+done:
+ return wbc_status;
+}
diff --git a/source/nsswitch/libwbclient/wbclient.h b/source/nsswitch/libwbclient/wbclient.h
index 1789e8e..797b4d7 100644
--- a/source/nsswitch/libwbclient/wbclient.h
+++ b/source/nsswitch/libwbclient/wbclient.h
@@ -137,6 +137,19 @@ struct wbcSidWithAttr {
#define WBC_SID_ATTR_GROUP_LOGON_ID 0xC0000000
/**
+ * @brief Windows GUID
+ *
+ **/
+
+struct wbcGuid {
+ uint32_t time_low;
+ uint16_t time_mid;
+ uint16_t time_hi_and_version;
+ uint8_t clock_seq[2];
+ uint8_t node[6];
+};
+
+/**
* @brief Domain Information
**/
@@ -379,7 +392,20 @@ struct wbcDomainControllerInfo {
char *dc_name;
};
-
+/*
+ * DomainControllerInfoEx struct
+ */
+struct wbcDomainControllerInfoEx {
+ const char *dc_unc;
+ const char *dc_address;
+ uint16_t dc_address_type;
+ struct wbcGuid *domain_guid;
+ const char *domain_name;
+ const char *forest_name;
+ uint32_t dc_flags;
+ const char *dc_site_name;
+ const char *client_site_name;
+};
/*
* Memory Management
@@ -398,6 +424,16 @@ wbcErr wbcSidToString(const struct wbcDomainSid *sid,
wbcErr wbcStringToSid(const char *sid_string,
struct wbcDomainSid *sid);
+/*
+ * Utility functions for dealing with GUIDs
+ */
+
+wbcErr wbcGuidToString(const struct wbcGuid *guid,
+ char **guid_string);
+
+wbcErr wbcStringToGuid(const char *guid_string,
+ struct wbcGuid *guid);
+
wbcErr wbcPing(void);
wbcErr wbcLibraryDetails(struct wbcLibraryDetails **details);
@@ -536,6 +572,12 @@ wbcErr wbcLookupDomainController(const char *domain,
uint32_t flags,
struct wbcDomainControllerInfo **dc_info);
+wbcErr wbcLookupDomainControllerEx(const char *domain,
+ struct wbcGuid *guid,
+ const char *site,
+ uint32_t flags,
+ struct wbcDomainControllerInfoEx **dc_info);
+
/*
* Athenticate functions
*/
diff --git a/source/nsswitch/wbinfo.c b/source/nsswitch/wbinfo.c
index cee8cc3..84f01e1 100644
--- a/source/nsswitch/wbinfo.c
+++ b/source/nsswitch/wbinfo.c
@@ -538,8 +538,8 @@ static bool wbinfo_dsgetdcname(const char *domain_name, uint32_t flags)
ZERO_STRUCT(request);
ZERO_STRUCT(response);
- fstrcpy(request.domain_name, domain_name);
- request.flags = flags;
+ fstrcpy(request.data.dsgetdcname.domain_name, domain_name);
+ request.data.dsgetdcname.flags = flags;
request.flags |= DS_DIRECTORY_SERVICE_REQUIRED;
@@ -553,7 +553,15 @@ static bool wbinfo_dsgetdcname(const char *domain_name, uint32_t flags)
/* Display response */
- d_printf("%s\n", response.data.dc_name);
+ d_printf("%s\n", response.data.dsgetdcname.dc_unc);
+ d_printf("%s\n", response.data.dsgetdcname.dc_address);
+ d_printf("%d\n", response.data.dsgetdcname.dc_address_type);
+ d_printf("%s\n", response.data.dsgetdcname.domain_guid);
+ d_printf("%s\n", response.data.dsgetdcname.domain_name);
+ d_printf("%s\n", response.data.dsgetdcname.forest_name);
+ d_printf("0x%08x\n", response.data.dsgetdcname.dc_flags);
+ d_printf("%s\n", response.data.dsgetdcname.dc_site_name);
+ d_printf("%s\n", response.data.dsgetdcname.client_site_name);
return true;
}
diff --git a/source/nsswitch/winbind_krb5_locator.c b/source/nsswitch/winbind_krb5_locator.c
index 990c2ca..7eecd13 100644
--- a/source/nsswitch/winbind_krb5_locator.c
+++ b/source/nsswitch/winbind_krb5_locator.c
@@ -1,7 +1,7 @@
/*
Unix SMB/CIFS implementation.
kerberos locator plugin
- Copyright (C) Guenther Deschner 2007
+ Copyright (C) Guenther Deschner 2007-2008
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -247,18 +247,19 @@ static bool ask_winbind(const char *realm, char **dcname)
NSS_STATUS status;
struct winbindd_request request;
struct winbindd_response response;
+ const char *dc = NULL;
ZERO_STRUCT(request);
ZERO_STRUCT(response);
- request.flags = 0x40020600;
+ request.data.dsgetdcname.flags = 0x40020600;
/* DS_KDC_REQUIRED |
DS_IS_DNS_NAME |
DS_RETURN_DNS_NAME |
DS_IP_REQUIRED */
- strncpy(request.domain_name, realm,
- sizeof(request.domain_name)-1);
+ strncpy(request.data.dsgetdcname.domain_name, realm,
+ sizeof(request.data.dsgetdcname.domain_name)-1);
status = winbindd_request_response(WINBINDD_DSGETDCNAME,
&request, &response);
@@ -270,7 +271,23 @@ static bool ask_winbind(const char *realm, char **dcname)
return false;
}
- *dcname = strdup(response.data.dc_name);
+ if (response.data.dsgetdcname.dc_address[0] != '\0') {
+ dc = response.data.dsgetdcname.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[0] == '\\') dc++;
+ if (dc[0] == '\\') dc++;
+ }
+
+ if (!dc) {
+ return false;
+ }
+
+ *dcname = strdup(dc);
if (!*dcname) {
return false;
}
diff --git a/source/nsswitch/winbind_struct_protocol.h b/source/nsswitch/winbind_struct_protocol.h
index b5b0b11..169b4a8 100644
--- a/source/nsswitch/winbind_struct_protocol.h
+++ b/source/nsswitch/winbind_struct_protocol.h
@@ -315,6 +315,12 @@ struct winbindd_request {
uint32_t initial_blob_len; /* blobs in extra_data */
uint32_t challenge_blob_len;
} ccache_ntlm_auth;
+ struct {
+ fstring domain_name;
+ fstring domain_guid;
+ fstring site_name;
+ uint32_t flags;
+ } dsgetdcname;
/* padding -- needed to fix alignment between 32bit and 64bit libs.
The size is the sizeof the union without the padding aligned on
@@ -455,6 +461,17 @@ struct winbindd_response {
struct {
uint32_t auth_blob_len; /* blob in extra_data */
} ccache_ntlm_auth;
+ struct {
+ fstring dc_unc;
+ fstring dc_address;
+ uint32_t dc_address_type;
+ fstring domain_guid;
+ fstring domain_name;
+ fstring forest_name;
+ uint32_t dc_flags;
+ fstring dc_site_name;
+ fstring client_site_name;
+ } dsgetdcname;
} data;
/* Variable length return data */
--
Samba Shared Repository
More information about the samba-cvs
mailing list