[SCM] Samba Shared Repository - branch master updated

Andreas Schneider asn at samba.org
Thu Jul 21 11:51:02 MDT 2011


The branch, master has been updated
       via  156a0ff s3-rpc_server: Create common function to allocate pipes_struct
       via  759a04e s3-rpc_server: Move pipe/handles functions
       via  0d8f65b s3-rpc_server: Fixed header define.
       via  6a4a6ef s3-rpc_server: Remove unused endpoint information.
       via  4a6a588 s3-rpc_server: We need to copy the session_info for external pipes.
       via  19288f9 s3-rpc_server: Duplicate the pipe name.
       via  3a43ef5 s3-rpc_server: Free the np dir.
       via  304e811 s3-rpc_server: Fix messaging context in the pipes struct.
       via  f5da8ed s3-rpc_server: Add my copyright.
      from  71b49f5 s3:loadparm: fix an implicit cast warning in string intialization in init_globals()

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


- Log -----------------------------------------------------------------
commit 156a0ffe542339952a6e2db191ffc586227edd5a
Author: Simo Sorce <idra at samba.org>
Date:   Thu Jul 21 11:02:59 2011 -0400

    s3-rpc_server: Create common function to allocate pipes_struct
    
    Avoid code duplication and fix bug where a new pipe was not added to
    InternalPipes upon creation in make_server_pipes_struct()
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User: Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date: Thu Jul 21 19:50:02 CEST 2011 on sn-devel-104

commit 759a04e58a88b400dbf0cafc2b86ab58ea196433
Author: Simo Sorce <idra at samba.org>
Date:   Thu Jul 21 09:53:10 2011 -0400

    s3-rpc_server: Move pipe/handles functions
    
    Put InternalPipes related functions in rpc_handles.c and out of rpc_ncacn_np.c
    rpc_handles.c is the only file that really uses them after all and ncacn_np.c
    is the wrong place for that stuff.
    While ther remove unnecessary wrapper functions now that the InternalPipes
    static variable is directly accessible.
    
    Also move all pipes_struct related header stuff in its own rpc_pipes.h header.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>

commit 0d8f65b346592d98f4edbc1fa3905688c9677326
Author: Andreas Schneider <asn at samba.org>
Date:   Fri May 27 11:55:41 2011 +0200

    s3-rpc_server: Fixed header define.

commit 6a4a6efdc9b76d0eb0229ef3f355cb82ba22969c
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jul 15 18:03:47 2011 +0200

    s3-rpc_server: Remove unused endpoint information.

commit 4a6a588e442e8b0880051c92af82eb0fd3bc7f99
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Jul 21 17:58:41 2011 +0200

    s3-rpc_server: We need to copy the session_info for external pipes.
    
    Andrew please check!

commit 19288f978484ca0c826535083bcbefddcbd93346
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Jul 21 11:21:30 2011 +0200

    s3-rpc_server: Duplicate the pipe name.

commit 3a43ef52db8e85c9479e61853dfed0fa371c4fa4
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Jul 21 11:11:51 2011 +0200

    s3-rpc_server: Free the np dir.

commit 304e8116a9c5ac78ca9769000df73538b28e78df
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Jul 21 10:43:56 2011 +0200

    s3-rpc_server: Fix messaging context in the pipes struct.

commit f5da8ed88990f6a326eb16ed0c64925c1702fc5a
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Jul 21 13:13:35 2011 +0200

    s3-rpc_server: Add my copyright.

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

Summary of changes:
 source3/include/ntdomain.h                         |  194 +-------------------
 source3/rpc_server/rpc_ep_setup.h                  |    6 +-
 source3/rpc_server/rpc_handles.c                   |  120 ++++++++++++-
 source3/rpc_server/rpc_ncacn_np.c                  |  125 ++-----------
 source3/rpc_server/rpc_ncacn_np.h                  |    5 -
 .../{include/ntdomain.h => rpc_server/rpc_pipes.h} |   64 +++----
 source3/rpc_server/rpc_server.c                    |   80 +++------
 source3/rpc_server/srv_pipe.c                      |    2 +-
 source3/smbd/conn_idle.c                           |    2 +-
 9 files changed, 190 insertions(+), 408 deletions(-)
 copy source3/{include/ntdomain.h => rpc_server/rpc_pipes.h} (88%)


