[SCM] Samba Shared Repository - branch v3-3-test updated - release-3-2-0pre2-2552-gfe8f9e4

Michael Adam obnox at samba.org
Wed May 21 21:38:50 GMT 2008


The branch, v3-3-test has been updated
       via  fe8f9e427af3eb42d63fde96c4fe20a255facb95 (commit)
       via  a0bdd56c75ca6f6c6068995647c0dc1ba89aef12 (commit)
       via  24ac40518f79fd480baaedc1d42f3b6fe8ea1c94 (commit)
       via  be5d54a363a57113e494202a2d22dd9bbcf13b41 (commit)
       via  2ff908a902ec857856518eaddb5246dd5067063d (commit)
       via  8ae39c1339758795a91c6a168e210357e7f29eae (commit)
      from  c81d5537420ea305d995eaedb68e65f4864b331c (commit)

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


- Log -----------------------------------------------------------------
commit fe8f9e427af3eb42d63fde96c4fe20a255facb95
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Apr 24 22:45:28 2008 +0200

    Compile endpoint mapper pidl output

commit a0bdd56c75ca6f6c6068995647c0dc1ba89aef12
Author: Volker Lendecke <vl at samba.org>
Date:   Tue May 20 18:25:42 2008 +0200

    rpc_client: add a destructor to close the socket for pipes over tcp.
    
    used in rpc_pipe_open_tcp() and rpc_pipe_open_ncalrpc().

commit 24ac40518f79fd480baaedc1d42f3b6fe8ea1c94
Author: Volker Lendecke <vl at samba.org>
Date:   Mon May 12 23:37:07 2008 +0200

    Add client support for NCACN_UNIX_STREAM

commit be5d54a363a57113e494202a2d22dd9bbcf13b41
Author: Volker Lendecke <vl at samba.org>
Date:   Mon May 12 23:35:27 2008 +0200

    rpccli_schannel_bind_data only needs the schannel key

commit 2ff908a902ec857856518eaddb5246dd5067063d
Author: Volker Lendecke <vl at samba.org>
Date:   Mon May 12 17:07:37 2008 +0200

    Rename rpc_pipe_client.tcp.sock to rpc_pipe_client.sock.fd

commit 8ae39c1339758795a91c6a168e210357e7f29eae
Author: Volker Lendecke <vl at samba.org>
Date:   Mon May 12 17:05:42 2008 +0200

    Fix a comment

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

Summary of changes:
 source/Makefile.in           |    2 +
 source/include/client.h      |    4 +-
 source/include/proto.h       |    5 ++-
 source/include/rpc_client.h  |    1 +
 source/include/smb.h         |    5 ++-
 source/rpc_client/cli_pipe.c |  123 ++++++++++++++++++++++++++++++++++++-----
 source/rpc_parse/parse_rpc.c |    1 +
 7 files changed, 122 insertions(+), 19 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/Makefile.in b/source/Makefile.in
index 21b4b1c..6899faf 100644
--- a/source/Makefile.in
+++ b/source/Makefile.in
@@ -291,6 +291,7 @@ LIBNDR_GEN_OBJ = librpc/gen_ndr/ndr_wkssvc.o \
 		 librpc/gen_ndr/ndr_dssetup.o \
 		 librpc/gen_ndr/ndr_notify.o \
 		 librpc/gen_ndr/ndr_xattr.o \
+		 librpc/gen_ndr/ndr_epmapper.o \
 		 librpc/gen_ndr/ndr_ntsvcs.o
 
 RPC_PARSE_OBJ0 = rpc_parse/parse_prs.o rpc_parse/parse_misc.o
@@ -467,6 +468,7 @@ LIBMSRPC_GEN_OBJ = librpc/gen_ndr/cli_lsa.o \
 		   librpc/gen_ndr/cli_samr.o \
 		   librpc/gen_ndr/cli_dssetup.o \
 		   librpc/gen_ndr/cli_ntsvcs.o \
+		   librpc/gen_ndr/cli_epmapper.o \
 		   $(LIBNDR_GEN_OBJ) \
 		   $(RPCCLIENT_NDR_OBJ)
 
diff --git a/source/include/client.h b/source/include/client.h
index 7d76b8e..c5882e3 100644
--- a/source/include/client.h
+++ b/source/include/client.h
@@ -72,8 +72,8 @@ struct rpc_pipe_client {
 			uint16 fnum;
 		} np;
 		struct {
-			int sock;
-		} tcp;
+			int fd;
+		} sock;
 	} trans ;
 
 	const struct ndr_syntax_id *abstract_syntax;
