r13210: Revert my named pipes patch until it passes not just 'make quicktest' but
authorJelmer Vernooij <jelmer@samba.org>
Sat, 28 Jan 2006 20:08:03 +0000 (20:08 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:51:35 +0000 (13:51 -0500)
also 'make test'
(This used to be commit e3d0676aee84e96e5c87bed4cd0cde75a4191953)

15 files changed:
source4/include/smb.h
source4/include/structs.h
source4/librpc/rpc/dcerpc_smb.c
source4/ntvfs/config.mk
source4/ntvfs/ipc/ipc.h
source4/ntvfs/ipc/np_echo.c
source4/ntvfs/ipc/vfs_ipc.c
source4/rpc_server/config.mk
source4/rpc_server/dcerpc_np.c
source4/rpc_server/dcerpc_server.c
source4/script/tests/test_quick.sh
source4/torture/config.mk
source4/torture/ipc/np_echo.c
source4/torture/ipc/rap.c
source4/torture/torture.c

index a1934c9635acdf039b8a01f74ec32ac74947541e..78a66dd20a5b5d6e135d0a741095dee8223e6f22 100644 (file)
 /* used to indicate end of chain */
 #define SMB_CHAIN_NONE   0xFF
 
-/* These are the named pipe commands */
-#define NAMED_PIPE_SETHANDLESTATE              0x01 
-#define NAMED_PIPE_TRANSACT                            0x26
-#define NAMED_PIPE_WAITHANDLESTATE             0x53
+/* These are the trans subcommands */
+#define TRANSACT_SETNAMEDPIPEHANDLESTATE  0x01 
+#define TRANSACT_DCERPCCMD                0x26
+#define TRANSACT_WAITNAMEDPIPEHANDLESTATE 0x53
 
 /* These are the NT transact sub commands. */
 #define NT_TRANSACT_CREATE                1
index 05167db5f99d76d049083ee86600037d0dde953e..60ec1eae6723b3675e53a7ad22760ed507d9cf6b 100644 (file)
@@ -164,5 +164,3 @@ struct smbcli_state;
 struct substitute_context;
 
 struct model_ops;
-
-struct named_pipe_ops;
index 8a7ce88ed5dba74e8733204e3fde4cc3fb4a73b4..c0716a1af894755c566e8de27c1d1777a75ad9e0 100644 (file)
@@ -240,7 +240,7 @@ static NTSTATUS smb_send_trans_request(struct dcerpc_connection *c, DATA_BLOB *b
         trans->in.data = *blob;
         trans->in.params = data_blob(NULL, 0);
         
-        setup[0] = NAMED_PIPE_TRANSACT;
+        setup[0] = TRANSACT_DCERPCCMD;
         setup[1] = smb->fnum;
 
         trans->in.max_param = 0;
index df96998cfee1c90e39e521d2b557663dcbdce67b..74b62809f7e55bac6581d5bf4b63498c76fa9d59 100644 (file)
@@ -47,10 +47,7 @@ OBJ_FILES = \
 # End MODULE ntvfs_ipc
 ################################################
 
-[MODULE::np_echo]
-INIT_FUNCTION = np_echo_init
-OBJ_FILES = ipc/np_echo.o
-SUBSYSTEM = ntvfs_ipc
+
 
 ################################################
 # Start MODULE ntvfs_nbench
index 53818a584577ea6cd0f8c95b1ddaedcaa1545acc..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,30 +0,0 @@
-/* 
-   Unix SMB/CIFS implementation.
-   NTVFS IPC$ Named Pipes
-   Copyright (C) Jelmer Vernooij                       2005
-   
-   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 2 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, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-struct named_pipe_ops {
-       NTSTATUS (*open)(void *context_data,
-                                        const char *path, 
-                                        struct auth_session_info *session, 
-                                        struct stream_connection *stream,
-                                        TALLOC_CTX *ctx, void **private_data);
-       NTSTATUS (*trans)(void *private_data, DATA_BLOB *in, DATA_BLOB *out);
-       NTSTATUS (*write)(void *private_data, DATA_BLOB *out);
-       NTSTATUS (*read)(void *private_data, DATA_BLOB *in);
-};
index bfa0083b79010071a132a4b469031ac52df91f21..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,77 +0,0 @@
-/* 
-   Unix SMB/CIFS implementation.
-   DCE/RPC over named pipes support (glue between dcerpc and smb servers)
-
-   Copyright (C) Jelmer Vernooij 2005
-
-   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 2 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, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#include "includes.h"
-#include "lib/socket/socket.h"
-#include "lib/events/events.h"
-#include "rpc_server/dcerpc_server.h"
-#include "ntvfs/ipc/ipc.h"
-
-static NTSTATUS echo_pipe_open (void *context_data, const char *path, struct auth_session_info *session_info, struct stream_connection *srv_conn, TALLOC_CTX *mem_ctx, void **private_data)
-{
-       *private_data = talloc_zero(mem_ctx, DATA_BLOB);
-
-       return NT_STATUS_OK;
-}
-
-static NTSTATUS echo_pipe_trans(void *private_data, DATA_BLOB *in, DATA_BLOB *out)
-{
-       memcpy(out->data, in->data, MIN(out->length,in->length));
-
-       return NT_STATUS_OK;
-}
-
-static NTSTATUS echo_pipe_write(void *private_data, DATA_BLOB *out)
-{
-       DATA_BLOB *cache = private_data;
-       return data_blob_append(cache, cache, out->data, out->length);
-}
-
-static NTSTATUS echo_pipe_read(void *private_data, DATA_BLOB *in)
-{
-       uint8_t *newdata;
-       DATA_BLOB *cache = private_data;
-       uint32_t numread = MIN(in->length, cache->length);
-
-       memcpy(in->data, cache->data, numread);
-
-       cache->length -= numread;
-       newdata = talloc_memdup(cache, cache+numread, cache->length);
-       if (newdata == NULL)
-               return NT_STATUS_NO_MEMORY;
-
-       talloc_free(cache->data);
-       cache->data = newdata;
-
-       return NT_STATUS_OK;
-}
-
-const struct named_pipe_ops echo_pipe_ops = {
-       .open = echo_pipe_open,
-       .write = echo_pipe_write,
-       .read = echo_pipe_read,
-       .trans = echo_pipe_trans
-};
-
-NTSTATUS np_echo_init(void)
-{
-       return named_pipe_listen("\\PIPE\\NPECHO", &echo_pipe_ops, NULL);
-}
index bde87684e13af7139bd5449b2db1070bec35eb26..dd7994c1fb851c04c2b8bd584044064eff1ad79f 100644 (file)
@@ -4,7 +4,6 @@
 
    Copyright (C) Andrew Tridgell 2003
    Copyright (C) Stefan (metze) Metzmacher 2004-2005
-   Copyright (C) Jelmer Vernooij 2005
 
    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
 #include "includes.h"
 #include "dlinklist.h"
 #include "smb_server/smb_server.h"
-#include "ntvfs/ipc/ipc.h"
 #include "ntvfs/ntvfs.h"
 #include "rpc_server/dcerpc_server.h"
-#include "smb_build.h"
 
 #define IPC_BASE_FNUM 0x400
 
@@ -49,9 +46,8 @@ struct ipc_private {
                struct pipe_state *next, *prev;
                struct ipc_private *private;
                const char *pipe_name;
-               const struct named_pipe_ops *ops;
-               void *private_data;
                uint16_t fnum;
+               struct dcesrv_connection *dce_conn;
                uint16_t ipc_state;
                /* we need to remember the session it was opened on,
                   as it is illegal to operate on someone elses fnum */
@@ -80,6 +76,7 @@ static struct pipe_state *pipe_state_find(struct ipc_private *private, uint16_t
 static NTSTATUS ipc_connect(struct ntvfs_module_context *ntvfs,
                            struct smbsrv_request *req, const char *sharename)
 {
+       NTSTATUS status;
        struct smbsrv_tcon *tcon = req->tcon;
        struct ipc_private *private;
 
@@ -100,6 +97,10 @@ static NTSTATUS ipc_connect(struct ntvfs_module_context *ntvfs,
        private->idtree_fnum = idr_init(private);
        NT_STATUS_HAVE_NO_MEMORY(private->idtree_fnum);
 
+       /* setup the DCERPC server subsystem */
+       status = dcesrv_init_ipc_context(private, &private->dcesrv);
+       NT_STATUS_NOT_OK_RETURN(status);
+
        return NT_STATUS_OK;
 }
 
@@ -170,55 +171,6 @@ static int ipc_fd_destructor(void *ptr)
        return 0;
 }
 
-static struct named_pipe {
-       struct named_pipe *prev, *next;
-       const char *name;
-       const struct named_pipe_ops *ops;
-       void *context_data;
-} *named_pipes = NULL;
-
-static NTSTATUS find_pipe_ops(const char *fname, const struct named_pipe_ops **ops, void **context_data)
-{
-       struct named_pipe *np;
-
-       for (np = named_pipes; np; np = np->next) {
-               if (strcasecmp_m(np->name, fname) == 0) {
-                       if (ops) *ops = np->ops;
-                       if (context_data) *context_data = np->context_data;
-                       return NT_STATUS_OK;
-               }
-       }
-
-       return NT_STATUS_OBJECT_NAME_NOT_FOUND;
-}
-
-NTSTATUS named_pipe_listen(const char *name, const struct named_pipe_ops *ops, void *context_data)
-{
-       NTSTATUS status;
-       struct named_pipe *np;
-       DEBUG(3, ("Registering named pipe `%s'\n", name));
-
-       status = find_pipe_ops(name, NULL, NULL);
-       if (NT_STATUS_IS_OK(status)) {
-               return NT_STATUS_OBJECT_NAME_COLLISION;
-       }
-
-       if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
-               return status;
-       }
-
-       np = talloc(talloc_autofree_context(), struct named_pipe);
-       np->name = talloc_strdup(np, name);
-       np->ops = ops;
-       np->context_data = context_data;
-       np->prev = np->next = NULL;
-
-       DLIST_ADD(named_pipes, np);
-
-       return NT_STATUS_OK;
-}
-
-
 
 /*
   open a file backend - used for MSRPC pipes
@@ -229,9 +181,10 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs,
 {
        struct pipe_state *p;
        NTSTATUS status;
+       struct dcerpc_binding *ep_description;
        struct ipc_private *private = ntvfs->private_data;
-       void *context_data;
        int fnum;
+       struct stream_connection *srv_conn = req->smb_conn->connection;
 
        if (!req->session || !req->session->session_info) {
                return NT_STATUS_ACCESS_DENIED;
@@ -240,24 +193,14 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs,
        p = talloc(req, struct pipe_state);
        NT_STATUS_HAVE_NO_MEMORY(p);
 
+       ep_description = talloc(req, struct dcerpc_binding);
+       NT_STATUS_HAVE_NO_MEMORY(ep_description);
+
        while (fname[0] == '\\') fname++;
-       
+
        p->pipe_name = talloc_asprintf(p, "\\pipe\\%s", fname);
        NT_STATUS_HAVE_NO_MEMORY(p->pipe_name);
 
-       status = find_pipe_ops(p->pipe_name, &p->ops, &context_data);
-
-       /* FIXME: Perhaps fall back to opening /var/lib/samba/ipc/<pipename> ? */
-       if (NT_STATUS_IS_ERR(status)) {
-               DEBUG(0, ("Unable to find pipe ops for `%s'\n", p->pipe_name));
-               return status;
-       }
-
-       status = p->ops->open(context_data, p->pipe_name, req->session->session_info, req->smb_conn->connection, p, &p->private_data);
-       if (NT_STATUS_IS_ERR(status)) {
-               return status;
-       }
-
        fnum = idr_get_new_above(private->idtree_fnum, p, IPC_BASE_FNUM, UINT16_MAX);
        if (fnum == -1) {
                return NT_STATUS_TOO_MANY_OPENED_FILES;
@@ -266,6 +209,29 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs,
        p->fnum = fnum;
        p->ipc_state = 0x5ff;
 
+       /*
+         we're all set, now ask the dcerpc server subsystem to open the 
+         endpoint. At this stage the pipe isn't bound, so we don't
+         know what interface the user actually wants, just that they want
+         one of the interfaces attached to this pipe endpoint.
+       */
+       ep_description->transport = NCACN_NP;
+       ep_description->endpoint = talloc_reference(ep_description, p->pipe_name);
+
+       /* The session info is refcount-increased in the 
+        * dcesrv_endpoint_search_connect() function
+        */
+       status = dcesrv_endpoint_search_connect(private->dcesrv,
+                                               p,
+                                               ep_description, 
+                                               req->session->session_info,
+                                               srv_conn,
+                                               &p->dce_conn);
+       if (!NT_STATUS_IS_OK(status)) {
+               idr_remove(private->idtree_fnum, p->fnum);
+               return status;
+       }
+
        DLIST_ADD(private->pipe_list, p);
 
        p->smbpid = req->smbpid;
@@ -385,6 +351,18 @@ static NTSTATUS ipc_copy(struct ntvfs_module_context *ntvfs,
        return NT_STATUS_ACCESS_DENIED;
 }
 
+static NTSTATUS ipc_readx_dcesrv_output(void *private_data, DATA_BLOB *out, size_t *nwritten)
+{
+       DATA_BLOB *blob = private_data;
+
+       if (out->length < blob->length) {
+               blob->length = out->length;
+       }
+       memcpy(blob->data, out->data, blob->length);
+       *nwritten = blob->length;
+       return NT_STATUS_OK;
+}
+
 /*
   read from a file
 */
@@ -415,7 +393,7 @@ static NTSTATUS ipc_read(struct ntvfs_module_context *ntvfs,
        }
 
        if (data.length != 0) {
-               status = p->ops->read(p->private_data, &data);
+               status = dcesrv_output(p->dce_conn, &data, ipc_readx_dcesrv_output);
                if (NT_STATUS_IS_ERR(status)) {
                        return status;
                }
@@ -453,7 +431,7 @@ static NTSTATUS ipc_write(struct ntvfs_module_context *ntvfs,
                return NT_STATUS_INVALID_HANDLE;
        }
 
-       status = p->ops->write(p->private_data, &data);
+       status = dcesrv_input(p->dce_conn, &data);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
@@ -639,12 +617,30 @@ static NTSTATUS ipc_search_close(struct ntvfs_module_context *ntvfs,
        return NT_STATUS_ACCESS_DENIED;
 }
 
-/* SMBtrans - set named pipe state */
-static NTSTATUS ipc_np_set_nm_state(struct ntvfs_module_context *ntvfs,
-                               struct smbsrv_request *req, struct smb_trans2 *trans)
+static NTSTATUS ipc_trans_dcesrv_output(void *private_data, DATA_BLOB *out, size_t *nwritten)
+{
+       NTSTATUS status = NT_STATUS_OK;
+       DATA_BLOB *blob = private_data;
+
+       if (out->length > blob->length) {
+               status = STATUS_BUFFER_OVERFLOW;
+       }
+
+       if (out->length < blob->length) {
+               blob->length = out->length;
+       }
+       memcpy(blob->data, out->data, blob->length);
+       *nwritten = blob->length;
+       return status;
+}
+
+/* SMBtrans - handle a DCERPC command */
+static NTSTATUS ipc_dcerpc_cmd(struct ntvfs_module_context *ntvfs,
+                              struct smbsrv_request *req, struct smb_trans2 *trans)
 {
-       struct ipc_private *private = ntvfs->private_data;
        struct pipe_state *p;
+       struct ipc_private *private = ntvfs->private_data;
+       NTSTATUS status;
 
        /* the fnum is in setup[1] */
        p = pipe_state_find(private, trans->in.setup[1]);
@@ -652,25 +648,43 @@ static NTSTATUS ipc_np_set_nm_state(struct ntvfs_module_context *ntvfs,
                return NT_STATUS_INVALID_HANDLE;
        }
 
-       if (trans->in.params.length != 2) {
-               return NT_STATUS_INVALID_PARAMETER;
+       trans->out.data = data_blob_talloc(req, NULL, trans->in.max_data);
+       if (!trans->out.data.data) {
+               return NT_STATUS_NO_MEMORY;
+       }
+
+       /* pass the data to the dcerpc server. Note that we don'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->dce_conn, &trans->in.data);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
+       /*
+         now ask the dcerpc system for some output. This doesn't yet handle
+         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->dce_conn, &trans->out.data, ipc_trans_dcesrv_output);
+       if (NT_STATUS_IS_ERR(status)) {
+               return status;
        }
-       p->ipc_state = SVAL(trans->in.params.data, 0);
 
        trans->out.setup_count = 0;
        trans->out.setup = NULL;
        trans->out.params = data_blob(NULL, 0);
-       trans->out.data = data_blob(NULL, 0);
 
-       return NT_STATUS_OK;
+       return status;
 }
 
-/* SMBtrans - named pipe transaction */
-static NTSTATUS ipc_np_trans(struct ntvfs_module_context *ntvfs,
+
+/* SMBtrans - set named pipe state */
+static NTSTATUS ipc_set_nm_pipe_state(struct ntvfs_module_context *ntvfs,
                                struct smbsrv_request *req, struct smb_trans2 *trans)
 {
        struct ipc_private *private = ntvfs->private_data;
-       NTSTATUS status;
        struct pipe_state *p;
 
        /* the fnum is in setup[1] */
@@ -679,55 +693,50 @@ static NTSTATUS ipc_np_trans(struct ntvfs_module_context *ntvfs,
                return NT_STATUS_INVALID_HANDLE;
        }
 
-       if (trans->in.setup_count != 2) {
+       if (trans->in.params.length != 2) {
                return NT_STATUS_INVALID_PARAMETER;
        }
-       
-       trans->out.data = data_blob_talloc(req, NULL, trans->in.max_data);
-       if (!trans->out.data.data) {
-               return NT_STATUS_NO_MEMORY;
-       }
-       
-       status = p->ops->trans(p->private_data, &trans->in.data, &trans->out.data);
-       if (NT_STATUS_IS_ERR(status)) {
-               return status;
-       }
+       p->ipc_state = SVAL(trans->in.params.data, 0);
 
        trans->out.setup_count = 0;
        trans->out.setup = NULL;
        trans->out.params = data_blob(NULL, 0);
+       trans->out.data = data_blob(NULL, 0);
 
        return NT_STATUS_OK;
 }
 
+
 /* SMBtrans - used to provide access to SMB pipes */
 static NTSTATUS ipc_trans(struct ntvfs_module_context *ntvfs,
                                struct smbsrv_request *req, struct smb_trans2 *trans)
 {
        NTSTATUS status;
 
-       if (strequal(trans->in.trans_name, "\\PIPE\\")) { /* Named pipe */
-               switch (trans->in.setup[0]) {
-               case NAMED_PIPE_SETHANDLESTATE:
-                       status = ipc_np_set_nm_state(ntvfs, req, trans);
-                       break;
-               case NAMED_PIPE_TRANSACT:
-                       status = ipc_np_trans(ntvfs, req, trans);
-                       break;
-               default:
-                       status = NT_STATUS_INVALID_PARAMETER;
-                       break;
-               }
-       } else if (strequal(trans->in.trans_name, "\\PIPE\\LANMAN")) { /* RAP */
-               status = ipc_rap_call(req, trans);
-       } else {
-               DEBUG(1, ("Unknown transaction name `%s'\n", trans->in.trans_name));
-               status = NT_STATUS_NOT_SUPPORTED;
+       if (strequal(trans->in.trans_name, "\\PIPE\\LANMAN"))
+               return ipc_rap_call(req, trans);
+
+               if (trans->in.setup_count != 2) {
+               return NT_STATUS_INVALID_PARAMETER;
+       }
+
+       switch (trans->in.setup[0]) {
+       case TRANSACT_SETNAMEDPIPEHANDLESTATE:
+               status = ipc_set_nm_pipe_state(ntvfs, req, trans);
+               break;
+       case TRANSACT_DCERPCCMD:
+               status = ipc_dcerpc_cmd(ntvfs, req, trans);
+               break;
+       default:
+               status = NT_STATUS_INVALID_PARAMETER;
+               break;
        }
 
        return status;
 }
 
+
+
 /*
   initialialise the IPC backend, registering ourselves with the ntvfs subsystem
  */
@@ -735,9 +744,7 @@ NTSTATUS ntvfs_ipc_init(void)
 {
        NTSTATUS ret;
        struct ntvfs_ops ops;
-       init_module_fn static_init[] = STATIC_ntvfs_ipc_MODULES;
-       init_module_fn *shared_init;
-       
+
        ZERO_STRUCT(ops);
        
        /* fill in the name and type */
@@ -784,13 +791,5 @@ NTSTATUS ntvfs_ipc_init(void)
                return ret;
        }
 
-       /* load available named pipe backends */
-       shared_init = load_samba_modules(NULL, "np");
-
-       run_init_functions(static_init);
-       run_init_functions(shared_init);
-
-       talloc_free(shared_init);
-
        return ret;
 }
index 4aeb4f79c74c33d8f41f00fc5a0f71d21e22d459..73f61602bd447374ad0052a8de85d754b19bc5d3 100644 (file)
@@ -204,7 +204,6 @@ REQUIRED_SUBSYSTEMS = \
 PRIVATE_PROTO_HEADER = dcerpc_server_proto.h
 OBJ_FILES = \
                dcerpc_server.o \
-               dcerpc_np.o \
                dcerpc_sock.o \
                dcesrv_auth.o \
                handles.o
index a1da60f7f6b1b952edba617e95948d66fd08176c..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,167 +0,0 @@
-/* 
-   Unix SMB/CIFS implementation.
-   DCE/RPC over named pipes support (glue between dcerpc and smb servers)
-
-   Copyright (C) Jelmer Vernooij 2005
-
-   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 2 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, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#include "includes.h"
-#include "lib/socket/socket.h"
-#include "lib/events/events.h"
-#include "rpc_server/dcerpc_server.h"
-#include "ntvfs/ipc/ipc.h"
-
-static NTSTATUS dcesrv_pipe_open (void *context_data, const char *path, struct auth_session_info *session_info, struct stream_connection *srv_conn, TALLOC_CTX *mem_ctx, void **private_data)
-{
-       NTSTATUS status;
-       struct dcerpc_binding *ep_description;
-       struct dcesrv_connection *dce_conn;
-
-       ep_description = talloc(mem_ctx, struct dcerpc_binding);
-       NT_STATUS_HAVE_NO_MEMORY(ep_description);
-
-       /*
-         we're all set, now ask the dcerpc server subsystem to open the 
-         endpoint. At this stage the pipe isn't bound, so we don't
-         know what interface the user actually wants, just that they want
-         one of the interfaces attached to this pipe endpoint.
-       */
-       ep_description->transport = NCACN_NP;
-       ep_description->endpoint = talloc_reference(ep_description, path);
-
-       /* The session info is refcount-increased in the 
-        * dcesrv_endpoint_search_connect() function
-        */
-       status = dcesrv_endpoint_search_connect(context_data,
-                                               mem_ctx,
-                                               ep_description, 
-                                               session_info,
-                                               srv_conn,
-                                               &dce_conn);
-       talloc_free(ep_description);
-
-       if (!NT_STATUS_IS_OK(status)) {
-               return status;
-       }
-
-       *private_data = dce_conn;
-
-       return NT_STATUS_OK;
-}
-
-static NTSTATUS ipc_trans_dcesrv_output(void *private_data, DATA_BLOB *out, size_t *nwritten)
-{
-       NTSTATUS status = NT_STATUS_OK;
-       DATA_BLOB *blob = private_data;
-
-       if (out->length > blob->length) {
-               status = STATUS_BUFFER_OVERFLOW;
-       }
-
-       if (out->length < blob->length) {
-               blob->length = out->length;
-       }
-       memcpy(blob->data, out->data, blob->length);
-       *nwritten = blob->length;
-       return status;
-}
-
-
-static NTSTATUS dcesrv_pipe_trans(void *private_data, DATA_BLOB *in, DATA_BLOB *out)
-{
-       struct dcesrv_connection *dce_conn = private_data;
-       NTSTATUS status;
-
-       /* pass the data to the dcerpc server. Note that we don'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(dce_conn, in);
-       if (!NT_STATUS_IS_OK(status)) {
-               return status;
-       }
-
-       /*
-         now ask the dcerpc system for some output. This doesn't yet handle
-         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(dce_conn, out, ipc_trans_dcesrv_output);
-       if (NT_STATUS_IS_ERR(status)) {
-               return status;
-       }
-
-       return status;
-}
-
-static NTSTATUS dcesrv_pipe_write(void *private_data, DATA_BLOB *out)
-{
-       struct dcesrv_connection *dce_conn = private_data;
-       NTSTATUS status;
-       
-       status = dcesrv_input(dce_conn, out);
-       if (!NT_STATUS_IS_OK(status)) {
-               return status;
-       }
-       return status;
-}
-
-static NTSTATUS ipc_readx_dcesrv_output(void *private_data, DATA_BLOB *out, size_t *nwritten)
-{
-       DATA_BLOB *blob = private_data;
-
-       if (out->length < blob->length) {
-               blob->length = out->length;
-       }
-       memcpy(blob->data, out->data, blob->length);
-       *nwritten = blob->length;
-       return NT_STATUS_OK;
-}
-
-               
-static NTSTATUS dcesrv_pipe_read(void *private_data, DATA_BLOB *in)
-{
-       struct dcesrv_connection *dce_conn = private_data;
-       NTSTATUS status;
-       
-       status = dcesrv_output(dce_conn, in, ipc_readx_dcesrv_output);
-       if (NT_STATUS_IS_ERR(status)) {
-               return status;
-       }
-
-       return status;
-}
-
-const struct named_pipe_ops dce_pipe_ops = {
-       .open = dcesrv_pipe_open,
-       .write = dcesrv_pipe_write,
-       .read = dcesrv_pipe_read,
-       .trans = dcesrv_pipe_trans
-};
-
-/* Add named pipe endpoint */
-NTSTATUS dcesrv_add_ep_np(struct dcesrv_context *dce_ctx, struct dcesrv_endpoint *e, struct event_context *event_ctx, const struct model_ops *model_ops)
-{
-       NTSTATUS status;
-
-       status = named_pipe_listen(e->ep_description->endpoint, &dce_pipe_ops, dce_ctx);
-       if (NT_STATUS_IS_ERR(status)) {
-               return status;
-       }
-
-       return NT_STATUS_OK;
-}
index 0c50c4aaaa7d7acb5a821f531fcb8238feb03b35..2aeb737f5e7e789205330f436719e05e7c5dea8b 100644 (file)
@@ -1171,6 +1171,21 @@ static NTSTATUS dcesrv_init_context(TALLOC_CTX *mem_ctx, const char **endpoint_s
        return NT_STATUS_OK;
 }
 
+/*
+  initialise the dcerpc server context for ncacn_np based services
+*/
+NTSTATUS dcesrv_init_ipc_context(TALLOC_CTX *mem_ctx, struct dcesrv_context **_dce_ctx)
+{
+       NTSTATUS status;
+       struct dcesrv_context *dce_ctx;
+
+       status = dcesrv_init_context(mem_ctx, lp_dcerpc_endpoint_servers(), 0, &dce_ctx);
+       NT_STATUS_NOT_OK_RETURN(status);
+
+       *_dce_ctx = dce_ctx;
+       return NT_STATUS_OK;
+}
+
 /* the list of currently registered DCERPC endpoint servers.
  */
 static struct ep_server {
@@ -1290,8 +1305,8 @@ static NTSTATUS dcesrv_init(struct event_context *event_context, const struct mo
                        break;
                        
                case NCACN_NP:
-                       status = dcesrv_add_ep_np(dce_ctx, e, event_context, model_ops);
-                       NT_STATUS_NOT_OK_RETURN(status);
+/*                     FIXME: status = dcesrv_add_ep_np(dce_ctx, e, event_context, model_ops);
+                       NT_STATUS_NOT_OK_RETURN(status); */
                        break;
 
                default:
index 8e1c138c8f5827c114c36f348700a2b1e0fdfd56..6c8e77a151f214c2148d48f7893ad6f4da5afc81 100755 (executable)
@@ -23,7 +23,7 @@ tests="$tests BASE-DIR2 BASE-TCON BASE-OPEN"
 tests="$tests BASE-CHKPATH RAW-QFSINFO RAW-QFILEINFO RAW-SFILEINFO"
 tests="$tests RAW-LOCK RAW-MKDIR RAW-SEEK RAW-OPEN RAW-WRITE"
 tests="$tests RAW-UNLINK RAW-READ RAW-CLOSE RAW-IOCTL RAW-RENAME"
-tests="$tests RAW-EAS RAW-STREAMS RAW-ACLS RAW-PIPE-ECHO"
+tests="$tests RAW-EAS RAW-STREAMS RAW-ACLS"
 
 failed=0
 for t in $tests; do
index 8d022cdce2e8d65ce861462a3fb1db3807ce24b2..c7e8e2cc4828e5d542c303d98371f6f5e66fbcd1 100644 (file)
@@ -121,14 +121,13 @@ REQUIRED_SUBSYSTEMS = \
 #################################
 
 #################################
-# Start SUBSYSTEM TORTURE_IPC
-[SUBSYSTEM::TORTURE_IPC]
+# Start SUBSYSTEM TORTURE_RAP
+[SUBSYSTEM::TORTURE_RAP]
 OBJ_FILES = \
-               ipc/rap.o \
-               ipc/np_echo.o 
+               rap/rap.o
 REQUIRED_SUBSYSTEMS = \
                LIBSMB
-# End SUBSYSTEM TORTURE_IPC
+# End SUBSYSTEM TORTURE_RAP
 #################################
 
 #################################
@@ -211,7 +210,7 @@ REQUIRED_SUBSYSTEMS = \
                TORTURE_RAW \
                TORTURE_SMB2 \
                TORTURE_RPC \
-               TORTURE_IPC \
+               TORTURE_RAP \
                TORTURE_AUTH \
                TORTURE_LOCAL \
                TORTURE_NBENCH \
index 7d81d4fd37b768e1f10bf8df9430d9b6b1e3a5a6..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,119 +0,0 @@
-/* 
-   Unix SMB/CIFS implementation.
-   Named Pipe Echo test
-   Copyright (C) Jelmer Vernooij 2005
-   
-   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 2 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, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#include "includes.h"
-#include "librpc/gen_ndr/security.h"
-#include "smb.h"
-#include "torture/torture.h"
-#include "libcli/raw/libcliraw.h"
-#include "libcli/libcli.h"
-
-#define ECHODATA "Good Times, Bad Times"
-
-int torture_np_echo(void)
-{
-       NTSTATUS status;
-       TALLOC_CTX *mem_ctx = NULL;
-       struct smbcli_state *cli;
-       const char *pipe_name = "\\NPECHO";
-       union smb_open open;
-       union smb_read read;
-       union smb_write write;
-       union smb_close close;
-       int fnum;
-       BOOL ret;
-
-       ret = torture_open_connection_share(mem_ctx, &cli, 
-                                  lp_parm_string(-1, "torture", "host"), 
-                                  "IPC$",
-                                  NULL);
-       if (!ret)
-               return False;
-
-       open.ntcreatex.level = RAW_OPEN_NTCREATEX;
-       open.ntcreatex.in.flags = 0;
-       open.ntcreatex.in.root_fid = 0;
-       open.ntcreatex.in.access_mask = 
-               SEC_STD_READ_CONTROL |
-               SEC_FILE_WRITE_ATTRIBUTE |
-               SEC_FILE_WRITE_EA |
-               SEC_FILE_READ_DATA |
-               SEC_FILE_WRITE_DATA;
-       open.ntcreatex.in.file_attr = 0;
-       open.ntcreatex.in.alloc_size = 0;
-       open.ntcreatex.in.share_access = 
-               NTCREATEX_SHARE_ACCESS_READ |
-               NTCREATEX_SHARE_ACCESS_WRITE;
-       open.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
-       open.ntcreatex.in.create_options = 0;
-       open.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_IMPERSONATION;
-       open.ntcreatex.in.security_flags = 0;
-       open.ntcreatex.in.fname = pipe_name;
-
-       status = smb_raw_open(cli->tree, cli->tree, &open);
-       if (NT_STATUS_IS_ERR(status))
-               return False;
-
-       fnum = open.ntcreatex.out.fnum;
-       
-       write.write.level = RAW_WRITE_WRITE;
-       write.write.in.fnum = fnum;
-       write.write.in.count = strlen(ECHODATA);
-       write.write.in.offset = 0;
-       write.write.in.remaining = 0;
-       write.write.in.data = (const uint8_t *)ECHODATA;
-
-       status = smb_raw_write(cli->tree, &write);
-       if (NT_STATUS_IS_ERR(status))
-               return False;
-
-       if (write.write.out.nwritten != strlen(ECHODATA))
-               return False;
-
-       read.read.level = RAW_READ_READ;
-       read.read.in.fnum = fnum;
-       read.read.in.count = strlen(ECHODATA);
-       read.read.in.offset = 0;
-       read.read.in.remaining = 0;
-       read.read.out.data = talloc_array(mem_ctx, uint8_t, strlen(ECHODATA));
-
-       status = smb_raw_read(cli->tree, &read);
-
-       if (NT_STATUS_IS_ERR(status))
-               return False;
-
-       if (read.read.out.nread != strlen(ECHODATA))
-               return False;
-
-       if (memcmp(read.read.out.data, ECHODATA, strlen(ECHODATA)) != 0) {
-               printf ("np_echo: Returned data did not match!\n");
-               return False;
-       }
-
-       close.close.level = RAW_CLOSE_CLOSE;
-       close.close.in.fnum = fnum;
-       close.close.in.write_time = 0;
-
-       status = smb_raw_close(cli->tree, &close);
-       if (NT_STATUS_IS_ERR(status)) 
-               return False;
-
-       return True;
-}
index 24cf1bb6429f87e6b720019faa0363e58d830570..52fc100b2354398a8111e1f547dc42cee23b0faf 100644 (file)
@@ -21,9 +21,6 @@
 
 #include "includes.h"
 #include "rap.h"
-#include "libcli/raw/libcliraw.h"
-#include "libcli/libcli.h"
-#include "torture/torture.h"
 
 struct rap_call {
        uint16_t callno;
index 465c703dc815a1dad6d0be4efc7a3633413255e4..a37fde693888489eec3e76ff6f7545634777f658 100644 (file)
@@ -2246,7 +2246,6 @@ static struct {
        {"RAW-ACLS", torture_raw_acls, 0},
        {"RAW-RAP", torture_raw_rap, 0},
        {"RAW-COMPOSITE", torture_raw_composite, 0},
-       {"RAW-PIPE-ECHO", torture_np_echo, 0 },
 
        /* SMB2 tests */
        {"SMB2-CONNECT", torture_smb2_connect, 0},