[SCM] Samba Shared Repository - branch master updated

Stefan Metzmacher metze at samba.org
Tue Oct 29 18:33:02 MDT 2013


The branch, master has been updated
       via  5990de5 s3-rpc_client: Make data pointer const in trans_send().
       via  cd8f811 s3-rpc_server: Remove obsolete make_internal_rpc_pipe().
       via  f69a490 s3-rpc_server: Remove obsolete FAKE_FILE_TYPE_NAMED_PIPE handling.
       via  b8e0732 s3-rpc_server: Use make_internal_rpc_pipe_socketpair().
       via  4498d07 s3-rpc_server: Pass the server event context to np_open().
       via  7daa4b9 s3-rpc_server: Add make_internal_rpc_pipe_socketpair().
       via  327b0dd s3-smbd: Do not declare change_to_root_user() twice.
       via  13d840a s3-smbd_shim: Add become_authenticated_pipe_user().
       via  9e723f9 s3-rpc_server: Add named_pipe_client_init() function.
       via  921ef8f s3-rpc_server: Make named_pipe_packet_process a shared functiion.
       via  1c069b1 s3-rpc_server: Make make_server_pipes_struct a shared function.
       via  0152406 s3-waf: Create a target for RPC_SOCK_HELPER.
       via  710ddf8 s3-waf: Seperate rpc_server and rpc_service.
       via  df4c2df s3-waf: Reorder rpc_server wscript_build file.
       via  0733836 s3-rpc_server: Use new rpc named pipe functions.
       via  1e66a8e s3-rpc_server: Add make_internal_rpc_pipe().
       via  155a794 s3-rpc_server: Add make_external_rpc_pipe() function.
       via  b86b4d0 s3-rpc_server: Add npa_state_init() function.
       via  eec05fb libcli: Add tstream_npa_socketpair() function.
      from  30e5a5c rpc_server: Fix a memleak on error exit

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 5990de5d89f900b9f754357e9ca7afbc142e0e00
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Oct 24 11:49:53 2013 +0200

    s3-rpc_client: Make data pointer const in trans_send().
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    
    Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
    Autobuild-Date(master): Wed Oct 30 01:32:08 CET 2013 on sn-devel-104

commit cd8f811247038c057653995f06aacd8b6cebc0a4
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Oct 24 10:32:17 2013 +0200

    s3-rpc_server: Remove obsolete make_internal_rpc_pipe().
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit f69a490a87e31880fd033292d9c2f74f7de39d88
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Oct 23 17:16:10 2013 +0200

    s3-rpc_server: Remove obsolete FAKE_FILE_TYPE_NAMED_PIPE handling.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit b8e07323c985c4b797c2d31bf91af3f9a9471052
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Oct 23 17:04:12 2013 +0200

    s3-rpc_server: Use make_internal_rpc_pipe_socketpair().
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 4498d07e7355a0ec8b96f7f9138d8321b15bef55
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Oct 23 17:03:37 2013 +0200

    s3-rpc_server: Pass the server event context to np_open().
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 7daa4b94fa6299d6e1788c93ed8ff0b4c4023b40
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Sep 25 11:35:41 2013 +0200

    s3-rpc_server: Add make_internal_rpc_pipe_socketpair().
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 327b0ddcd9ea7db373a92e47db7e796da3186b05
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Oct 23 11:07:38 2013 +0200

    s3-smbd: Do not declare change_to_root_user() twice.
    
    This is already in include/proto.h for smbd_shim.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 13d840ad2ff0db7320e0cbef86cd47872493292c
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Oct 23 11:02:39 2013 +0200

    s3-smbd_shim: Add become_authenticated_pipe_user().
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 9e723f9d69bbbaefd9e15399654668693854628b
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Sep 25 11:34:56 2013 +0200

    s3-rpc_server: Add named_pipe_client_init() function.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 921ef8f9eb718be7343b5d27b2f6b8341eeca162
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Sep 25 10:25:39 2013 +0200

    s3-rpc_server: Make named_pipe_packet_process a shared functiion.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 1c069b17775ea041051104ae80d4986631634b54
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Sep 25 16:33:00 2013 +0200

    s3-rpc_server: Make make_server_pipes_struct a shared function.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 01524063cc6b4c5f82127ef985e8aefe7c50806d
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Oct 23 10:36:57 2013 +0200

    s3-waf: Create a target for RPC_SOCK_HELPER.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 710ddf82ed88002493171f36fbbeebfff0a181fb
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Oct 23 10:24:13 2013 +0200

    s3-waf: Seperate rpc_server and rpc_service.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit df4c2df53b7fa94149fb9fd0c48f651fef342274
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Oct 23 10:14:01 2013 +0200

    s3-waf: Reorder rpc_server wscript_build file.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 0733836b0e7f0797dc9ab331fb4f0ebf48d204b5
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Sep 24 15:03:48 2013 +0200

    s3-rpc_server: Use new rpc named pipe functions.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 1e66a8e674da00c2a110466e74311f54283104c6
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Sep 24 11:28:39 2013 +0200

    s3-rpc_server: Add make_internal_rpc_pipe().
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 155a794e74ae0f171e24da64f9d357444c3f8214
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Sep 24 11:28:29 2013 +0200

    s3-rpc_server: Add make_external_rpc_pipe() function.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit b86b4d0db1f6838799f66bed4ed2a1083599eaea
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Sep 24 11:27:35 2013 +0200

    s3-rpc_server: Add npa_state_init() function.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit eec05fb70f5f3558ef5f08816c22d0edaf7fedab
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Sep 19 14:52:22 2013 +0200

    libcli: Add tstream_npa_socketpair() function.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

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

