[SCM] Samba Shared Repository - branch v3-6-test updated

Jeremy Allison jra at samba.org
Wed Apr 13 16:10:34 MDT 2011


The branch, v3-6-test has been updated
       via  f0bfd05 Fix WAF build for sids2xids.
       via  50ce453 s3: Add a test for sid2xids
       via  ba00567 s3: Add some debug to winbindd_sids_to_xids
       via  b82f664 s3: Use wbcSidsToUnixIds in create_local_token
       via  813086f nsswitch: Add wbinfo --sids-to-unix-ids
       via  9d19ddd libwbclient: Add wbcSidsToUnixIds
       via  d6d33b7 s3: Export WINBINDD_SIDS_TO_XIDS via the winbind pipe
       via  fbdb9c2 s3: Add wbint_Sids2UnixIDs idl & implementation
       via  a1b061e s3: Make idmap_find_domain public
       via  6430e41 s3: Add is_domain_online
       via  ffe63d9 nsswitch: wbinfo --lookup-sids
       via  c932fae lib: Move next_token next to next_token_talloc
       via  0b192c0 libwbclient: Add wbcLookupSids
       via  d061260 s3: Add winbindd_lookupsids
       via  13fefb3 s3: Add wb_lookupsids
       via  b8d47ca s3: Add wbint_LookupSids
       via  88bc0a2 s3: Make parse_sidlist public
       via  f54916e s3: Simplify parse_sidlist
       via  050cd77 Add dom_sid_parse_endp
      from  0ec0aa8 s3:WHATSNEW.txt: remove the "strict allocate" default value

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


- Log -----------------------------------------------------------------
commit f0bfd05517f682743175a9a9c043f679a26804ce
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Apr 13 14:53:26 2011 -0700

    Fix WAF build for sids2xids.

commit 50ce453d2d51ab865964a0603e1da80a3f15dbf6
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Apr 11 17:26:35 2011 +0200

    s3: Add a test for sid2xids
    
    Signed-off-by: Jeremy Allison <jra at samba.org>

commit ba00567fb07152125a5c96762d00f65f3aa30d18
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Apr 12 13:32:20 2011 +0200

    s3: Add some debug to winbindd_sids_to_xids
    
    Signed-off-by: Jeremy Allison <jra at samba.org>

commit b82f664ff25c69071aa9df8776c6dd1802cdfde5
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Mar 23 18:31:38 2011 +0100

    s3: Use wbcSidsToUnixIds in create_local_token
    
    Signed-off-by: Jeremy Allison <jra at samba.org>

commit 813086f7085c46ac8533a999bd7956a9144dd3af
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Mar 23 18:31:17 2011 +0100

    nsswitch: Add wbinfo --sids-to-unix-ids
    
    Signed-off-by: Jeremy Allison <jra at samba.org>

commit 9d19ddd88c787323cd87463dbe02ac1098c1da79
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Mar 23 18:30:32 2011 +0100

    libwbclient: Add wbcSidsToUnixIds
    
    Signed-off-by: Jeremy Allison <jra at samba.org>

commit d6d33b7a5fcedb315bc3248a294402e804a8474c
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Mar 23 18:29:45 2011 +0100

    s3: Export WINBINDD_SIDS_TO_XIDS via the winbind pipe
    
    Signed-off-by: Jeremy Allison <jra at samba.org>

commit fbdb9c26b9d271e5ec1fa9f14b2eb2665c9b355c
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Mar 23 18:18:13 2011 +0100

    s3: Add wbint_Sids2UnixIDs idl & implementation
    
    Signed-off-by: Jeremy Allison <jra at samba.org>

commit a1b061e4002075177bb52f55c256551793777c9c
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Mar 23 18:15:34 2011 +0100

    s3: Make idmap_find_domain public
    
    Signed-off-by: Jeremy Allison <jra at samba.org>

commit 6430e41a1a86bb14a5c7558813659c7605e6fcea
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Mar 22 16:37:41 2011 +0100

    s3: Add is_domain_online
    
    Signed-off-by: Jeremy Allison <jra at samba.org>

commit ffe63d9346bab939bafd04400fc94b3803247b36
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Mar 9 16:36:20 2011 +0100

    nsswitch: wbinfo --lookup-sids
    
    Signed-off-by: Jeremy Allison <jra at samba.org>