Changeset truncated at 500 lines:

diff --git a/source3/include/ntdomain.h b/source3/include/ntdomain.h
index 6971305..6f457f8 100644
--- a/source3/include/ntdomain.h
+++ b/source3/include/ntdomain.h
@@ -21,206 +21,16 @@
 */
 
 #ifndef _NT_DOMAIN_H /* _NT_DOMAIN_H */
-#define _NT_DOMAIN_H 
-
-#include "librpc/rpc/dcerpc.h"
+#define _NT_DOMAIN_H
 
 /*
  * A bunch of stuff that was put into smb.h
  * in the NTDOM branch - it didn't belong there.
  */
 
-typedef struct _output_data {
-	/*
-	 * Raw RPC output data. This does not include RPC headers or footers.
-	 */
-	DATA_BLOB rdata;
-
-	/* The amount of data sent from the current rdata struct. */
-	uint32 data_sent_length;
-
-	/*
-	 * The current fragment being returned. This inclues
-	 * headers, data and authentication footer.
-	 */
-	DATA_BLOB frag;
-
-	/* The amount of data sent from the current PDU. */
-	uint32 current_pdu_sent;
-} output_data;
-
-typedef struct _input_data {
-	/*
-	 * This is the current incoming pdu. The data here
-	 * is collected via multiple writes until a complete
-	 * pdu is seen, then the data is copied into the in_data
-	 * structure. The maximum size of this is 0x1630 (RPC_MAX_PDU_FRAG_LEN).
-	 * If length is zero, then we are at the start of a new
-	 * pdu.
-	 */
-	DATA_BLOB pdu;
-
-	/*
-	 * The amount of data needed to complete the in_pdu.
-	 * If this is zero, then we are at the start of a new
-	 * pdu.
-	 */
-	uint32 pdu_needed_len;
-
-	/*
-	 * This is the collection of input data with all
-	 * the rpc headers and auth footers removed.
-	 * The maximum length of this (1Mb) is strictly enforced.
-	 */
-	DATA_BLOB data;
-
-} input_data;
-
-struct handle_list;
-
-typedef struct pipe_rpc_fns {
-
-	struct pipe_rpc_fns *next, *prev;
-
-	/* RPC function table associated with the current rpc_bind (associated by context) */
-
-	const struct api_struct *cmds;
-	int n_cmds;
-	uint32_t context_id;
-	struct ndr_syntax_id syntax;
-
-} PIPE_RPC_FNS;
-
-/*
- * Different auth types we support.
- * Can't keep in sync with wire values as spnego wraps different auth methods.
- */
-
 struct gse_context;
 