Summary of changes:
 libcli/named_pipe_auth/npa_tstream.c       |   57 ++++++
 libcli/named_pipe_auth/npa_tstream.h       |   10 +
 source3/include/proto.h                    |    5 +-
 source3/lib/smbd_shim.c                    |   18 ++
 source3/lib/smbd_shim.h                    |    2 +
 source3/rpc_client/rpc_transport.h         |    2 +-
 source3/rpc_client/rpc_transport_tstream.c |    2 +-
 source3/rpc_server/rpc_ncacn_np.c          |  267 ++++++++++++++++++++++++++++
 source3/rpc_server/rpc_ncacn_np.h          |   29 +++
 source3/rpc_server/rpc_server.c            |   91 +++++-----
 source3/rpc_server/rpc_server.h            |   52 ++++++
 source3/rpc_server/srv_pipe_hnd.c          |  110 +++++------
 source3/rpc_server/srv_pipe_hnd.h          |    1 +
 source3/rpc_server/wscript_build           |  173 +++++++++++--------
 source3/smbd/pipes.c                       |    1 +
 source3/smbd/proto.h                       |    5 +-
 source3/smbd/server.c                      |    2 +
 source3/smbd/uid.c                         |    4 +-
 source3/wscript_build                      |    7 +-
 19 files changed, 653 insertions(+), 185 deletions(-)


Changeset truncated at 500 lines:

diff --git a/libcli/named_pipe_auth/npa_tstream.c b/libcli/named_pipe_auth/npa_tstream.c
index c2eb7bf..2728e04 100644
--- a/libcli/named_pipe_auth/npa_tstream.c
+++ b/libcli/named_pipe_auth/npa_tstream.c
@@ -1442,3 +1442,60 @@ int _tstream_npa_accept_existing_recv(struct tevent_req *req,
 	tevent_req_received(req);
 	return 0;
 }
