svn commit: samba r5659 - in trunk/source/nsswitch: .

vlendec at samba.org vlendec at samba.org
Sat Mar 5 09:46:34 GMT 2005


Author: vlendec
Date: 2005-03-05 09:46:34 +0000 (Sat, 05 Mar 2005)
New Revision: 5659

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

Log:
Merge r5654. Meanwhile fix the trustdom encoding on the pipe. This just
happened to work for a single trusted domain.

Volker
Modified:
   trunk/source/nsswitch/wbinfo.c
   trunk/source/nsswitch/winbindd_misc.c
   trunk/source/nsswitch/winbindd_rpc.c
   trunk/source/nsswitch/winbindd_util.c


Changeset:
Modified: trunk/source/nsswitch/wbinfo.c
===================================================================
--- trunk/source/nsswitch/wbinfo.c	2005-03-05 08:12:56 UTC (rev 5658)
+++ trunk/source/nsswitch/wbinfo.c	2005-03-05 09:46:34 UTC (rev 5659)
@@ -224,7 +224,6 @@
 static BOOL wbinfo_list_domains(void)
 {
 	struct winbindd_response response;
-	fstring name;
 
 	ZERO_STRUCT(response);
 
@@ -238,9 +237,19 @@
 
 	if (response.extra_data) {
 		const char *extra_data = (char *)response.extra_data;
+		fstring name;
+		char *p;
 
-		while(next_token(&extra_data, name, ",", sizeof(fstring)))
+		while(next_token(&extra_data, name, "\n", sizeof(fstring))) {
+			p = strchr(name, '\\');
+			if (p == 0) {
+				d_printf("Got invalid response: %s\n",
+					 extra_data);
+				return False;
+			}
+			*p = 0;
 			d_printf("%s\n", name);
+		}
 
 		SAFE_FREE(response.extra_data);
 	}

Modified: trunk/source/nsswitch/winbindd_misc.c
===================================================================
--- trunk/source/nsswitch/winbindd_misc.c	2005-03-05 08:12:56 UTC (rev 5658)
+++ trunk/source/nsswitch/winbindd_misc.c	2005-03-05 09:46:34 UTC (rev 5659)
@@ -162,8 +162,8 @@
 	extra_data = talloc_strdup(state->mem_ctx, "");
 
 	if (num_domains > 0)
-		extra_data = talloc_asprintf(state->mem_ctx, "%s\\%s\n",
-					     names[0],
+		extra_data = talloc_asprintf(state->mem_ctx, "%s\\%s\\%s",
+					     names[0], alt_names[0],
 					     sid_string_static(&sids[0]));
 
 	for (i=1; i<num_domains; i++)

Modified: trunk/source/nsswitch/winbindd_rpc.c
===================================================================
--- trunk/source/nsswitch/winbindd_rpc.c	2005-03-05 08:12:56 UTC (rev 5658)
+++ trunk/source/nsswitch/winbindd_rpc.c	2005-03-05 09:46:34 UTC (rev 5659)
@@ -829,14 +829,50 @@
 	DEBUG(3,("rpc: trusted_domains\n"));
 
 	*num_domains = 0;
+	*names = NULL;
 	*alt_names = NULL;
+	*dom_sids = NULL;
 
 	result = cm_connect_lsa(domain, mem_ctx, &cli, &lsa_policy);
 	if (!NT_STATUS_IS_OK(result))
 		return result;
 
-	return rpccli_lsa_enum_trust_dom(cli, mem_ctx, &lsa_policy, &enum_ctx,
-					 num_domains, names, dom_sids);
+	result = STATUS_MORE_ENTRIES;
+
+	while (NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)) {
+		uint32 start_idx, num;
+		char **tmp_names;
+		DOM_SID *tmp_sids;
+		int i;
+
+		result = rpccli_lsa_enum_trust_dom(cli, mem_ctx,
+						   &lsa_policy, &enum_ctx,
+						   &num, &tmp_names,
+						   &tmp_sids);
+
+		if (!NT_STATUS_IS_OK(result) &&
+		    !NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES))
+			break;
+
+		start_idx = *num_domains;
+		*num_domains += num;
+		*names = TALLOC_REALLOC_ARRAY(mem_ctx, *names,
+					      char *, *num_domains);
+		*dom_sids = TALLOC_REALLOC_ARRAY(mem_ctx, *dom_sids,
+						 DOM_SID, *num_domains);
+		*alt_names = TALLOC_REALLOC_ARRAY(mem_ctx, *alt_names,
+						 char *, *num_domains);
+		if ((*names == NULL) || (*dom_sids == NULL) ||
+		    (*alt_names == NULL))
+			return NT_STATUS_NO_MEMORY;
+
+		for (i=0; i<num; i++) {
+			(*names)[start_idx+i] = tmp_names[i];
+			(*dom_sids)[start_idx+i] = tmp_sids[i];
+			(*alt_names)[start_idx+i] = talloc_strdup(mem_ctx, "");
+		}
+	}
+	return result;
 }
 
 /* find the domain sid for a domain */

Modified: trunk/source/nsswitch/winbindd_util.c
===================================================================
--- trunk/source/nsswitch/winbindd_util.c	2005-03-05 08:12:56 UTC (rev 5658)
+++ trunk/source/nsswitch/winbindd_util.c	2005-03-05 09:46:34 UTC (rev 5659)
@@ -246,10 +246,19 @@
 	p = response->extra_data;
 
 	while ((p != NULL) && (*p != '\0')) {
-		char *sidstr;
+		char *sidstr, *alt_name;
 		DOM_SID sid;
 
-		sidstr = strchr(p, '\\');
+		alt_name = strchr(p, '\\');
+		if (alt_name == NULL) {
+			DEBUG(0, ("Got invalid trustdom response\n"));
+			break;
+		}
+
+		*alt_name = '\0';
+		alt_name += 1;
+
+		sidstr = strchr(alt_name, '\\');
 		if (sidstr == NULL) {
 			DEBUG(0, ("Got invalid trustdom response\n"));
 			break;
@@ -265,7 +274,8 @@
 
 		if (find_domain_from_sid_noinit(&sid) == NULL) {
 			struct winbindd_domain *domain;
-			domain = add_trusted_domain(p, NULL, &cache_methods,
+			domain = add_trusted_domain(p, alt_name,
+						    &cache_methods,
 						    &sid);
 			setup_domain_child(&domain->child);
 		}



More information about the samba-cvs mailing list