[SCM] Samba Shared Repository - branch v3-2-test updated -
release-3-2-0pre2-616-gff87260
Stefan Metzmacher
metze at samba.org
Tue Apr 1 16:37:18 GMT 2008
The branch, v3-2-test has been updated
via ff87260f1268d190170608b0808c191ef8f3e942 (commit)
via fee3806326b9ba214e35868271e6481c0c8b9c4b (commit)
via de2e8d5db93d32e5ebf04a2018a08f766eb9a233 (commit)
from c04a234f8f6fbdf8e54c69414024d84aa71fec45 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test
- Log -----------------------------------------------------------------
commit ff87260f1268d190170608b0808c191ef8f3e942
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Mar 28 16:55:53 2008 +0100
wbinfo: use wbcInterfaceDetails()
metze
commit fee3806326b9ba214e35868271e6481c0c8b9c4b
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Mar 28 16:52:18 2008 +0100
libwbclient: add wbcInterfaceDetails()
metze
commit de2e8d5db93d32e5ebf04a2018a08f766eb9a233
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Mar 31 12:01:24 2008 +0200
libwbclient: use WBC_ERROR_IS_OK() in BAIL_ON_WBC_ERROR() macro
metze
-----------------------------------------------------------------------
Summary of changes:
source/nsswitch/libwbclient/wbc_err_internal.h | 9 ++-
source/nsswitch/libwbclient/wbc_util.c | 75 ++++++++++++++++++++++++
source/nsswitch/libwbclient/wbclient.h | 15 +++++
source/nsswitch/wbinfo.c | 44 ++++++++------
4 files changed, 120 insertions(+), 23 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source/nsswitch/libwbclient/wbc_err_internal.h b/source/nsswitch/libwbclient/wbc_err_internal.h
index ea501cb..83364b8 100644
--- a/source/nsswitch/libwbclient/wbc_err_internal.h
+++ b/source/nsswitch/libwbclient/wbc_err_internal.h
@@ -24,10 +24,11 @@
/* Private macros */
-#define BAIL_ON_WBC_ERROR(x) \
- do { \
- if ((x) != WBC_ERR_SUCCESS) \
- goto done; \
+#define BAIL_ON_WBC_ERROR(x) \
+ do { \
+ if (!WBC_ERROR_IS_OK(x)) { \
+ goto done; \
+ } \
} while(0);
#define BAIL_ON_PTR_ERROR(x, status) \
diff --git a/source/nsswitch/libwbclient/wbc_util.c b/source/nsswitch/libwbclient/wbc_util.c
index ff3cec8..7bdae91 100644
--- a/source/nsswitch/libwbclient/wbc_util.c
+++ b/source/nsswitch/libwbclient/wbc_util.c
@@ -44,6 +44,81 @@ wbcErr wbcPing(void)
return wbcRequestResponse(WINBINDD_PING, &request, &response);
}
+wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **_details)
+{
+ wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+ struct wbcInterfaceDetails *info;
+ struct wbcDomainInfo *domain = NULL;
+ struct winbindd_request request;
+ struct winbindd_response response;
+
+ /* Initialize request */
+
+ ZERO_STRUCT(request);
+ ZERO_STRUCT(response);
+
+ info = talloc(NULL, struct wbcInterfaceDetails);
+ BAIL_ON_PTR_ERROR(info, wbc_status);
+
+ /* first the interface version */
+ wbc_status = wbcRequestResponse(WINBINDD_INTERFACE_VERSION, NULL, &response);
+ BAIL_ON_WBC_ERROR(wbc_status);
+ info->interface_version = response.data.interface_version;
+
+ /* then the samba version and the winbind separator */
+ wbc_status = wbcRequestResponse(WINBINDD_INFO, NULL, &response);
+ BAIL_ON_WBC_ERROR(wbc_status);
+
+ info->winbind_version = talloc_strdup(info,
+ response.data.info.samba_version);
+ BAIL_ON_PTR_ERROR(info->winbind_version, wbc_status);
+ info->winbind_separator = response.data.info.winbind_separator;
+
+ /* then the local netbios name */
+ wbc_status = wbcRequestResponse(WINBINDD_NETBIOS_NAME, NULL, &response);
+ BAIL_ON_WBC_ERROR(wbc_status);
+
+ info->netbios_name = talloc_strdup(info,
+ response.data.netbios_name);
+ BAIL_ON_PTR_ERROR(info->netbios_name, wbc_status);
+
+ /* then the local workgroup name */
+ wbc_status = wbcRequestResponse(WINBINDD_DOMAIN_NAME, NULL, &response);
+ BAIL_ON_WBC_ERROR(wbc_status);
+
+ info->netbios_domain = talloc_strdup(info,
+ response.data.domain_name);
+ BAIL_ON_PTR_ERROR(info->netbios_domain, wbc_status);
+
+ wbc_status = wbcDomainInfo(info->netbios_domain, &domain);
+ if (wbc_status == WBC_ERR_DOMAIN_NOT_FOUND) {
+ /* maybe it's a standalone server */
+ domain = NULL;
+ wbc_status = WBC_ERR_SUCCESS;
+ } else {
+ BAIL_ON_WBC_ERROR(wbc_status);
+ }
+
+ if (domain) {
+ info->dns_domain = talloc_strdup(info,
+ domain->dns_name);
+ wbcFreeMemory(domain);
+ BAIL_ON_PTR_ERROR(info->dns_domain, wbc_status);
+ } else {
+ info->dns_domain = NULL;
+ }
+
+ *_details = info;
+ info = NULL;
+
+ wbc_status = WBC_ERR_SUCCESS;
+
+done:
+ talloc_free(info);
+ return wbc_status;
+}
+
+
/** @brief Lookup the current status of a trusted domain
*
* @param domain Domain to query
diff --git a/source/nsswitch/libwbclient/wbclient.h b/source/nsswitch/libwbclient/wbclient.h
index e5047af..4a9a3b2 100644
--- a/source/nsswitch/libwbclient/wbclient.h
+++ b/source/nsswitch/libwbclient/wbclient.h
@@ -51,6 +51,19 @@ typedef enum _wbcErrType wbcErr;
const char *wbcErrorString(wbcErr error);
+/**
+ * @brief Some useful details about the running winbindd
+ *
+ **/
+struct wbcInterfaceDetails {
+ uint32_t interface_version;
+ const char *winbind_version;
+ char winbind_separator;
+ const char *netbios_name;
+ const char *netbios_domain;
+ const char *dns_domain;
+};
+
/*
* Data types used by the Winbind Client API
*/
@@ -277,6 +290,8 @@ wbcErr wbcStringToSid(const char *sid_string,
wbcErr wbcPing(void);
+wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **details);
+
/*
* Name/SID conversion
*/
diff --git a/source/nsswitch/wbinfo.c b/source/nsswitch/wbinfo.c
index d62e82a..6707f9d 100644
--- a/source/nsswitch/wbinfo.c
+++ b/source/nsswitch/wbinfo.c
@@ -27,21 +27,35 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_WINBIND
+static struct wbcInterfaceDetails *init_interface_details(void)
+{
+ wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+ static struct wbcInterfaceDetails *details;
+
+ if (details) {
+ return details;
+ }
+
+ wbc_status = wbcInterfaceDetails(&details);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ d_fprintf(stderr, "could not obtain winbind interface details!\n");
+ }
+
+ return details;
+}
+
static char winbind_separator_int(bool strict)
{
- struct winbindd_response response;
+ struct wbcInterfaceDetails *details;
static bool got_sep;
static char sep;
if (got_sep)
return sep;
- ZERO_STRUCT(response);
-
- /* Send off request */
+ details = init_interface_details();
- if (winbindd_request_response(WINBINDD_INFO, NULL, &response) !=
- NSS_STATUS_SUCCESS) {
+ if (!details) {
d_fprintf(stderr, "could not obtain winbind separator!\n");
if (strict) {
return 0;
@@ -50,7 +64,7 @@ static char winbind_separator_int(bool strict)
return *lp_winbind_separator();
}
- sep = response.data.info.winbind_separator;
+ sep = details->winbind_separator;
got_sep = true;
if (!sep) {
@@ -72,26 +86,18 @@ static char winbind_separator(void)
static const char *get_winbind_domain(void)
{
- wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
- struct wbcDomainInfo *dinfo = NULL;
- static fstring winbind_domain;
+ static struct wbcInterfaceDetails *details;
- ZERO_STRUCT(dinfo);
+ details = init_interface_details();
- wbc_status = wbcDomainInfo(".", &dinfo);
-
- if (!WBC_ERROR_IS_OK(wbc_status)) {
+ if (!details) {
d_fprintf(stderr, "could not obtain winbind domain name!\n");
/* HACK: (this module should not call lp_ functions) */
return lp_workgroup();
}
- fstrcpy(winbind_domain, dinfo->short_name);
-
- wbcFreeMemory(dinfo);
-
- return winbind_domain;
+ return details->netbios_domain;
}
/* Copy of parse_domain_user from winbindd_util.c. Parse a string of the
--
Samba Shared Repository
More information about the samba-cvs
mailing list