-struct dcesrv_ep_entry_list;
-
-struct tsocket_address;
-
-/*
- * DCE/RPC-specific samba-internal-specific handling of data on
- * NamedPipes.
- */
-
-struct pipes_struct {
-	struct pipes_struct *next, *prev;
-
-	const struct tsocket_address *local_address;
-	const struct tsocket_address *remote_address;
-
-	enum dcerpc_transport_t transport;
-
-	struct auth_session_info *session_info;
-	struct messaging_context *msg_ctx;
-
-	struct dcesrv_ep_entry_list *ep_entries;
-
-	/* linked list of rpc dispatch tables associated 
-	   with the open rpc contexts */
-
-	PIPE_RPC_FNS *contexts;
-
-	struct pipe_auth_data auth;
-
-	bool ncalrpc_as_system;
-
-	/*
-	 * Set to true when an RPC bind has been done on this pipe.
-	 */
-
-	bool pipe_bound;
-
-	/*
-	 * Set to true when we should return fault PDU's for everything.
-	 */
-
-	bool fault_state;
-
-	/*
-	 * Set to true when we should return fault PDU's for a bad handle.
-	 */
-
-	bool bad_handle_fault_state;
-
-	/*
-	 * Set to true when the backend does not support a call.
-	 */
-
-	bool rng_fault_state;
-
-	/*
-	 * Set to RPC_BIG_ENDIAN when dealing with big-endian PDU's
-	 */
-
-	bool endian;
-
-	/*
-	 * Struct to deal with multiple pdu inputs.
-	 */
-
-	input_data in_data;
-
-	/*
-	 * Struct to deal with multiple pdu outputs.
-	 */
-
-	output_data out_data;
-
-	/* This context is used for PDU data and is freed between each pdu.
-		Don't use for pipe state storage. */
-	TALLOC_CTX *mem_ctx;
-
-	/* handle database to use on this pipe. */
-	struct handle_list *pipe_handles;
-
-	/* call id retrieved from the pdu header */
-	uint32_t call_id;
-
-	/* operation number retrieved from the rpc header */
-	uint16_t opnum;
-
-	/* private data for the interface implementation */
-	void *private_data;
-
-};
-
-struct api_struct {  
-	const char *name;
-	uint8 opnum;
-	bool (*fn) (struct pipes_struct *);
-};
-
-/* The following definitions come from rpc_server/rpc_handles.c  */
-
-size_t num_pipe_handles(struct pipes_struct *p);
-bool init_pipe_handles(struct pipes_struct *p, const struct ndr_syntax_id *syntax);
-bool create_policy_hnd(struct pipes_struct *p, struct policy_handle *hnd, void *data_ptr);
-bool find_policy_by_hnd(struct pipes_struct *p, const struct policy_handle *hnd,
-			void **data_p);
-bool close_policy_hnd(struct pipes_struct *p, struct policy_handle *hnd);
-void close_policy_by_pipe(struct pipes_struct *p);
-bool pipe_access_check(struct pipes_struct *p);
-
-void *_policy_handle_create(struct pipes_struct *p, struct policy_handle *hnd,
-			    uint32_t access_granted, size_t data_size,
-			    const char *type, NTSTATUS *pstatus);
-#define policy_handle_create(_p, _hnd, _access, _type, _pstatus) \
-	(_type *)_policy_handle_create((_p), (_hnd), (_access), sizeof(_type), #_type, \
-				       (_pstatus))
-
-void *_policy_handle_find(struct pipes_struct *p,
-			  const struct policy_handle *hnd,
-			  uint32_t access_required, uint32_t *paccess_granted,
-			  const char *name, const char *location,
-			  NTSTATUS *pstatus);
-#define policy_handle_find(_p, _hnd, _access_required, _access_granted, _type, _pstatus) \
-	(_type *)_policy_handle_find((_p), (_hnd), (_access_required), \
-				     (_access_granted), #_type, __location__, (_pstatus))
+#include "rpc_server/rpc_pipes.h"
 
 #include "rpc_server/srv_pipe_register.h"
 
diff --git a/source3/rpc_server/rpc_ep_setup.h b/source3/rpc_server/rpc_ep_setup.h
index 57b06ab..2e27995 100644
--- a/source3/rpc_server/rpc_ep_setup.h
+++ b/source3/rpc_server/rpc_ep_setup.h
@@ -19,8 +19,8 @@
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef _SMBD_RPC_CALLBACKS_H
-#define _SMBD_RPC_CALLBACKS_H
+#ifndef _RPC_EP_SETUP_H
+#define _RPC_EP_SETUP_H
 
 struct ndr_interface_table;
 
@@ -51,6 +51,6 @@ NTSTATUS rpc_ep_setup_register(struct tevent_context *ev_ctx,
 bool dcesrv_ep_setup(struct tevent_context *ev_ctx,
 		     struct messaging_context *msg_ctx);
 
-#endif /* _SMBD_RPC_CALLBACKS_H */
+#endif /* _RPC_EP_SETUP_H */
 
 /* vim: set ts=8 sw=8 noet cindent ft=c.doxygen: */
diff --git a/source3/rpc_server/rpc_handles.c b/source3/rpc_server/rpc_handles.c
index 3500a22..c40029b 100644
--- a/source3/rpc_server/rpc_handles.c
+++ b/source3/rpc_server/rpc_handles.c
@@ -23,13 +23,125 @@
 #include "../librpc/gen_ndr/ndr_lsa.h"
 #include "../librpc/gen_ndr/ndr_samr.h"
 #include "auth.h"
-#include "ntdomain.h"
-#include "rpc_server/rpc_ncacn_np.h"
+#include "rpc_server/rpc_pipes.h"
 #include "../libcli/security/security.h"
+#include "lib/tsocket/tsocket.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_RPC_SRV
 
+static struct pipes_struct *InternalPipes;
+
+/* TODO
+ * the following prototypes are declared here to avoid
+ * code being moved about too much for a patch to be
+ * disrupted / less obvious.
+ *
+ * these functions, and associated functions that they
+ * call, should be moved behind a .so module-loading
+ * system _anyway_.  so that's the next step...
+ */
+
+int make_base_pipes_struct(TALLOC_CTX *mem_ctx,
+			   struct messaging_context *msg_ctx,
+			   const char *pipe_name,
+			   enum dcerpc_transport_t transport,
+			   bool endian, bool ncalrpc_as_system,
+			   const struct tsocket_address *remote_address,
+			   const struct tsocket_address *local_address,
+			   struct pipes_struct **_p)
+{
+	struct pipes_struct *p;
+
+	p = talloc_zero(mem_ctx, struct pipes_struct);
+	if (!p) {
+		return ENOMEM;
+	}
+
+	p->mem_ctx = talloc_named(p, 0, "pipe %s %p", pipe_name, p);
+	if (!p->mem_ctx) {
+		talloc_free(p);
+		return ENOMEM;
+	}
+
+	p->msg_ctx = msg_ctx;
+	p->transport = transport;
+	p->endian = endian;
+	p->ncalrpc_as_system = ncalrpc_as_system;
+
+	p->remote_address = tsocket_address_copy(remote_address, p);
+	if (p->remote_address == NULL) {
+		talloc_free(p);
+		return ENOMEM;
+	}
+
+	if (local_address) {
+		p->local_address = tsocket_address_copy(remote_address, p);
+		if (p->local_address == NULL) {
+			talloc_free(p);
+			return ENOMEM;
+		}
+	}
+
+	DLIST_ADD(InternalPipes, p);
+	talloc_set_destructor(p, close_internal_rpc_pipe_hnd);
+
+	*_p = p;
+	return 0;
+}
+
+
+bool check_open_pipes(void)
+{
+	struct pipes_struct *p;
+
+	for (p = InternalPipes; p != NULL; p = p->next) {
+		if (num_pipe_handles(p) != 0) {
+			return true;
+		}
+	}
+	return false;
+}
+
+/****************************************************************************
+ Close an rpc pipe.
+****************************************************************************/
+
+static void free_pipe_rpc_context_internal(struct pipe_rpc_fns *list)
+{
+	struct pipe_rpc_fns *tmp = list;
+	struct pipe_rpc_fns *tmp2;
+
+	while (tmp) {
+		tmp2 = tmp->next;
+		SAFE_FREE(tmp);
+		tmp = tmp2;
+	}
+
+	return;
+}
+
+int close_internal_rpc_pipe_hnd(struct pipes_struct *p)
+{
+	if (!p) {
+		DEBUG(0,("Invalid pipe in close_internal_rpc_pipe_hnd\n"));
+		return False;
+	}
+
+	TALLOC_FREE(p->auth.auth_ctx);
+
+	/* Free the handles database. */
+	close_policy_by_pipe(p);
+
+	free_pipe_rpc_context_internal( p->contexts );
+
+	DLIST_REMOVE(InternalPipes, p);
+
+	ZERO_STRUCTP(p);
+
+	return 0;
+}
+
 /*
  * Handle database - stored per pipe.
  */
@@ -82,9 +194,7 @@ bool init_pipe_handles(struct pipes_struct *p, const struct ndr_syntax_id *synta
 	struct pipes_struct *plist;
 	struct handle_list *hl;
 
-	for (plist = get_first_internal_pipe();
-	     plist;
-	     plist = get_next_internal_pipe(plist)) {
+	for (plist = InternalPipes; plist; plist = plist->next) {
 		struct pipe_rpc_fns *p_ctx;
 		bool stop = false;
 
diff --git a/source3/rpc_server/rpc_ncacn_np.c b/source3/rpc_server/rpc_ncacn_np.c
index a8d9608..2ed4a01 100644
--- a/source3/rpc_server/rpc_ncacn_np.c
+++ b/source3/rpc_server/rpc_ncacn_np.c
@@ -31,7 +31,7 @@
 #include "librpc/gen_ndr/auth.h"
 #include "../auth/auth_sam_reply.h"
 #include "auth.h"
-#include "ntdomain.h"
+#include "rpc_server/rpc_pipes.h"
 #include "../lib/tsocket/tsocket.h"
 #include "../lib/util/tevent_ntstatus.h"
 #include "rpc_contexts.h"
@@ -39,83 +39,6 @@
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_RPC_SRV
 
-static struct pipes_struct *InternalPipes;
-
-/* TODO
- * the following prototypes are declared here to avoid
- * code being moved about too much for a patch to be
- * disrupted / less obvious.
- *
- * these functions, and associated functions that they
- * call, should be moved behind a .so module-loading
- * system _anyway_.  so that's the next step...
- */
-
-/****************************************************************************
- Internal Pipe iterator functions.
-****************************************************************************/
-
-struct pipes_struct *get_first_internal_pipe(void)
-{
-	return InternalPipes;
-}
-
-struct pipes_struct *get_next_internal_pipe(struct pipes_struct *p)
-{
-	return p->next;
-}
-
-static void free_pipe_rpc_context_internal( PIPE_RPC_FNS *list )
-{
-	PIPE_RPC_FNS *tmp = list;
-	PIPE_RPC_FNS *tmp2;
-
-	while (tmp) {
-		tmp2 = tmp->next;
-		SAFE_FREE(tmp);
-		tmp = tmp2;
-	}
-
-	return;
-}
-
-bool check_open_pipes(void)
-{
-	struct pipes_struct *p;
-
-	for (p = InternalPipes; p != NULL; p = p->next) {
-		if (num_pipe_handles(p) != 0) {
-			return true;
-		}
-	}
-	return false;
-}
-
-/****************************************************************************
- Close an rpc pipe.
-****************************************************************************/
-
-int close_internal_rpc_pipe_hnd(struct pipes_struct *p)
-{
-	if (!p) {
-		DEBUG(0,("Invalid pipe in close_internal_rpc_pipe_hnd\n"));
-		return False;
-	}
-
-	TALLOC_FREE(p->auth.auth_ctx);
-
-	/* Free the handles database. */
-	close_policy_by_pipe(p);
-
-	free_pipe_rpc_context_internal( p->contexts );
-
-	DLIST_REMOVE(InternalPipes, p);
-
-	ZERO_STRUCTP(p);
-
-	return 0;
-}
-
 /****************************************************************************
  Make an internal namedpipes structure
 ****************************************************************************/
@@ -128,26 +51,21 @@ struct pipes_struct *make_internal_rpc_pipe_p(TALLOC_CTX *mem_ctx,
 {
 	struct pipes_struct *p;
 	struct pipe_rpc_fns *context_fns;
+	const char *pipe_name;
+	int ret;
 
-	DEBUG(4,("Create pipe requested %s\n",
-		 get_pipe_name_from_syntax(talloc_tos(), syntax)));
+	pipe_name = get_pipe_name_from_syntax(talloc_tos(), syntax);
 
-	p = talloc_zero(mem_ctx, struct pipes_struct);
+	DEBUG(4,("Create pipe requested %s\n", pipe_name));
 
-	if (!p) {
+	ret = make_base_pipes_struct(mem_ctx, msg_ctx, pipe_name,
+				     NCALRPC, RPC_LITTLE_ENDIAN, false,
+				     remote_address, NULL, &p);
+	if (ret) {
 		DEBUG(0,("ERROR! no memory for pipes_struct!\n"));
 		return NULL;
 	}
 
-	p->mem_ctx = talloc_named(p, 0, "pipe %s %p",


-- 
Samba Shared Repository


More information about the samba-cvs mailing list