commit c932faed8a61053fcfb63bc9915baa4bfa2678d4
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Mar 9 16:34:49 2011 +0100

    lib: Move next_token next to next_token_talloc
    
    Signed-off-by: Jeremy Allison <jra at samba.org>

commit 0b192c0a53966d823e0e6cf8c2ce3e489f58ff34
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Mar 8 18:01:21 2011 +0100

    libwbclient: Add wbcLookupSids
    
    Signed-off-by: Jeremy Allison <jra at samba.org>

commit d061260ab43e89999ce1f2e2216ee9bf8147bba3
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Mar 8 14:31:44 2011 +0100

    s3: Add winbindd_lookupsids
    
    Signed-off-by: Jeremy Allison <jra at samba.org>

commit 13fefb36c15364e4e46d4c696d03df786db495c0
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Mar 7 13:40:30 2011 +0100

    s3: Add wb_lookupsids
    
    Signed-off-by: Jeremy Allison <jra at samba.org>

commit b8d47ca8703b5bbacbbbcb8e4c651277683ef6da
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Mar 11 12:48:11 2011 +0100

    s3: Add wbint_LookupSids
    
    This will be called from wb_lookupsids to query remote DCs via lsa
    
    Signed-off-by: Jeremy Allison <jra at samba.org>

commit 88bc0a25ff3c4bd71563c2d89d768e5dac4c52bf
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Mar 8 14:23:15 2011 +0100

    s3: Make parse_sidlist public
    
    Signed-off-by: Jeremy Allison <jra at samba.org>

commit f54916e2db86e6d92f852439a74df44147f92515
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Mar 7 20:27:30 2011 +0100

    s3: Simplify parse_sidlist
    
    Signed-off-by: Jeremy Allison <jra at samba.org>

commit 050cd77018006cdd87f7e64f9d10e67e4b84f1ea
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Mar 7 20:16:13 2011 +0100

    Add dom_sid_parse_endp
    
    This returns a pointer to the first non-parsed character, along the lines of
    strtoul for example.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>

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

Summary of changes:
 lib/util/charset/util_unistr.c                    |   46 --
 lib/util/util.c                                   |   46 ++
 libcli/security/dom_sid.c                         |   14 +-
 libcli/security/dom_sid.h                         |    2 +
 librpc/idl/lsa.idl                                |    6 +-
 nsswitch/libwbclient/wbc_idmap.c                  |   93 ++++
 nsswitch/libwbclient/wbc_sid.c                    |  183 +++++++
 nsswitch/libwbclient/wbclient.h                   |   42 ++-
 nsswitch/wbinfo.c                                 |  141 +++++
 nsswitch/winbind_struct_protocol.h                |    4 +-
 source3/Makefile.in                               |    4 +
 source3/auth/auth_util.c                          |   26 +-
 source3/librpc/idl/wbint.idl                      |   25 +-
 source3/passdb/lookup_sid.c                       |  103 ++++
 source3/passdb/lookup_sid.h                       |    3 +
 source3/script/tests/test_wbinfo_sids2xids.sh     |   11 +
 source3/script/tests/test_wbinfo_sids2xids_int.py |   47 ++
 source3/selftest/tests.py                         |    4 +
 source3/winbindd/idmap.c                          |    2 +-
 source3/winbindd/wb_lookupsids.c                  |  601 +++++++++++++++++++++
 source3/winbindd/winbindd.c                       |    4 +
 source3/winbindd/winbindd_dual_srv.c              |  110 ++++
 source3/winbindd/winbindd_getsidaliases.c         |   42 --
 source3/winbindd/winbindd_lookupsids.c            |  145 +++++
 source3/winbindd/winbindd_proto.h                 |   32 ++
 source3/winbindd/winbindd_rpc.c                   |   98 ++++
 source3/winbindd/winbindd_sids_to_xids.c          |  306 +++++++++++
 source3/winbindd/winbindd_util.c                  |   36 ++
 source3/wscript_build                             |    5 +-
 29 files changed, 2077 insertions(+), 104 deletions(-)
 create mode 100755 source3/script/tests/test_wbinfo_sids2xids.sh
 create mode 100755 source3/script/tests/test_wbinfo_sids2xids_int.py
 create mode 100644 source3/winbindd/wb_lookupsids.c
 create mode 100644 source3/winbindd/winbindd_lookupsids.c
 create mode 100644 source3/winbindd/winbindd_sids_to_xids.c