diff --git a/source/include/proto.h b/source/include/proto.h
index a0354a3..f76e43a 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -7053,7 +7053,7 @@ NTSTATUS rpccli_ntlmssp_bind_data(TALLOC_CTX *mem_ctx,
 				  struct cli_pipe_auth_data **presult);
 NTSTATUS rpccli_schannel_bind_data(TALLOC_CTX *mem_ctx, const char *domain,
 				   enum pipe_auth_level auth_level,
-				   const struct dcinfo *pdc,
+				   const uint8_t sess_key[16],
 				   struct cli_pipe_auth_data **presult);
 NTSTATUS rpccli_kerberos_bind_data(TALLOC_CTX *mem_ctx,
 				   enum pipe_auth_level auth_level,
@@ -7065,6 +7065,9 @@ NTSTATUS rpc_pipe_open_tcp(TALLOC_CTX *mem_ctx, const char *host,
 			   uint16_t port,
 			   const struct ndr_syntax_id *abstract_syntax,
 			   struct rpc_pipe_client **presult);
+NTSTATUS rpc_pipe_open_ncalrpc(TALLOC_CTX *mem_ctx, const char *socket_path,
+			       const struct ndr_syntax_id *abstract_syntax,
+			       struct rpc_pipe_client **presult);
 struct rpc_pipe_client *cli_rpc_pipe_open_noauth(struct cli_state *cli, int pipe_idx, NTSTATUS *perr);
 struct rpc_pipe_client *cli_rpc_pipe_open_ntlmssp(struct cli_state *cli,
 						int pipe_idx,
diff --git a/source/include/rpc_client.h b/source/include/rpc_client.h
index ce0c932..4d1b1a7 100644
--- a/source/include/rpc_client.h
+++ b/source/include/rpc_client.h
@@ -35,6 +35,7 @@
 #include "librpc/gen_ndr/cli_netlogon.h"
 #include "librpc/gen_ndr/cli_dssetup.h"
 #include "librpc/gen_ndr/cli_ntsvcs.h"
+#include "librpc/gen_ndr/cli_epmapper.h"
 
 #define prs_init_empty( _ps_, _ctx_, _io_ ) (void) prs_init((_ps_), 0, (_ctx_), (_io_))
 
diff --git a/source/include/smb.h b/source/include/smb.h
index d6b026d..0215104 100644
--- a/source/include/smb.h
+++ b/source/include/smb.h
@@ -189,6 +189,7 @@ typedef uint32 codepoint_t;
 #define PIPE_EPM      "\\PIPE\\epmapper"
 #define PIPE_SVCCTL   "\\PIPE\\svcctl"
 #define PIPE_EVENTLOG "\\PIPE\\eventlog"
+#define PIPE_EPMAPPER "\\PIPE\\epmapper"
 
 #define PIPE_NETLOGON_PLAIN "\\NETLOGON"
 
@@ -206,7 +207,8 @@ typedef uint32 codepoint_t;
 #define PI_SVCCTL		11
 #define PI_EVENTLOG 		12
 #define PI_NTSVCS		13
-#define PI_MAX_PIPES		14
+#define PI_EPMAPPER		14
+#define PI_MAX_PIPES		15
 
 /* 64 bit time (100usec) since ????? - cifs6.txt, section 3.5, page 30 */
 typedef uint64_t NTTIME;
@@ -307,6 +309,7 @@ extern const DATA_BLOB data_blob_null;
 #include "librpc/gen_ndr/netlogon.h"
 #include "librpc/gen_ndr/samr.h"
 #include "librpc/gen_ndr/dssetup.h"
+#include "librpc/gen_ndr/epmapper.h"
 #include "librpc/gen_ndr/libnet_join.h"
 #include "librpc/gen_ndr/krb5pac.h"
 #include "librpc/gen_ndr/ntsvcs.h"
diff --git a/source/rpc_client/cli_pipe.c b/source/rpc_client/cli_pipe.c
index 8c801e5..9908c69 100644
--- a/source/rpc_client/cli_pipe.c
+++ b/source/rpc_client/cli_pipe.c
@@ -63,10 +63,24 @@ static int map_pipe_auth_type_to_rpc_auth_type(enum pipe_auth_type auth_type)
 static char *rpccli_pipe_txt(TALLOC_CTX *mem_ctx, struct rpc_pipe_client *cli)
 {
 	char *result;
-	result = talloc_asprintf(mem_ctx, "host %s, pipe %s, fnum 0x%x",
-				 cli->desthost,
-				 cli->trans.np.pipe_name,
-				 (unsigned int)(cli->trans.np.fnum));
+
+	switch (cli->transport_type) {
+	case NCACN_NP:
+		result = talloc_asprintf(mem_ctx, "host %s, pipe %s, "
+					 "fnum 0x%x",
+					 cli->desthost,
+					 cli->trans.np.pipe_name,
+					 (unsigned int)(cli->trans.np.fnum));
+		break;
+	case NCACN_IP_TCP:
+	case NCACN_UNIX_STREAM:
+		result = talloc_asprintf(mem_ctx, "host %s, fd %d",
+					 cli->desthost, cli->trans.sock.fd);
+		break;
+	default:
+		result = talloc_asprintf(mem_ctx, "host %s", cli->desthost);
+		break;
+	}
 	SMB_ASSERT(result != NULL);
 	return result;
 }
@@ -183,8 +197,9 @@ static NTSTATUS rpc_read(struct rpc_pipe_client *cli,
 					     &num_read);
 			break;
 		case NCACN_IP_TCP:
+		case NCACN_UNIX_STREAM:
 			status = NT_STATUS_OK;
-			num_read = sys_read(cli->trans.tcp.sock, pdata, size);
+			num_read = sys_read(cli->trans.sock.fd, pdata, size);
 			if (num_read == -1) {
 				status = map_nt_error_from_unix(errno);
 			}
@@ -828,9 +843,10 @@ static NTSTATUS rpc_api_pipe(struct rpc_pipe_client *cli,
 		break;
 	}
 	case NCACN_IP_TCP:
+	case NCACN_UNIX_STREAM:
 	{
 		ssize_t nwritten, nread;
-		nwritten = write_data(cli->trans.tcp.sock, pdata, data_len);
+		nwritten = write_data(cli->trans.sock.fd, pdata, data_len);
 		if (nwritten == -1) {
 			ret = map_nt_error_from_unix(errno);
 			DEBUG(0, ("rpc_api_pipe: write_data returned %s\n",
@@ -842,7 +858,7 @@ static NTSTATUS rpc_api_pipe(struct rpc_pipe_client *cli,
 		if (prdata == NULL) {
 			return NT_STATUS_NO_MEMORY;
 		}
-		nread = sys_read(cli->trans.tcp.sock, prdata, 1);
+		nread = sys_read(cli->trans.sock.fd, prdata, 1);
 		if (nread == 0) {
 			SAFE_FREE(prdata);
 		}
@@ -1651,8 +1667,9 @@ NTSTATUS rpc_api_pipe_req(struct rpc_pipe_client *cli,
 				}
 				break;
 			case NCACN_IP_TCP:
+			case NCACN_UNIX_STREAM:
 				num_written = write_data(
-					cli->trans.tcp.sock,
+					cli->trans.sock.fd,
 					prs_data_p(&outgoing_pdu),
 					(size_t)hdr.frag_len);
 				if (num_written != hdr.frag_len) {
@@ -1885,7 +1902,8 @@ static NTSTATUS rpc_finish_auth3_bind(struct rpc_pipe_client *cli,
 			nt_status = cli_get_nt_error(cli->trans.np.cli);
 		}
 	case NCACN_IP_TCP:
-		ret = write_data(cli->trans.tcp.sock, prs_data_p(&rpc_out),
+	case NCACN_UNIX_STREAM:
+		ret = write_data(cli->trans.sock.fd, prs_data_p(&rpc_out),
 				 (size_t)prs_offset(&rpc_out));
 		if (ret != (ssize_t)prs_offset(&rpc_out)) {
 			nt_status = map_nt_error_from_unix(errno);
@@ -2383,7 +2401,7 @@ NTSTATUS rpccli_ntlmssp_bind_data(TALLOC_CTX *mem_ctx,
 
 NTSTATUS rpccli_schannel_bind_data(TALLOC_CTX *mem_ctx, const char *domain,
 				   enum pipe_auth_level auth_level,
-				   const struct dcinfo *pdc,
+				   const uint8_t sess_key[16],
 				   struct cli_pipe_auth_data **presult)
 {
 	struct cli_pipe_auth_data *result;
@@ -2408,7 +2426,8 @@ NTSTATUS rpccli_schannel_bind_data(TALLOC_CTX *mem_ctx, const char *domain,
 		goto fail;
 	}
 
-	memcpy(result->a_u.schannel_auth->sess_key, pdc->sess_key, 16);
+	memcpy(result->a_u.schannel_auth->sess_key, sess_key,
+	       sizeof(result->a_u.schannel_auth->sess_key));
 	result->a_u.schannel_auth->seq_num = 0;
 
 	*presult = result;
@@ -2484,8 +2503,14 @@ NTSTATUS rpccli_kerberos_bind_data(TALLOC_CTX *mem_ctx,
 #endif
 }
 
+static int rpc_pipe_sock_destructor(struct rpc_pipe_client *p)
+{
+	close(p->trans.sock.fd);
+	return 0;
+}
+
 /********************************************************************
- Create a named pipe struct, connecting to a tcp port
+ Create a rpc pipe client struct, connecting to a tcp port
  ********************************************************************/
 NTSTATUS rpc_pipe_open_tcp(TALLOC_CTX *mem_ctx, const char *host,
 			   uint16_t port,
@@ -2522,12 +2547,80 @@ NTSTATUS rpc_pipe_open_tcp(TALLOC_CTX *mem_ctx, const char *host,
 		goto fail;
 	}
 
-	result->trans.tcp.sock = open_socket_out(SOCK_STREAM, &addr, port, 60);
-	if (result->trans.tcp.sock == -1) {
+	result->trans.sock.fd = open_socket_out(SOCK_STREAM, &addr, port, 60);
+	if (result->trans.sock.fd == -1) {
 		status = map_nt_error_from_unix(errno);
 		goto fail;
 	}
 
+	talloc_set_destructor(result, rpc_pipe_sock_destructor);
+
+	*presult = result;
+	return NT_STATUS_OK;
+
+ fail:
+	TALLOC_FREE(result);
+	return status;
+}
+
+/********************************************************************
+ Create a rpc pipe client struct, connecting to a unix domain socket
+ ********************************************************************/
+NTSTATUS rpc_pipe_open_ncalrpc(TALLOC_CTX *mem_ctx, const char *socket_path,
+			       const struct ndr_syntax_id *abstract_syntax,
+			       struct rpc_pipe_client **presult)
+{
+	struct rpc_pipe_client *result;
+	struct sockaddr_un addr;
+	NTSTATUS status;
+
+	result = talloc(mem_ctx, struct rpc_pipe_client);
+	if (result == NULL) {
+		return NT_STATUS_NO_MEMORY;
+	}
+
+	result->transport_type = NCACN_UNIX_STREAM;
+
+	result->abstract_syntax = abstract_syntax;
+	result->transfer_syntax = &ndr_transfer_syntax;
+
+	result->desthost = get_myname(result);
+	result->srv_name_slash = talloc_asprintf_strupper_m(
+		result, "\\\\%s", result->desthost);
+	if ((result->desthost == NULL) || (result->srv_name_slash == NULL)) {
+		status = NT_STATUS_NO_MEMORY;
+		goto fail;
+	}
+
+	result->max_xmit_frag = RPC_MAX_PDU_FRAG_LEN;
+	result->max_recv_frag = RPC_MAX_PDU_FRAG_LEN;
+
+	result->trans.sock.fd = socket(AF_UNIX, SOCK_STREAM, 0);
+	if (result->trans.sock.fd == -1) {
+		status = map_nt_error_from_unix(errno);
+		goto fail;
+	}
+
+	talloc_set_destructor(result, rpc_pipe_sock_destructor);
+
+	result->dc = TALLOC_ZERO_P(result, struct dcinfo);
+	if (result->dc == NULL) {
+		status = NT_STATUS_NO_MEMORY;
+		goto fail;
+	}
+
+	ZERO_STRUCT(addr);
+	addr.sun_family = AF_UNIX;
+	strncpy(addr.sun_path, socket_path, sizeof(addr.sun_path));
+
+	if (sys_connect(result->trans.sock.fd,
+			(struct sockaddr *)&addr) == -1) {
+		DEBUG(0, ("connect(%s) failed: %s\n", socket_path,
+			  strerror(errno)));
+		close(result->trans.sock.fd);
+		return map_nt_error_from_unix(errno);
+	}
+
 	*presult = result;
 	return NT_STATUS_OK;
 
@@ -2880,7 +2973,7 @@ struct rpc_pipe_client *cli_rpc_pipe_open_schannel_with_key(struct cli_state *cl
 	}
 
 	*perr = rpccli_schannel_bind_data(result, domain, auth_level,
-					  pdc, &auth);
+					  pdc->sess_key, &auth);
 	if (!NT_STATUS_IS_OK(*perr)) {
 		DEBUG(0, ("rpccli_schannel_bind_data returned %s\n",
 			  nt_errstr(*perr)));
diff --git a/source/rpc_parse/parse_rpc.c b/source/rpc_parse/parse_rpc.c
index d0be83b..8171951 100644
--- a/source/rpc_parse/parse_rpc.c
+++ b/source/rpc_parse/parse_rpc.c
@@ -59,6 +59,7 @@ const struct pipe_id_info pipe_names [] =
 	{ PIPE_SVCCTL  , &ndr_table_svcctl.syntax_id, PIPE_NTSVCS   , &ndr_transfer_syntax },
 	{ PIPE_EVENTLOG, &ndr_table_eventlog.syntax_id, PIPE_EVENTLOG , &ndr_transfer_syntax },
 	{ PIPE_NTSVCS  , &ndr_table_ntsvcs.syntax_id, PIPE_NTSVCS   , &ndr_transfer_syntax },
+	{ PIPE_EPMAPPER  , &ndr_table_epmapper.syntax_id, PIPE_EPMAPPER   , &ndr_transfer_syntax },
 	{ NULL         , NULL                  , NULL          , NULL }
 };
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list