+
+
+/* SOCKETPAIR for internal rpc communication */
+
+/* file_type is FILE_TYPE_BYTE_MODE_PIPE or FILE_TYPE_MESSAGE_MODE_PIPE */
+int _tstream_npa_socketpair(uint16_t file_type,
+			    TALLOC_CTX *mem_ctx1,
+			    struct tstream_context **pstream1,
+			    TALLOC_CTX *mem_ctx2,
+			    struct tstream_context **pstream2,
+			    const char *location)
+{
+	struct tstream_context *stream1 = NULL;
+	struct tstream_context *stream2 = NULL;
+	int fds[2];
+	int fd1;
+	int fd2;
+	int rc;
+
+	rc = socketpair(AF_UNIX, SOCK_STREAM, 0, fds);
+	if (rc == -1) {
+		return -1;
+	}
+	fd1 = fds[0];
+	fd2 = fds[1];
+
+	rc = _tstream_npa_existing_socket(mem_ctx1,
+					  fd1,
+					  file_type,
+					  &stream1,
+					  location);
+	if (rc == -1) {
+		int sys_errno = errno;
+		close(fd1);
+		close(fd2);
+		errno = sys_errno;
+		return -1;
+	}
+
+	rc = _tstream_npa_existing_socket(mem_ctx2,
+					  fd2,
+					  file_type,
+					  &stream2,
+					  location);
+	if (rc == -1) {
+		int sys_errno = errno;
+		talloc_free(stream1);
+		close(fd2);
+		errno = sys_errno;
+		return -1;
+	}
+
+	*pstream1 = stream1;
+	*pstream2 = stream2;
+
+	return 0;
+}
diff --git a/libcli/named_pipe_auth/npa_tstream.h b/libcli/named_pipe_auth/npa_tstream.h
index 1d85de7..e7a1ac7 100644
--- a/libcli/named_pipe_auth/npa_tstream.h
+++ b/libcli/named_pipe_auth/npa_tstream.h
@@ -117,4 +117,14 @@ int _tstream_npa_accept_existing_recv(struct tevent_req *req,
 					  session_info, \
 					  __location__)
 
+int _tstream_npa_socketpair(uint16_t file_type,
+			    TALLOC_CTX *mem_ctx1,
+			    struct tstream_context **pstream1,
+			    TALLOC_CTX *mem_ctx2,
+			    struct tstream_context **pstream2,
+			    const char *location);
+#define tstream_npa_socketpair(ft, mem1, stream1, mem2, stream2) \
+	_tstream_npa_socketpair(ft, mem1, stream1, mem2, stream2, \
+				__location__)
+
 #endif /* NPA_TSTREAM_H */
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 497828e..277547b 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1253,7 +1253,7 @@ bool ea_list_has_invalid_name(struct ea_list *ea_list);
 void become_root(void);
 void unbecome_root(void);
 