Changeset truncated at 500 lines:

diff --git a/lib/util/charset/util_unistr.c b/lib/util/charset/util_unistr.c
index b6bfb29..760be77 100644
--- a/lib/util/charset/util_unistr.c
+++ b/lib/util/charset/util_unistr.c
@@ -61,52 +61,6 @@ _PUBLIC_ int strcasecmp_m(const char *s1, const char *s2)
 }
 
 /**
- * Get the next token from a string, return False if none found.
- * Handles double-quotes.
- * 
- * Based on a routine by GJC at VILLAGE.COM. 
- * Extensively modified by Andrew.Tridgell at anu.edu.au
- **/
-_PUBLIC_ bool next_token(const char **ptr,char *buff, const char *sep, size_t bufsize)
-{
-	const char *s;
-	bool quoted;
-	size_t len=1;
-
-	if (!ptr)
-		return false;
-
-	s = *ptr;
-
-	/* default to simple separators */
-	if (!sep)
-		sep = " \t\n\r";
-
-	/* find the first non sep char */
-	while (*s && strchr_m(sep,*s))
-		s++;
-	
-	/* nothing left? */
-	if (!*s)
-		return false;
-	
-	/* copy over the token */
-	for (quoted = false; len < bufsize && *s && (quoted || !strchr_m(sep,*s)); s++) {
-		if (*s == '\"') {
-			quoted = !quoted;
-		} else {
-			len++;
-			*buff++ = *s;
-		}
-	}
-	
-	*ptr = (*s) ? s+1 : s;  
-	*buff = 0;
-	
-	return true;
-}
-
-/**
  Case insensitive string compararison, length limited
 **/
 _PUBLIC_ int strncasecmp_m(const char *s1, const char *s2, size_t n)
diff --git a/lib/util/util.c b/lib/util/util.c
index 35ad49b..d4a936f 100644
--- a/lib/util/util.c
+++ b/lib/util/util.c
@@ -936,6 +936,52 @@ bool next_token_no_ltrim_talloc(TALLOC_CTX *ctx,
 	return next_token_internal_talloc(ctx, ptr, pp_buff, sep, false);
 }
 
