From 7e6cf43756b7643e2f0ee7ada5076f36f3a24bb7 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 8 Jan 2004 22:55:27 +0000 Subject: This patch adds a better dcerpc server infastructure. 1.) We now register endpoint servers add startup via register_backend() and later use the smb.conf 'dcerpc endpoint servers' parameter to setup the dcesrv_context 2.) each endpoint server can register at context creation time as much interfaces as it wants (multiple interfaces on one endpoint are supported!) (NOTE: there's a difference between 'endpoint server' and 'endpoint'! for details look at rpc_server/dcesrv_server.h) 3.) one endpoint can have a security descriptor registered to it self this will be checked in the future when a client wants to connect to an smb pipe endpoint. 4.) we now have a 'remote' endpoint server, which works like the ntvfs_cifs module it takes this options in the [globals] section: dcerpc remote:interfaces = srvsvc, winreg, w32time, epmapper dcerpc remote:binding = ... dcerpc remote:user = ... dcerpc remote:password = ... 5.) we currently have tree endpoint servers: epmapper, rpcecho and remote the default for the 'dcerpc endpiont servers = epmapper, rpcecho' for testing you can also do dcerpc endpoint servers = rpcecho, remote, epmapper dcerpc remote:interfaces = srvsvc, samr, netlogon 6,) please notice the the epmapper now only returns NO_ENTRIES (but I think we'll find a solution for this too:-) 7.) also there're some other stuff left, but step by step :-) This patch also includes updates for the register_subsystem() , ntvfs_init(), and some other funtions to check for duplicate subsystem registration metze (hmmm, my first large commit...I hope it works as supposed :-) (This used to be commit 917e45dafd5be4c2cd90ff425b8d6f8403122349) --- source4/ntvfs/ipc/vfs_ipc.c | 22 ++++++++++++---------- source4/ntvfs/ntvfs_base.c | 11 +++++++++-- 2 files changed, 21 insertions(+), 12 deletions(-) (limited to 'source4/ntvfs') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 96f28895c9..cd300b6589 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -1,7 +1,9 @@ /* Unix SMB/CIFS implementation. default IPC$ NTVFS backend + Copyright (C) Andrew Tridgell 2003 + Copyright (C) Stefan (metze) Metzmacher 2004 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 @@ -39,7 +41,7 @@ struct ipc_private { TALLOC_CTX *mem_ctx; const char *pipe_name; uint16 fnum; - struct dcesrv_state *pipe_state; + struct dcesrv_connection *dce_conn; uint16 ipc_state; } *pipe_list; @@ -77,7 +79,7 @@ again: static void pipe_shutdown(struct ipc_private *private, struct pipe_state *p) { TALLOC_CTX *mem_ctx = private->pipe_list->mem_ctx; - dcesrv_endpoint_disconnect(private->pipe_list->pipe_state); + dcesrv_endpoint_disconnect(private->pipe_list->dce_conn); DLIST_REMOVE(private->pipe_list, private->pipe_list); talloc_destroy(mem_ctx); } @@ -192,7 +194,7 @@ static NTSTATUS ipc_open_generic(struct request_context *req, const char *fname, struct pipe_state *p; TALLOC_CTX *mem_ctx; NTSTATUS status; - struct dcesrv_endpoint endpoint; + struct dcesrv_ep_description ep_description; struct ipc_private *private = req->conn->ntvfs_private; mem_ctx = talloc_init("ipc_open '%s'", fname); @@ -235,10 +237,10 @@ static NTSTATUS ipc_open_generic(struct request_context *req, const char *fname, finalised for Samba4 */ - endpoint.type = ENDPOINT_SMB; - endpoint.info.smb_pipe = p->pipe_name; + ep_description.type = ENDPOINT_SMB; + ep_description.info.smb_pipe = p->pipe_name; - status = dcesrv_endpoint_connect(&req->smb->dcesrv, &endpoint, &p->pipe_state); + status = dcesrv_endpoint_search_connect(&req->smb->dcesrv, &ep_description, &p->dce_conn); if (!NT_STATUS_IS_OK(status)) { talloc_destroy(mem_ctx); return status; @@ -386,7 +388,7 @@ static NTSTATUS ipc_read(struct request_context *req, union smb_read *rd) return NT_STATUS_INVALID_HANDLE; } - status = dcesrv_output(p->pipe_state, &data); + status = dcesrv_output(p->dce_conn, &data); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -440,7 +442,7 @@ static NTSTATUS ipc_write(struct request_context *req, union smb_write *wr) return NT_STATUS_INVALID_HANDLE; } - status = dcesrv_input(p->pipe_state, &data); + status = dcesrv_input(p->dce_conn, &data); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -599,7 +601,7 @@ static NTSTATUS ipc_dcerpc_cmd(struct request_context *req, struct smb_trans2 *t expect this to fail, and things like NDR faults are not reported at this stage. Those sorts of errors happen in the dcesrv_output stage */ - status = dcesrv_input(p->pipe_state, &trans->in.data); + status = dcesrv_input(p->dce_conn, &trans->in.data); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -609,7 +611,7 @@ static NTSTATUS ipc_dcerpc_cmd(struct request_context *req, struct smb_trans2 *t async calls. Again, we only expect NT_STATUS_OK. If the call fails then the error is encoded at the dcerpc level */ - status = dcesrv_output(p->pipe_state, &trans->out.data); + status = dcesrv_output(p->dce_conn, &trans->out.data); if (!NT_STATUS_IS_OK(status)) { return status; } diff --git a/source4/ntvfs/ntvfs_base.c b/source4/ntvfs/ntvfs_base.c index ad1b3ae671..e4009fd1f0 100644 --- a/source4/ntvfs/ntvfs_base.c +++ b/source4/ntvfs/ntvfs_base.c @@ -1,7 +1,9 @@ /* Unix SMB/CIFS implementation. NTVFS base code + Copyright (C) Andrew Tridgell 2003 + Copyright (C) Stefan (metze) Metzmacher 2004 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 @@ -107,12 +109,17 @@ const struct ntvfs_critical_sizes *ntvfs_interface_version(void) */ BOOL ntvfs_init(void) { - register_subsystem("ntvfs", ntvfs_register); + NTSTATUS status; + + status = register_subsystem("ntvfs", ntvfs_register); + if (!NT_STATUS_IS_OK(status)) { + return False; + } /* FIXME: Perhaps panic if a basic backend, such as IPC, fails to initialise? */ static_init_ntvfs; - DEBUG(3,("NTVFS version %d initialised\n", NTVFS_INTERFACE_VERSION)); + DEBUG(3,("NTVFS subsystem version %d initialised\n", NTVFS_INTERFACE_VERSION)); return True; } -- cgit