svn commit: samba r15487 - in branches/SAMBA_4_0/source/libnet: .

mimir at samba.org mimir at samba.org
Sun May 7 12:51:53 GMT 2006


Author: mimir
Date: 2006-05-07 12:51:53 +0000 (Sun, 07 May 2006)
New Revision: 15487

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

Log:
More comments and a few minor changes (not even fixes).


rafal


Modified:
   branches/SAMBA_4_0/source/libnet/libnet_rpc.c


Changeset:
Modified: branches/SAMBA_4_0/source/libnet/libnet_rpc.c
===================================================================
--- branches/SAMBA_4_0/source/libnet/libnet_rpc.c	2006-05-07 11:15:52 UTC (rev 15486)
+++ branches/SAMBA_4_0/source/libnet/libnet_rpc.c	2006-05-07 12:51:53 UTC (rev 15487)
@@ -70,13 +70,18 @@
 	case LIBNET_RPC_CONNECT_DC:
 	case LIBNET_RPC_CONNECT_PDC:
 	case LIBNET_RPC_CONNECT_SERVER:
-	case LIBNET_RPC_CONNECT_DC_INFO:
 		s->binding = talloc_asprintf(s, "ncacn_np:%s", r->in.name);
 		break;
 
 	case LIBNET_RPC_CONNECT_BINDING:
 		s->binding = talloc_strdup(s, r->in.binding);
 		break;
+
+	case LIBNET_RPC_CONNECT_DC_INFO:
+		/* this should never happen - DC_INFO level has a separate
+		   composite function */
+		composite_error(c, NT_STATUS_INVALID_LEVEL);
+		return c;
 	}
 
 	/* connect to remote dcerpc pipe */
@@ -346,6 +351,7 @@
 	struct composite_context *c, *conn_req;
 	struct rpc_connect_dci_state *s;
 
+	/* composite context allocation and setup */
 	c = talloc_zero(mem_ctx, struct composite_context);
 	if (c == NULL) return NULL;
 
@@ -369,6 +375,7 @@
 		s->rpc_conn.level      = LIBNET_RPC_CONNECT_BINDING;
 	}
 
+	/* we need to query information on lsarpc interface first */
 	s->rpc_conn.in.dcerpc_iface    = &dcerpc_table_lsarpc;
 	
 	/* request connection to the lsa pipe on the pdc */
@@ -376,7 +383,6 @@
 	if (composite_nomem(c, conn_req)) return c;
 
 	composite_continue(c, conn_req, continue_dci_rpc_connect, c);
-
 	return c;
 }
 
@@ -400,21 +406,22 @@
 		return;
 	}
 
+	/* prepare to open a policy handle on lsa pipe */
 	s->lsa_pipe = s->ctx->pipe;
 	
-	s->qos.len = 0;
+	s->qos.len                 = 0;
 	s->qos.impersonation_level = 2;
-	s->qos.context_mode = 1;
-	s->qos.effective_only = 0;
+	s->qos.context_mode        = 1;
+	s->qos.effective_only      = 0;
 
 	s->attr.sec_qos = &s->qos;
 
-	s->lsa_open_policy.in.attr = &s->attr;
+	s->lsa_open_policy.in.attr        = &s->attr;
 	s->lsa_open_policy.in.system_name = talloc_asprintf(c, "\\");
 	if (composite_nomem(s->lsa_open_policy.in.system_name, c)) return;
 
 	s->lsa_open_policy.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
-	s->lsa_open_policy.out.handle = &s->lsa_handle;
+	s->lsa_open_policy.out.handle     = &s->lsa_handle;
 
 	open_pol_req = dcerpc_lsa_OpenPolicy2_send(s->lsa_pipe, c, &s->lsa_open_policy);
 	if (composite_nomem(open_pol_req, c)) return;
@@ -442,6 +449,7 @@
 		return;
 	}
 
+	/* query lsa info for dns domain name and guid */
 	s->lsa_query_info2.in.handle = &s->lsa_handle;
 	s->lsa_query_info2.in.level  = LSA_POLICY_INFO_DNS;
 
@@ -466,6 +474,11 @@
 	s = talloc_get_type(c->private_data, struct rpc_connect_dci_state);
 
 	c->status = dcerpc_ndr_request_recv(req);
+	
+	/* In case of error just null the realm and guid and proceed
+	   to the next step. After all, it doesn't have to be AD domain
+	   controller we talking to - NT-style PDC also counts */
+
 	if (NT_STATUS_EQUAL(c->status, NT_STATUS_NET_WRITE_FAULT)) {
 		s->r.out.realm = NULL;
 		s->r.out.guid  = NULL;
@@ -479,6 +492,8 @@
 			return;
 		}
 
+		/* Copy the dns domain name and guid from the query result */
+
 		/* this should actually be a conversion from lsa_StringLarge */
 		s->r.out.realm = s->lsa_query_info2.out.info->dns.dns_domain.string;
 		s->r.out.guid  = talloc(c, struct GUID);
@@ -489,6 +504,7 @@
 		*s->r.out.guid = s->lsa_query_info2.out.info->dns.domain_guid;
 	}
 
+	/* query lsa info for domain name and sid */
 	s->lsa_query_info.in.handle = &s->lsa_handle;
 	s->lsa_query_info.in.level  = LSA_POLICY_INFO_DOMAIN;
 
@@ -520,9 +536,12 @@
 		return;
 	}
 
+	/* Copy the domain name and sid from the query result */
 	s->r.out.domain_sid  = s->lsa_query_info.out.info->domain.sid;
 	s->r.out.domain_name = s->lsa_query_info.out.info->domain.name.string;
 
+
+	/* prepare to get endpoint mapping for the requested interface */
 	s->final_binding = talloc(s, struct dcerpc_binding);
 	if (composite_nomem(s->final_binding, c)) return;
 	
@@ -540,7 +559,8 @@
 
 /*
   Step 6 of RpcConnectDCInfo: Receive endpoint mapping and create secondary
-  lsa pipe connection derived from already used pipe
+  rpc connection derived from already used pipe but connected to the requested
+  one (as specified in libnet_RpcConnect structure)
 */
 static void continue_epm_map_binding(struct composite_context *ctx)
 {
@@ -558,7 +578,8 @@
 		composite_error(c, c->status);
 		return;
 	}
-	
+
+	/* create secondary connection derived from lsa pipe */
 	sec_conn_req = dcerpc_secondary_connection_send(s->lsa_pipe, s->final_binding);
 	if (composite_nomem(sec_conn_req, c)) return;
 
@@ -646,13 +667,10 @@
 
 	switch (r->level) {
 	case LIBNET_RPC_CONNECT_SERVER:
+	case LIBNET_RPC_CONNECT_BINDING:
 		c = libnet_RpcConnectSrv_send(ctx, mem_ctx, r);
 		break;
 
-	case LIBNET_RPC_CONNECT_BINDING:
-		c = libnet_RpcConnectSrv_send(ctx, mem_ctx, r);
-		break;
-			
 	case LIBNET_RPC_CONNECT_PDC:
 	case LIBNET_RPC_CONNECT_DC:
 		c = libnet_RpcConnectDC_send(ctx, mem_ctx, r);



More information about the samba-cvs mailing list