rpcdump.exe now works fine against a Samba4 server
authorAndrew Tridgell <tridge@samba.org>
Sat, 13 Dec 2003 04:46:50 +0000 (04:46 +0000)
committerAndrew Tridgell <tridge@samba.org>
Sat, 13 Dec 2003 04:46:50 +0000 (04:46 +0000)
for some reason the epm_Lookup replies can't be parsed by ethereal,
although w2k parses then fine as does the Samba4 NDR code.
(This used to be commit 097e7ca99d947932df5674c36e628ca6b8f31d3a)

source4/librpc/idl/epmapper.idl
source4/ntvfs/ipc/vfs_ipc.c
source4/rpc_server/dcerpc_server.c
source4/rpc_server/dcerpc_server.h
source4/rpc_server/epmapper/rpc_epmapper.c

index 59c542255d29cf929e5ef7f285635bdf0ba4d31a..79fb7f3dd1ec8ac10471275d015774f6a95441a5 100644 (file)
@@ -20,6 +20,9 @@ interface epmapper
          with.
        */
 
+       const int EPMAPPER_STATUS_NO_MORE_ENTRIES = 0x16c9a0d6;
+
+
        /* this guid indicates NDR encoding in a protocol tower */
        const string NDR_GUID = "8a885d04-1ceb-11c9-9fe8-08002b104860";
        const string NDR_GUID_VERSION = 2;
@@ -123,8 +126,6 @@ interface epmapper
        /**********************/
        /* Function 0x03      */
 
-       const int EPMAPPER_MAP_FAILED = 0x16c9a0d6;
-
        typedef struct {
                epm_twr_t *twr;
        } epm_twr_p_t;
index b57e72f14afbff2f8c70d7f4bf741e46abe4031e..04825ec632f3b0ca4f46f95c7333fb5d23e379c6 100644 (file)
@@ -40,6 +40,7 @@ struct ipc_private {
                const char *pipe_name;
                uint16 fnum;
                struct dcesrv_state *pipe_state;
+               uint16 ipc_state;
        } *pipe_list;
 
 };
@@ -223,6 +224,7 @@ static NTSTATUS ipc_open(struct request_context *req, union smb_open *oi)
        while (p->pipe_name[0] == '\\') {
                p->pipe_name++;
        }
+       p->ipc_state = 0x5ff;
 
        /*
          we're all set, now ask the dcerpc server subsystem to open the 
@@ -250,6 +252,7 @@ static NTSTATUS ipc_open(struct request_context *req, union smb_open *oi)
 
        ZERO_STRUCT(oi->ntcreatex.out);
        oi->ntcreatex.out.fnum = p->fnum;
+       oi->ntcreatex.out.ipc_state = p->ipc_state;
 
        return NT_STATUS_OK;
 }
@@ -508,17 +511,12 @@ NTSTATUS ipc_search_close(struct request_context *req, union smb_search_close *i
 }
 
 
-/* SMBtrans - used to provide access to SMB pipes */
-static NTSTATUS ipc_trans(struct request_context *req, struct smb_trans2 *trans)
+/* SMBtrans - handle a DCERPC command */
+static NTSTATUS ipc_dcerpc_cmd(struct request_context *req, struct smb_trans2 *trans)
 {
        struct pipe_state *p;
        struct ipc_private *private = req->conn->ntvfs_private;
        NTSTATUS status;
-       
-       if (trans->in.setup_count != 2 ||
-           trans->in.setup[0] != TRANSACT_DCERPCCMD) {
-               return NT_STATUS_INVALID_PARAMETER;
-       }
 
        /* the fnum is in setup[1] */
        p = pipe_state_find(private, trans->in.setup[1]);
@@ -558,6 +556,57 @@ static NTSTATUS ipc_trans(struct request_context *req, struct smb_trans2 *trans)
 }
 
 