-/* The following definitions come from lib/dummysmbd.c */
+/* The following definitions come from lib/smbd_shim.c */
 
 int find_service(TALLOC_CTX *ctx, const char *service_in, char **p_service_out);
 void cancel_pending_lock_requests_by_fid(files_struct *fsp,
@@ -1263,6 +1263,9 @@ void send_stat_cache_delete_message(struct messaging_context *msg_ctx,
 				    const char *name);
 NTSTATUS can_delete_directory_fsp(files_struct *fsp);
 bool change_to_root_user(void);
+bool become_authenticated_pipe_user(struct auth_session_info *session_info);
+bool unbecome_authenticated_pipe_user(void);
+
 void contend_level2_oplocks_begin(files_struct *fsp,
 				  enum level2_contention_type type);
 void contend_level2_oplocks_end(files_struct *fsp,
diff --git a/source3/lib/smbd_shim.c b/source3/lib/smbd_shim.c
index d5ad577..1b5b4e6 100644
--- a/source3/lib/smbd_shim.c
+++ b/source3/lib/smbd_shim.c
@@ -58,6 +58,24 @@ bool change_to_root_user(void)
 	return false;
 }
 
+bool become_authenticated_pipe_user(struct auth_session_info *session_info)
+{
+	if (shim.become_authenticated_pipe_user) {
+		return shim.become_authenticated_pipe_user(session_info);
+	}
+
+	return false;
+}
+
+bool unbecome_authenticated_pipe_user(void)
+{
+	if (shim.unbecome_authenticated_pipe_user) {
+		return shim.unbecome_authenticated_pipe_user();
+	}
+
+	return false;
+}
+
 /**
  * The following two functions need to be called from inside the low-level BRL
  * code for oplocks correctness in smbd.  Since other utility binaries also
diff --git a/source3/lib/smbd_shim.h b/source3/lib/smbd_shim.h
index 1645837..f3da585 100644
--- a/source3/lib/smbd_shim.h
+++ b/source3/lib/smbd_shim.h
@@ -36,6 +36,8 @@ struct smbd_shim
 					       const char *name);
 
 	bool (*change_to_root_user)(void);
+	bool (*become_authenticated_pipe_user)(struct auth_session_info *session_info);
+	bool (*unbecome_authenticated_pipe_user)(void);
 
 	void (*contend_level2_oplocks_begin)(files_struct *fsp,
 					     enum level2_contention_type type);
diff --git a/source3/rpc_client/rpc_transport.h b/source3/rpc_client/rpc_transport.h
index ad22106..1c77458 100644
--- a/source3/rpc_client/rpc_transport.h
+++ b/source3/rpc_client/rpc_transport.h
@@ -64,7 +64,7 @@ struct rpc_cli_transport {
 	 */
 	struct tevent_req *(*trans_send)(TALLOC_CTX *mem_ctx,
 					 struct tevent_context *ev,
-					 uint8_t *data, size_t data_len,
+					 const uint8_t *data, size_t data_len,
 					 uint32_t max_rdata_len,
 					 void *priv);
 	/**
diff --git a/source3/rpc_client/rpc_transport_tstream.c b/source3/rpc_client/rpc_transport_tstream.c
index dd0de08..3d47d60 100644
--- a/source3/rpc_client/rpc_transport_tstream.c
+++ b/source3/rpc_client/rpc_transport_tstream.c
@@ -356,7 +356,7 @@ static int rpc_tstream_trans_next_vector(struct tstream_context *stream,
 
 static struct tevent_req *rpc_tstream_trans_send(TALLOC_CTX *mem_ctx,
 						 struct tevent_context *ev,
-						 uint8_t *data, size_t data_len,
+						 const uint8_t *data, size_t data_len,
 						 uint32_t max_rdata_len,
 						 void *priv)
 {
diff --git a/source3/rpc_server/rpc_ncacn_np.c b/source3/rpc_server/rpc_ncacn_np.c
index c58f97d..5317fd3 100644
--- a/source3/rpc_server/rpc_ncacn_np.c
+++ b/source3/rpc_server/rpc_ncacn_np.c
@@ -37,10 +37,146 @@
 #include "rpc_contexts.h"
 #include "rpc_server/rpc_config.h"
 #include "librpc/ndr/ndr_table.h"
+#include "rpc_server/rpc_server.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_RPC_SRV
 
+static struct npa_state *npa_state_init(TALLOC_CTX *mem_ctx)
+{
+	struct npa_state *npa;
+
+	npa = talloc_zero(mem_ctx, struct npa_state);
+	if (npa == NULL) {
+		return NULL;
+	}
+
+	npa->read_queue = tevent_queue_create(npa, "npa_cli_read");
+	if (npa->read_queue == NULL) {
+		DEBUG(0, ("tevent_queue_create failed\n"));
+		goto fail;
+	}
+
+	npa->write_queue = tevent_queue_create(npa, "npa_cli_write");
+	if (npa->write_queue == NULL) {
+		DEBUG(0, ("tevent_queue_create failed\n"));
+		goto fail;
+	}
+
+	return npa;
+fail:
+	talloc_free(npa);
+	return NULL;
+}
+
+NTSTATUS make_internal_rpc_pipe_socketpair(TALLOC_CTX *mem_ctx,
+					   struct tevent_context *ev_ctx,
+					   struct messaging_context *msg_ctx,
+					   const char *pipe_name,
+					   const struct ndr_syntax_id *syntax,
+					   const struct tsocket_address *remote_address,
+					   const struct auth_session_info *session_info,
+					   struct npa_state **pnpa)
+{
+	TALLOC_CTX *tmp_ctx = talloc_stackframe();
+	struct named_pipe_client *npc;
+	struct tevent_req *subreq;
+	struct npa_state *npa;
+	NTSTATUS status;
+	int error;
+	int rc;
+
+	DEBUG(4, ("Create of internal pipe %s requested\n", pipe_name));
+
+	npa = npa_state_init(tmp_ctx);
+	if (npa == NULL) {
+		status = NT_STATUS_NO_MEMORY;
+		goto out;
+	}
+
+	npa->file_type = FILE_TYPE_MESSAGE_MODE_PIPE;
+	npa->device_state = 0xff | 0x0400 | 0x0100;
+	npa->allocation_size = 4096;
+
+	npc = named_pipe_client_init(npa,
+				     ev_ctx,
+				     msg_ctx,
+				     pipe_name,
+				     NULL, /* term_fn */
+				     npa->file_type,
+				     npa->device_state,
+				     npa->allocation_size,
+				     NULL); /* private_data */
+	if (npc == NULL) {
+		status = NT_STATUS_NO_MEMORY;
+		goto out;
+	}
+	npa->private_data = (void*) npc;
+
+	rc = tstream_npa_socketpair(npa->file_type,
+				    npa,
+				    &npa->stream,
+				    npc,
+				    &npc->tstream);
+	if (rc == -1) {
+		status = map_nt_error_from_unix(errno);
+		goto out;
+	}
+
+	npc->client = tsocket_address_copy(remote_address, npc);
+	if (npc->client == NULL) {
+		status = NT_STATUS_NO_MEMORY;
+		goto out;
+	}
+
+	npc->client_name = tsocket_address_inet_addr_string(npc->client, npc);
+	if (npc->client_name == NULL) {
+		status = NT_STATUS_NO_MEMORY;
+		goto out;
+	}
+
+	npc->session_info = copy_session_info(npc, session_info);
+	if (npc->session_info == NULL) {
+		status = NT_STATUS_NO_MEMORY;
+		goto out;
+	}
+
+	rc = make_server_pipes_struct(npc,
+				      npc->msg_ctx,
+				      npc->pipe_name,
+				      NCACN_NP,
+				      false,
+				      npc->server,
+				      npc->client,
+				      npc->session_info,
+				      &npc->p,
+				      &error);
+	if (rc == -1) {
+		status = map_nt_error_from_unix(error);
+		goto out;
+	}
+
+	npc->write_queue = tevent_queue_create(npc, "npa_server_write_queue");
+	if (npc->write_queue == NULL) {
+		status = NT_STATUS_NO_MEMORY;
+		goto out;
+	}
+
+	subreq = dcerpc_read_ncacn_packet_send(npc, npc->ev, npc->tstream);
+	if (subreq == NULL) {
+		DEBUG(2, ("Failed to start receving packets\n"));
+		status = NT_STATUS_PIPE_BROKEN;
+		goto out;
+	}
+	tevent_req_set_callback(subreq, named_pipe_packet_process, npc);
+
+	*pnpa = talloc_steal(mem_ctx, npa);
+	status = NT_STATUS_OK;
+out:
+	talloc_free(tmp_ctx);
+	return status;
+}
+
 /****************************************************************************
  Make an internal namedpipes structure
 ****************************************************************************/
