summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2011-07-21 09:53:10 -0400
committerAndreas Schneider <asn@cryptomilk.org>2011-07-21 18:40:23 +0200
commit759a04e58a88b400dbf0cafc2b86ab58ea196433 (patch)
treec3bb8258da0bf6c7c6366c56c890e3d5a995d2d6
parent0d8f65b346592d98f4edbc1fa3905688c9677326 (diff)
downloadsamba-759a04e58a88b400dbf0cafc2b86ab58ea196433.tar.gz
samba-759a04e58a88b400dbf0cafc2b86ab58ea196433.tar.bz2
samba-759a04e58a88b400dbf0cafc2b86ab58ea196433.zip
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@samba.org>
-rw-r--r--source3/include/ntdomain.h194
-rw-r--r--source3/rpc_server/rpc_handles.c70
-rw-r--r--source3/rpc_server/rpc_ncacn_np.c77
-rw-r--r--source3/rpc_server/rpc_ncacn_np.h5
-rw-r--r--source3/rpc_server/rpc_pipes.h213
-rw-r--r--source3/rpc_server/srv_pipe.c2
-rw-r--r--source3/smbd/conn_idle.c2
7 files changed, 282 insertions, 281 deletions
diff --git a/source3/include/ntdomain.h b/source3/include/ntdomain.h
index 6971305e07..6f457f8c4c 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_handles.c b/source3/rpc_server/rpc_handles.c
index 3500a228d5..1fbee9e3c0 100644
--- a/source3/rpc_server/rpc_handles.c
+++ b/source3/rpc_server/rpc_handles.c
@@ -23,13 +23,75 @@
#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"
#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...
+ */
+
+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 +144,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 d4f3833366..dea079f3f5 100644
--- a/source3/rpc_server/rpc_ncacn_np.c
+++ b/source3/rpc_server/rpc_ncacn_np.c
@@ -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
****************************************************************************/
diff --git a/source3/rpc_server/rpc_ncacn_np.h b/source3/rpc_server/rpc_ncacn_np.h
index 9670045b3f..fc968a2035 100644
--- a/source3/rpc_server/rpc_ncacn_np.h
+++ b/source3/rpc_server/rpc_ncacn_np.h
@@ -56,9 +56,4 @@ NTSTATUS rpc_pipe_open_interface(TALLOC_CTX *mem_ctx,
struct messaging_context *msg_ctx,
struct rpc_pipe_client **cli_pipe);
-struct pipes_struct *get_first_internal_pipe(void);
-struct pipes_struct *get_next_internal_pipe(struct pipes_struct *p);
-bool check_open_pipes(void);
-int close_internal_rpc_pipe_hnd(struct pipes_struct *p);
-
#endif /* _RPC_NCACN_NP_H_ */
diff --git a/source3/rpc_server/rpc_pipes.h b/source3/rpc_server/rpc_pipes.h
new file mode 100644
index 0000000000..9315830351
--- /dev/null
+++ b/source3/rpc_server/rpc_pipes.h
@@ -0,0 +1,213 @@
+/*
+ Unix SMB/Netbios implementation.
+ RPC Server Headers
+ Copyright (C) Andrew Tridgell 1992-1997
+ Copyright (C) Luke Kenneth Casson Leighton 1996-1997
+ Copyright (C) Paul Ashton 1997
+ Copyright (C) Jeremy Allison 2000-2004
+ Copyright (C) Simo Sorce 2010-2011
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _RPC_PIPES_H_
+#define _RPC_PIPES_H_
+
+#include "librpc/rpc/dcerpc.h"
+
+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 dcesrv_ep_entry_list;
+struct tsocket_address;
+struct handle_list;
+struct pipes_struct;
+
+struct api_struct {
+ const char *name;
+ uint8 opnum;
+ bool (*fn) (struct pipes_struct *);
+};
+
+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;
+
+};
+
+/*
+ * 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 */
+
+ struct 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;
+
+};
+
+bool check_open_pipes(void);
+int close_internal_rpc_pipe_hnd(struct pipes_struct *p);
+
+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))
+
+#endif /* _RPC_PIPES_H_ */
diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c
index a52c098c9e..233dfdf5b2 100644
--- a/source3/rpc_server/srv_pipe.c
+++ b/source3/rpc_server/srv_pipe.c
@@ -1522,7 +1522,7 @@ static bool api_pipe_request(struct pipes_struct *p,
{
bool ret = False;
bool changed_user = False;
- PIPE_RPC_FNS *pipe_fns;
+ struct pipe_rpc_fns *pipe_fns;
if (p->pipe_bound &&
((p->auth.auth_type == DCERPC_AUTH_TYPE_NTLMSSP) ||
diff --git a/source3/smbd/conn_idle.c b/source3/smbd/conn_idle.c
index 46f5b7b111..c1949d334e 100644
--- a/source3/smbd/conn_idle.c
+++ b/source3/smbd/conn_idle.c
@@ -22,7 +22,7 @@
#include "includes.h"
#include "smbd/smbd.h"
#include "smbd/globals.h"
-#include "rpc_server/rpc_ncacn_np.h"
+#include "rpc_server/rpc_pipes.h"
/****************************************************************************
Update last used timestamps.