+/* SMBtrans - set named pipe state */
+static NTSTATUS ipc_set_nm_pipe_state(struct request_context *req, struct smb_trans2 *trans)
+{
+       struct pipe_state *p;
+       struct ipc_private *private = req->conn->ntvfs_private;
+
+       /* the fnum is in setup[1] */
+       p = pipe_state_find(private, trans->in.setup[1]);
+       if (!p) {
+               return NT_STATUS_INVALID_HANDLE;
+       }
+
+       if (trans->in.params.length != 2) {
+               return NT_STATUS_INVALID_PARAMETER;
+       }
+       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 request_context *req, struct smb_trans2 *trans)
+{
+       NTSTATUS status;
+
+               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(req, trans);
+               break;
+       case TRANSACT_DCERPCCMD:
+               status = ipc_dcerpc_cmd(req, trans);
+               break;
+       default:
+               status = NT_STATUS_INVALID_PARAMETER;
+               break;
+       }
+
+       return status;
+}
+
+
 
 /*
   initialialise the IPC backend, registering ourselves with the ntvfs subsystem
index 35661d913e6cb79fa475b492945374975ac1bca7..67b36cdc48391863cb1a28ab654a09101c69fe63 100644 (file)
@@ -651,6 +651,7 @@ int dcesrv_lookup_endpoints(const struct dcerpc_interface_table *table,
                return -1;
        }
 
+       (*e)->name = table->name;
        (*e)->uuid = table->uuid;
        (*e)->if_version = table->if_version;
        (*e)->endpoint.type = ENDPOINT_SMB;
index 3f2f5d039f35631b9cfabf3d61d1dfc2ba4174e6..83e0ee249ab15144a8f05926a0c4e8da7f337b30 100644 (file)
@@ -35,6 +35,7 @@ struct dcesrv_endpoint {
 
 /* a endpoint combined with an interface description */
 struct dcesrv_ep_iface {
+       const char *name;
        struct dcesrv_endpoint endpoint;
        const char *uuid;
        uint32 if_version;
index c5bd2ffa455f1c4c379e26bca102bd29e0213d85..2898a7015993d2bf6fe375baa30c9b3dd170884e 100644 (file)
@@ -72,14 +72,14 @@ static BOOL fill_protocol_tower(TALLOC_CTX *mem_ctx, struct epm_towers *twr,
        twr->floors[3].lhs.info.lhs_data = data_blob(NULL, 0);
        twr->floors[3].rhs.rhs_data.data = talloc_asprintf(mem_ctx, "\\PIPE\\%s", 
                                                           e->endpoint.info.smb_pipe);
-       twr->floors[3].rhs.rhs_data.length = strlen(twr->floors[3].rhs.rhs_data.data);
+       twr->floors[3].rhs.rhs_data.length = strlen(twr->floors[3].rhs.rhs_data.data)+1;
        
        /* on an NetBIOS link ... */
        twr->floors[4].lhs.protocol = EPM_PROTOCOL_NETBIOS;
        twr->floors[4].lhs.info.lhs_data = data_blob(NULL, 0);
        twr->floors[4].rhs.rhs_data.data = talloc_asprintf(mem_ctx, "\\\\%s", 
                                                           lp_netbios_name());
-       twr->floors[4].rhs.rhs_data.length = strlen(twr->floors[4].rhs.rhs_data.data);
+       twr->floors[4].rhs.rhs_data.length = strlen(twr->floors[4].rhs.rhs_data.data)+1;
 
        return True;
 }
@@ -175,6 +175,9 @@ static NTSTATUS epm_Lookup(struct dcesrv_state *dce, TALLOC_CTX *mem_ctx,
 
        if (num_ents == 0) {
                r->out.entries = NULL;
+               r->out.status  = EPMAPPER_STATUS_NO_MORE_ENTRIES;
+               ZERO_STRUCTP(r->out.entry_handle);
+               dcesrv_handle_destroy(dce, h);
                return NT_STATUS_OK;
        }
 
@@ -185,7 +188,7 @@ static NTSTATUS epm_Lookup(struct dcesrv_state *dce, TALLOC_CTX *mem_ctx,
 
        for (i=0;i<num_ents;i++) {
                ZERO_STRUCT(r->out.entries[i].object);
-               r->out.entries[i].annotation = "";
+               r->out.entries[i].annotation = eps->e[i].name;
                r->out.entries[i].tower = talloc_p(mem_ctx, struct epm_twr_t);
                if (!r->out.entries[i].tower) {
                        return NT_STATUS_NO_MEMORY;
@@ -270,7 +273,7 @@ static NTSTATUS epm_Map(struct dcesrv_state *dce, TALLOC_CTX *mem_ctx,
 
 failed:
        r->out.num_towers = 0;
-       r->out.status = EPMAPPER_MAP_FAILED;
+       r->out.status = EPMAPPER_STATUS_NO_MORE_ENTRIES;
        r->out.towers->twr = NULL;
 
        return NT_STATUS_OK;