@@ -516,6 +652,137 @@ NTSTATUS rpc_pipe_open_internal(TALLOC_CTX *mem_ctx,
  * External pipes functions
  ***************************************************************************/
 
+NTSTATUS make_external_rpc_pipe(TALLOC_CTX *mem_ctx,
+				const char *pipe_name,
+				const struct tsocket_address *local_address,
+				const struct tsocket_address *remote_address,
+				const struct auth_session_info *session_info,
+				struct npa_state **pnpa)
+{
+	TALLOC_CTX *tmp_ctx = talloc_stackframe();
+	struct auth_session_info_transport *session_info_t;
+	struct tevent_context *ev_ctx;
+	struct tevent_req *subreq;
+	const char *socket_np_dir;
+	const char *socket_dir;
+	struct npa_state *npa;
+	int sys_errno;
+	NTSTATUS status;
+	int rc = -1;
+	bool ok;
+
+	npa = npa_state_init(tmp_ctx);
+	if (npa == NULL) {
+		status = NT_STATUS_NO_MEMORY;
+		goto out;
+	}
+
+	socket_dir = lp_parm_const_string(GLOBAL_SECTION_SNUM,
+					  "external_rpc_pipe",
+					  "socket_dir",
+					  lp_ncalrpc_dir());
+	if (socket_dir == NULL) {
+		DEBUG(0, ("external_rpc_pipe: socket_dir not set\n"));
+		status = NT_STATUS_PIPE_NOT_AVAILABLE;
+		goto out;
+	}
+
+	socket_np_dir = talloc_asprintf(tmp_ctx, "%s/np", socket_dir);
+	if (socket_np_dir == NULL) {
+		DEBUG(0, ("talloc_asprintf failed\n"));
+		status = NT_STATUS_NO_MEMORY;
+		goto out;
+	}
+
+	session_info_t = talloc_zero(tmp_ctx,
+				     struct auth_session_info_transport);
+	if (session_info_t == NULL) {
+		DEBUG(0, ("talloc failed\n"));
+		status = NT_STATUS_NO_MEMORY;
+		goto out;
+	}
+
+	session_info_t->session_info = copy_session_info(session_info_t,
+							 session_info);
+	if (session_info_t->session_info == NULL) {
+		DEBUG(0, ("copy_session_info failed\n"));
+		status = NT_STATUS_NO_MEMORY;
+		goto out;
+	}
+
+	ev_ctx = s3_tevent_context_init(tmp_ctx);
+	if (ev_ctx == NULL) {
+		DEBUG(0, ("s3_tevent_context_init failed\n"));
+		status = NT_STATUS_NO_MEMORY;
+		goto out;
+	}
+
+	become_root();
+	subreq = tstream_npa_connect_send(tmp_ctx,
+					  ev_ctx,
+					  socket_np_dir,
+					  pipe_name,
+					  remote_address, /* client_addr */
+					  NULL, /* client_name */
+					  local_address, /* server_addr */
+					  NULL, /* server_name */
+					  session_info_t);
+	if (subreq == NULL) {
+		unbecome_root();
+		DEBUG(0, ("tstream_npa_connect_send to %s for pipe %s and "
+			  "user %s\\%s failed\n",
+			  socket_np_dir, pipe_name, session_info_t->session_info->info->domain_name,
+			  session_info_t->session_info->info->account_name));
+		status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
+		goto out;
+	}
+	ok = tevent_req_poll(subreq, ev_ctx);
+	unbecome_root();
+	if (!ok) {
+		DEBUG(0, ("tevent_req_poll to %s for pipe %s and user %s\\%s "
+			  "failed for tstream_npa_connect: %s\n",
+			  socket_np_dir,
+			  pipe_name,
+			  session_info_t->session_info->info->domain_name,
+			  session_info_t->session_info->info->account_name,
+			  strerror(errno)));
+		status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
+		goto out;
+	}
+
+	rc = tstream_npa_connect_recv(subreq,
+				      &sys_errno,
+				      npa,
+				      &npa->stream,
+				      &npa->file_type,
+				      &npa->device_state,
+				      &npa->allocation_size);
+	talloc_free(subreq);
+	if (rc != 0) {
+		int l = 1;
+
+		if (errno == ENOENT) {
+			l = 2;
+		}
+
+		DEBUG(l, ("tstream_npa_connect_recv  to %s for pipe %s and "
+			  "user %s\\%s failed: %s\n",
+			  socket_np_dir,
+			  pipe_name,
+			  session_info_t->session_info->info->domain_name,
+			  session_info_t->session_info->info->account_name,
+			  strerror(sys_errno)));
+		status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
+		goto out;
+	}
+
+	*pnpa = talloc_steal(mem_ctx, npa);
+	status = NT_STATUS_OK;
+out:
+	talloc_free(tmp_ctx);
+
+	return status;
+}
 
 struct np_proxy_state *make_external_rpc_pipe_p(TALLOC_CTX *mem_ctx,
 				const char *pipe_name,
diff --git a/source3/rpc_server/rpc_ncacn_np.h b/source3/rpc_server/rpc_ncacn_np.h
index 67cd8a1..b8426e0 100644
--- a/source3/rpc_server/rpc_ncacn_np.h
+++ b/source3/rpc_server/rpc_ncacn_np.h
@@ -24,6 +24,35 @@ struct dcerpc_binding_handle;
 struct ndr_interface_table;
 struct tsocket_address;
 
+struct npa_state {
+	struct tstream_context *stream;
+
+	struct tevent_queue *read_queue;
+	struct tevent_queue *write_queue;
+
+	uint64_t allocation_size;
+	uint16_t device_state;
+	uint16_t file_type;
+
+	void *private_data;
+};
+
+NTSTATUS make_external_rpc_pipe(TALLOC_CTX *mem_ctx,
+				const char *pipe_name,
+				const struct tsocket_address *local_address,
+				const struct tsocket_address *remote_address,
+				const struct auth_session_info *session_info,
+				struct npa_state **pnpa);
+
+NTSTATUS make_internal_rpc_pipe_socketpair(TALLOC_CTX *mem_ctx,
+					   struct tevent_context *ev_ctx,
+					   struct messaging_context *msg_ctx,
+					   const char *pipe_name,
+					   const struct ndr_syntax_id *syntax,
+					   const struct tsocket_address *remote_address,
+					   const struct auth_session_info *session_info,
+					   struct npa_state **pnpa);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list