+/**
+ * Get the next token from a string, return False if none found.
+ * Handles double-quotes.
+ *
+ * Based on a routine by GJC at VILLAGE.COM.
+ * Extensively modified by Andrew.Tridgell at anu.edu.au
+ **/
+_PUBLIC_ bool next_token(const char **ptr,char *buff, const char *sep, size_t bufsize)
+{
+	const char *s;
+	bool quoted;
+	size_t len=1;
+
+	if (!ptr)
+		return false;
+
+	s = *ptr;
+
+	/* default to simple separators */
+	if (!sep)
+		sep = " \t\n\r";
+
+	/* find the first non sep char */
+	while (*s && strchr_m(sep,*s))
+		s++;
+
+	/* nothing left? */
+	if (!*s)
+		return false;
+
+	/* copy over the token */
+	for (quoted = false; len < bufsize && *s && (quoted || !strchr_m(sep,*s)); s++) {
+		if (*s == '\"') {
+			quoted = !quoted;
+		} else {
+			len++;
+			*buff++ = *s;
+		}
+	}
+
+	*ptr = (*s) ? s+1 : s;
+	*buff = 0;
+
+	return true;
+}
+
 struct anonymous_shared_header {
 	union {
 		size_t length;
diff --git a/libcli/security/dom_sid.c b/libcli/security/dom_sid.c
index 809f20c..2f80a36 100644
--- a/libcli/security/dom_sid.c
+++ b/libcli/security/dom_sid.c
@@ -118,9 +118,11 @@ int dom_sid_compare_domain(const struct dom_sid *sid1,
 
 /*****************************************************************
  Convert a string to a SID. Returns True on success, False on fail.
+ Return the first character not parsed in endp.
 *****************************************************************/
 
-bool string_to_sid(struct dom_sid *sidout, const char *sidstr)
+bool dom_sid_parse_endp(const char *sidstr,struct dom_sid *sidout,
+			const char **endp)
 {
 	const char *p;
 	char *q;
@@ -197,6 +199,9 @@ bool string_to_sid(struct dom_sid *sidout, const char *sidstr)
 		}
 		q += 1;
 	}
+	if (endp != NULL) {
+		*endp = q;
+	}
 	return true;
 
 format_error:
@@ -204,9 +209,14 @@ format_error:
 	return false;
 }
 
+bool string_to_sid(struct dom_sid *sidout, const char *sidstr)
+{
+	return dom_sid_parse(sidstr, sidout);
+}
+
 bool dom_sid_parse(const char *sidstr, struct dom_sid *ret)
 {
-	return string_to_sid(ret, sidstr);
+	return dom_sid_parse_endp(sidstr, ret, NULL);
 }
 
 /*
diff --git a/libcli/security/dom_sid.h b/libcli/security/dom_sid.h
index 3493fab..04571c2 100644
--- a/libcli/security/dom_sid.h
+++ b/libcli/security/dom_sid.h
@@ -60,6 +60,8 @@ int dom_sid_compare_domain(const struct dom_sid *sid1,
 bool dom_sid_equal(const struct dom_sid *sid1, const struct dom_sid *sid2);
 bool sid_append_rid(struct dom_sid *sid, uint32_t rid);
 bool string_to_sid(struct dom_sid *sidout, const char *sidstr);
+bool dom_sid_parse_endp(const char *sidstr,struct dom_sid *sidout,
+			const char **endp);
 bool dom_sid_parse(const char *sidstr, struct dom_sid *ret);
 struct dom_sid *dom_sid_parse_talloc(TALLOC_CTX *mem_ctx, const char *sidstr);
 struct dom_sid *dom_sid_parse_length(TALLOC_CTX *mem_ctx, const DATA_BLOB *sid);
diff --git a/librpc/idl/lsa.idl b/librpc/idl/lsa.idl
index fc59cd0..c8aaa47 100644
--- a/librpc/idl/lsa.idl
+++ b/librpc/idl/lsa.idl
@@ -519,7 +519,7 @@ import "misc.idl", "security.idl";
 	} lsa_TransSidArray;
 
 	const int LSA_REF_DOMAIN_LIST_MULTIPLIER = 32;
-	typedef struct {
+	typedef [public] struct {
 		[range(0,1000)] uint32 count;
 		[size_is(count)] lsa_DomainInfo *domains;
 		uint32 max_size;
@@ -533,7 +533,7 @@ import "misc.idl", "security.idl";
 	 * Level 6: Like 4
 	 */
 
-	typedef enum {
+	typedef [public] enum {
 		LSA_LOOKUP_NAMES_ALL = 1,
 		LSA_LOOKUP_NAMES_DOMAINS_ONLY = 2,
 		LSA_LOOKUP_NAMES_PRIMARY_DOMAIN_ONLY = 3,
@@ -563,7 +563,7 @@ import "misc.idl", "security.idl";
 		uint32 sid_index;
 	} lsa_TranslatedName;
 
-	typedef struct {
+	typedef [public] struct {
 		[range(0,20480)] uint32 count;
 		[size_is(count)] lsa_TranslatedName *names;
 	} lsa_TransNameArray;
diff --git a/nsswitch/libwbclient/wbc_idmap.c b/nsswitch/libwbclient/wbc_idmap.c
index a77e7c0..ad3cfe6 100644
--- a/nsswitch/libwbclient/wbc_idmap.c
+++ b/nsswitch/libwbclient/wbc_idmap.c
@@ -23,6 +23,7 @@
 
 #include "replace.h"
 #include "libwbclient.h"
+#include "../winbind_client.h"
 
 /* Convert a Windows SID to a Unix uid, allocating an uid if needed */
 wbcErr wbcSidToUid(const struct wbcDomainSid *sid, uid_t *puid)
@@ -296,3 +297,95 @@ wbcErr wbcSetGidHwm(gid_t gid_hwm)
 {
 	return WBC_ERR_NOT_IMPLEMENTED;
 }
+
+/* Convert a list of SIDs */
+wbcErr wbcSidsToUnixIds(const struct wbcDomainSid *sids, uint32_t num_sids,
+			struct wbcUnixId *ids)
+{
+	struct winbindd_request request;
+	struct winbindd_response response;
+	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+	int buflen, extra_len;
+	uint32_t i;
+	char *sidlist, *p, *extra_data;
+
+	buflen = num_sids * (WBC_SID_STRING_BUFLEN + 1) + 1;
+
+	sidlist = (char *)malloc(buflen);
+	if (sidlist == NULL) {
+		return WBC_ERR_NO_MEMORY;
+	}
+
+	p = sidlist;
+
+	for (i=0; i<num_sids; i++) {
+		int remaining;
+		int len;
+
+		remaining = buflen - (p - sidlist);
+
+		len = wbcSidToStringBuf(&sids[i], p, remaining);
+		if (len > remaining) {
+			free(sidlist);
+			return WBC_ERR_UNKNOWN_FAILURE;
+		}
+
+		p += len;
+		*p++ = '\n';
+	}
+	*p++ = '\0';
+
+	ZERO_STRUCT(request);
+	ZERO_STRUCT(response);
+
+	request.extra_data.data = sidlist;
+	request.extra_len = p - sidlist;
+
+	wbc_status = wbcRequestResponse(WINBINDD_SIDS_TO_XIDS,
+					&request, &response);
+	free(sidlist);
+	if (!WBC_ERROR_IS_OK(wbc_status)) {
+		return wbc_status;
+	}
+
+	extra_len = response.length - sizeof(struct winbindd_response);
+	extra_data = (char *)response.extra_data.data;
+
+	if ((extra_len <= 0) || (extra_data[extra_len-1] != '\0')) {
+		goto wbc_err_invalid;
+	}
+
+	p = extra_data;
+
+	for (i=0; i<num_sids; i++) {
+		struct wbcUnixId *id = &ids[i];
+		char *q;
+
+		switch (p[0]) {
+		case 'U':
+			id->type = WBC_ID_TYPE_UID;
+			id->id.uid = strtoul(p+1, &q, 10);
+			break;
+		case 'G':
+			id->type = WBC_ID_TYPE_GID;
+			id->id.gid = strtoul(p+1, &q, 10);
+			break;
+		default:
+			id->type = WBC_ID_TYPE_NOT_SPECIFIED;
+			q = p;
+			break;
+		};
+		if (q[0] != '\n') {
+			goto wbc_err_invalid;
+		}
+		p = q+1;
+	}
+	wbc_status = WBC_ERR_SUCCESS;
+	goto done;
+
+wbc_err_invalid:
+	wbc_status = WBC_ERR_INVALID_RESPONSE;
+done:
+	winbindd_free_response(&response);
+	return wbc_status;
+}
diff --git a/nsswitch/libwbclient/wbc_sid.c b/nsswitch/libwbclient/wbc_sid.c
index 712c865..6df8a3c 100644
--- a/nsswitch/libwbclient/wbc_sid.c
+++ b/nsswitch/libwbclient/wbc_sid.c
@@ -279,6 +279,189 @@ done:
 	return wbc_status;
 }
 
+static void wbcDomainInfosDestructor(void *ptr)
+{
+	struct wbcDomainInfo *i = (struct wbcDomainInfo *)ptr;
+
+	while (i->short_name != NULL) {
+		wbcFreeMemory(i->short_name);
+		wbcFreeMemory(i->dns_name);
+		i += 1;
+	}
+}
+
+static void wbcTranslatedNamesDestructor(void *ptr)
+{
+	struct wbcTranslatedName *n = (struct wbcTranslatedName *)ptr;
+
+	while (n->name != NULL) {
+		free(n->name);
+		n += 1;
+	}
+}
+
+wbcErr wbcLookupSids(const struct wbcDomainSid *sids, int num_sids,
+		     struct wbcDomainInfo **pdomains, int *pnum_domains,
+		     struct wbcTranslatedName **pnames)
+{
+	struct winbindd_request request;
+	struct winbindd_response response;
+	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+	int buflen, i, extra_len, num_domains, num_names;
+	char *sidlist, *p, *q, *extra_data;
+	struct wbcDomainInfo *domains = NULL;
+	struct wbcTranslatedName *names = NULL;
+
+	buflen = num_sids * (WBC_SID_STRING_BUFLEN + 1) + 1;
+
+	sidlist = (char *)malloc(buflen);
+	if (sidlist == NULL) {
+		return WBC_ERR_NO_MEMORY;
+	}
+
+	p = sidlist;
+
+	for (i=0; i<num_sids; i++) {
+		int remaining;
+		int len;
+
+		remaining = buflen - (p - sidlist);
+
+		len = wbcSidToStringBuf(&sids[i], p, remaining);
+		if (len > remaining) {
+			free(sidlist);
+			return WBC_ERR_UNKNOWN_FAILURE;
+		}
+
+		p += len;
+		*p++ = '\n';
+	}
+	*p++ = '\0';
+
+	ZERO_STRUCT(request);
+	ZERO_STRUCT(response);
+
+	request.extra_data.data = sidlist;
+	request.extra_len = p - sidlist;
+
+	wbc_status = wbcRequestResponse(WINBINDD_LOOKUPSIDS,
+					&request, &response);
+	free(sidlist);
+	if (!WBC_ERROR_IS_OK(wbc_status)) {
+		return wbc_status;
+	}
+
+	extra_len = response.length - sizeof(struct winbindd_response);
+	extra_data = (char *)response.extra_data.data;
+
+	if ((extra_len <= 0) || (extra_data[extra_len-1] != '\0')) {
+		goto wbc_err_invalid;
+	}
+
+	p = extra_data;
+
+	num_domains = strtoul(p, &q, 10);
+	if (*q != '\n') {
+		goto wbc_err_invalid;
+	}
+	p = q+1;
+
+	domains = (struct wbcDomainInfo *)wbcAllocateMemory(
+		num_domains+1, sizeof(struct wbcDomainInfo),
+		wbcDomainInfosDestructor);
+	if (domains == NULL) {
+		wbc_status = WBC_ERR_NO_MEMORY;
+		goto fail;
+	}
+
+	for (i=0; i<num_domains; i++) {
+
+		q = strchr(p, ' ');
+		if (q == NULL) {
+			goto wbc_err_invalid;
+		}
+		*q = '\0';
+		wbc_status = wbcStringToSid(p, &domains[i].sid);
+		if (!WBC_ERROR_IS_OK(wbc_status)) {
+			goto fail;
+		}
+		p = q+1;
+
+		q = strchr(p, '\n');
+		if (q == NULL) {
+			goto wbc_err_invalid;
+		}
+		*q = '\0';
+		domains[i].short_name = wbcStrDup(p);
+		if (domains[i].short_name == NULL) {
+			wbc_status = WBC_ERR_NO_MEMORY;
+			goto fail;
+		}
+		p = q+1;
+	}
+
+	num_names = strtoul(p, &q, 10);
+	if (*q != '\n') {
+		goto wbc_err_invalid;
+	}
+	p = q+1;
+
+	if (num_names != num_sids) {
+		goto wbc_err_invalid;
+	}
+
+	names = (struct wbcTranslatedName *)wbcAllocateMemory(
+		num_names+1, sizeof(struct wbcTranslatedName),
+		wbcTranslatedNamesDestructor);
+	if (names == NULL) {
+		wbc_status = WBC_ERR_NO_MEMORY;
+		goto fail;
+	}
+
+	for (i=0; i<num_names; i++) {
+
+		names[i].domain_index = strtoul(p, &q, 10);
+		if (*q != ' ') {
+			goto wbc_err_invalid;
+		}
+		p = q+1;
+
+		names[i].type = strtoul(p, &q, 10);
+		if (*q != ' ') {
+			goto wbc_err_invalid;
+		}
+		p = q+1;
+
+		q = strchr(p, '\n');
+		if (q == NULL) {
+			goto wbc_err_invalid;
+		}
+		*q = '\0';
+		names[i].name = wbcStrDup(p);
+		if (names[i].name == NULL) {
+			wbc_status = WBC_ERR_NO_MEMORY;
+			goto fail;
+		}
+		p = q+1;
+	}
+	if (*p != '\0') {
+		goto wbc_err_invalid;
+	}
+
+	*pdomains = domains;
+	*pnames = names;
+	winbindd_free_response(&response);
+	return WBC_ERR_SUCCESS;
+
+wbc_err_invalid:
+	wbc_status = WBC_ERR_INVALID_RESPONSE;
+fail:
+	winbindd_free_response(&response);
+	wbcFreeMemory(domains);
+	wbcFreeMemory(names);
+	return wbc_status;
+}
+


-- 
Samba Shared Repository


More information about the samba-cvs mailing list