r20830: merge mgmt work
authorJelmer Vernooij <jelmer@samba.org>
Tue, 16 Jan 2007 14:44:23 +0000 (14:44 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:43:37 +0000 (14:43 -0500)
(This used to be commit 3cc299dbbe278936281f8e7071e6de8ec1bb219c)

source4/librpc/idl/mgmt.idl
source4/pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm
source4/rpc_server/config.mk
source4/rpc_server/dcerpc_server.c
source4/rpc_server/dcesrv_mgmt.c [moved from source4/rpc_server/mgmt/dcesrv_mgmt.c with 65% similarity]
source4/script/tests/test_rpc.sh
source4/torture/rpc/mgmt.c

index 2f6467af1dfe6f5548f37ca027b5f2c0c711ef0d..8aae05e9537d88b4686419b8b68e7412ebefd556 100644 (file)
@@ -6,7 +6,6 @@
   uuid("afa8bd80-7d8a-11c9-bef4-08002b102989"), 
   version(1.0),
   pointer_default(unique),
-  endpoint("ncalrpc:[EPMAPPER]", "ncacn_ip_tcp:[135]", "ncacn_np:[\\pipe\\epmapper]"),
   helpstring("DCE/RPC Remote Management")
 ] 
 interface mgmt
@@ -24,7 +23,7 @@ interface mgmt
        /***********************/
        /* Function 0x00       */
        WERROR mgmt_inq_if_ids (
-               [out,unique]       rpc_if_id_vector_t      *if_id_vector
+               [out]       rpc_if_id_vector_t      **if_id_vector
                );
 
 
index abc3b786b98f322f9fb0b4e8ffb751d1b8d7b5ed..102b0fc769f8f671c704c2b9a6e03844b4b6b77f 100644 (file)
@@ -186,7 +186,7 @@ static NTSTATUS $name\__op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_C
        return NT_STATUS_OK;
 }
 
-static const struct dcesrv_interface $name\_interface = {
+const struct dcesrv_interface dcesrv\_$name\_interface = {
        .name           = \"$name\",
        .syntax_id  = {".print_uuid($uuid).",$if_version},
        .bind           = $name\__op_bind,
@@ -217,7 +217,7 @@ static NTSTATUS $name\__op_init_server(struct dcesrv_context *dce_ctx, const str
                NTSTATUS ret;
                const char *name = dcerpc_table_$name.endpoints->names[i];
 
-               ret = dcesrv_interface_register(dce_ctx, name, &$name\_interface, NULL);
+               ret = dcesrv_interface_register(dce_ctx, name, &dcesrv_$name\_interface, NULL);
                if (!NT_STATUS_IS_OK(ret)) {
                        DEBUG(1,(\"$name\_op_init_server: failed to register endpoint \'%s\'\\n\",name));
                        return ret;
@@ -229,9 +229,9 @@ static NTSTATUS $name\__op_init_server(struct dcesrv_context *dce_ctx, const str
 
 static BOOL $name\__op_interface_by_uuid(struct dcesrv_interface *iface, const struct GUID *uuid, uint32_t if_version)
 {
-       if ($name\_interface.syntax_id.if_version == if_version &&
-               GUID_equal(\&$name\_interface.syntax_id.uuid, uuid)) {
-               memcpy(iface,&$name\_interface, sizeof(*iface));
+       if (dcesrv_$name\_interface.syntax_id.if_version == if_version &&
+               GUID_equal(\&dcesrv\_$name\_interface.syntax_id.uuid, uuid)) {
+               memcpy(iface,&dcesrv\_$name\_interface, sizeof(*iface));
                return True;
        }
 
@@ -240,8 +240,8 @@ static BOOL $name\__op_interface_by_uuid(struct dcesrv_interface *iface, const s
 
 static BOOL $name\__op_interface_by_name(struct dcesrv_interface *iface, const char *name)
 {
-       if (strcmp($name\_interface.name, name)==0) {
-               memcpy(iface,&$name\_interface, sizeof(*iface));
+       if (strcmp(dcesrv_$name\_interface.name, name)==0) {
+               memcpy(iface, &dcesrv_$name\_interface, sizeof(*iface));
                return True;
        }
 
index cc676f9fd58d6e9695506de3e14ea70f9a335cc8..2f1428d10c2d982551e97e8a7cd418d14d201efe 100644 (file)
@@ -34,17 +34,6 @@ PUBLIC_DEPENDENCIES = NDR_EPMAPPER
 # End MODULE dcerpc_epmapper
 ################################################
 
-################################################
-# Start MODULE dcerpc_mgmt
-[MODULE::dcerpc_mgmt]
-INIT_FUNCTION = dcerpc_server_mgmt_init
-SUBSYSTEM = dcerpc_server
-OBJ_FILES = \
-               mgmt/dcesrv_mgmt.o
-PUBLIC_DEPENDENCIES = NDR_MGMT
-# End MODULE dcerpc_mgmt
-################################################
-
 ################################################
 # Start MODULE dcerpc_remote
 [MODULE::dcerpc_remote]
@@ -197,6 +186,7 @@ OBJ_FILES = \
                dcerpc_server.o \
                dcerpc_sock.o \
                dcesrv_auth.o \
+               dcesrv_mgmt.o \
                handles.o
 PUBLIC_DEPENDENCIES = \
                LIBCLI_AUTH \
index 6233a2e088690f85e0a1c9c80997866d91089059..6af4be9cc14f53cac8300025267674f698109707 100644 (file)
@@ -35,6 +35,8 @@
 #include "libcli/security/security.h"
 #include "build.h"
 
+extern const struct dcesrv_interface dcesrv_mgmt_interface;
+
 /*
   see if two endpoints match
 */
@@ -178,6 +180,17 @@ _PUBLIC_ NTSTATUS dcesrv_interface_register(struct dcesrv_context *dce_ctx,
                ZERO_STRUCTP(ep);
                ep->ep_description = talloc_reference(ep, binding);
                add_ep = True;
+
+               /* add mgmt interface */
+               ifl = talloc(dce_ctx, struct dcesrv_if_list);
+               if (!ifl) {
+                       return NT_STATUS_NO_MEMORY;
+               }
+
+               memcpy(&(ifl->iface), &dcesrv_mgmt_interface, 
+                          sizeof(struct dcesrv_interface));
+
+               DLIST_ADD(ep->interface_list, ifl);
        }
 
        /* see if the interface is already registered on te endpoint */
similarity index 65%
rename from source4/rpc_server/mgmt/dcesrv_mgmt.c
rename to source4/rpc_server/dcesrv_mgmt.c
index 2996b7675efff3eec55f57d700edc8bab7187375..1656050b59ec531366b3cc834cf4eb9afa4c05e1 100644 (file)
 static WERROR mgmt_inq_if_ids(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct mgmt_inq_if_ids *r)
 {
-       DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
+       const struct dcesrv_endpoint *ep = dce_call->conn->endpoint;
+       struct dcesrv_if_list *l;
+       struct rpc_if_id_vector_t *vector;
+
+       vector = *r->out.if_id_vector = talloc(mem_ctx, struct rpc_if_id_vector_t);
+       vector->count = 0;
+       vector->if_id = NULL;
+       for (l = ep->interface_list; l; l = l->next) {
+               vector->count++;
+               vector->if_id = talloc_realloc(mem_ctx, vector->if_id, struct dcerpc_syntax_id_p, vector->count);
+               vector->if_id[vector->count-1].id = &l->iface.syntax_id;
+       }
+       return WERR_OK;
 }
 
 
@@ -41,7 +53,18 @@ static WERROR mgmt_inq_if_ids(struct dcesrv_call_state *dce_call, TALLOC_CTX *me
 static WERROR mgmt_inq_stats(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct mgmt_inq_stats *r)
 {
-       DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
+       if (r->in.max_count != MGMT_STATS_ARRAY_MAX_SIZE)
+               return WERR_NOT_SUPPORTED;
+
+       r->out.statistics->count = r->in.max_count;
+       r->out.statistics->statistics = talloc_array(mem_ctx, uint32_t, r->in.max_count);
+       /* FIXME */
+       r->out.statistics->statistics[MGMT_STATS_CALLS_IN] = 0;
+       r->out.statistics->statistics[MGMT_STATS_CALLS_OUT] = 0;
+       r->out.statistics->statistics[MGMT_STATS_PKTS_IN] = 0;
+       r->out.statistics->statistics[MGMT_STATS_PKTS_OUT] = 0;
+
+       return WERR_OK;
 }
 
 
@@ -51,8 +74,8 @@ static WERROR mgmt_inq_stats(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem
 static uint32_t mgmt_is_server_listening(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct mgmt_is_server_listening *r)
 {
-       *r->out.status = 1;
-       return 0;
+       *r->out.status = 0;
+       return 1;
 }
 
 
@@ -62,7 +85,7 @@ static uint32_t mgmt_is_server_listening(struct dcesrv_call_state *dce_call, TAL
 static WERROR mgmt_stop_server_listening(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct mgmt_stop_server_listening *r)
 {
-       DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
+       return WERR_ACCESS_DENIED;
 }
 
 
index 918f01b8def0d6bcb069053d817b594434338735..228e5668b45dd80bf2b85716627bab52b452af71 100755 (executable)
@@ -2,9 +2,9 @@
 
 # add tests to this list as they start passing, so we test
 # that they stay passing
-ncacn_np_tests="RPC-SPOOLSS RPC-SRVSVC RPC-UNIXINFO RPC-SCHANNEL RPC-JOIN RPC-LSA RPC-ECHO RPC-DSSETUP RPC-ALTERCONTEXT RPC-MULTIBIND RPC-NETLOGON"
-ncalrpc_tests="RPC-UNIXINFO RPC-SCHANNEL RPC-JOIN RPC-LSA RPC-ECHO RPC-DSSETUP RPC-ALTERCONTEXT RPC-MULTIBIND RPC-NETLOGON"
-ncacn_ip_tcp_tests="RPC-UNIXINFO RPC-SCHANNEL RPC-JOIN RPC-LSA RPC-ECHO RPC-DSSETUP RPC-ALTERCONTEXT RPC-MULTIBIND RPC-NETLOGON"
+ncacn_np_tests="RPC-SPOOLSS RPC-SRVSVC RPC-UNIXINFO RPC-SCHANNEL RPC-JOIN RPC-LSA RPC-ECHO RPC-DSSETUP RPC-ALTERCONTEXT RPC-MULTIBIND RPC-NETLOGON RPC-MGMT"
+ncalrpc_tests="RPC-MGMT RPC-UNIXINFO RPC-SCHANNEL RPC-JOIN RPC-LSA RPC-ECHO RPC-DSSETUP RPC-ALTERCONTEXT RPC-MULTIBIND RPC-NETLOGON"
+ncacn_ip_tcp_tests="RPC-UNIXINFO RPC-SCHANNEL RPC-JOIN RPC-LSA RPC-ECHO RPC-DSSETUP RPC-ALTERCONTEXT RPC-MULTIBIND RPC-NETLOGON RPC-MGMT"
 slow_ncacn_np_tests="RPC-SAMLOGON RPC-SAMR RPC-SAMR-USERS RPC-SAMR-PASSWORDS"
 slow_ncalrpc_tests="RPC-SAMLOGON RPC-SAMR RPC-SAMR-USERS RPC-SAMR-PASSWORDS"
 slow_ncacn_ip_tcp_tests="RPC-SAMLOGON RPC-SAMR RPC-SAMR-USERS RPC-SAMR-PASSWORDS"
index 08804ec557b528c37c4abaedfe7b4a7a6ef903c5..97b1d0462dcd557f7e8721b27f8ed182f4b3a660 100644 (file)
 /*
   ask the server what interface IDs are available on this endpoint
 */
-static BOOL test_inq_if_ids(struct dcerpc_pipe *p, 
-                           TALLOC_CTX *mem_ctx)
+static BOOL test_inq_if_ids(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
 {
        NTSTATUS status;
        struct mgmt_inq_if_ids r;
+       struct rpc_if_id_vector_t *vector;
        int i;
+
+       vector = talloc(mem_ctx, struct rpc_if_id_vector_t);
+       r.out.if_id_vector = &vector;
        
        status = dcerpc_mgmt_inq_if_ids(p, mem_ctx, &r);
        if (!NT_STATUS_IS_OK(status)) {
@@ -48,13 +51,13 @@ static BOOL test_inq_if_ids(struct dcerpc_pipe *p,
                return False;
        }
 
-       if (!r.out.if_id_vector) {
+       if (!vector) {
                printf("inq_if_ids gave NULL if_id_vector\n");
                return False;
        }
 
-       for (i=0;i<r.out.if_id_vector->count;i++) {
-               struct dcerpc_syntax_id *id = r.out.if_id_vector->if_id[i].id;
+       for (i=0;i<vector->count;i++) {
+               struct dcerpc_syntax_id *id = vector->if_id[i].id;
                if (!id) continue;
 
                printf("\tuuid %s  version 0x%08x  '%s'\n",
@@ -70,9 +73,11 @@ static BOOL test_inq_stats(struct dcerpc_pipe *p,
 {
        NTSTATUS status;
        struct mgmt_inq_stats r;
+       struct mgmt_statistics statistics;
 
        r.in.max_count = MGMT_STATS_ARRAY_MAX_SIZE;
        r.in.unknown = 0;
+       r.out.statistics = &statistics;
 
        status = dcerpc_mgmt_inq_stats(p, mem_ctx, &r);
        if (!NT_STATUS_IS_OK(status)) {
@@ -80,16 +85,16 @@ static BOOL test_inq_stats(struct dcerpc_pipe *p,
                return False;
        }
 
-       if (r.out.statistics->count != MGMT_STATS_ARRAY_MAX_SIZE) {
-               printf("Unexpected array size %d\n", r.out.statistics->count);
+       if (statistics.count != MGMT_STATS_ARRAY_MAX_SIZE) {
+               printf("Unexpected array size %d\n", statistics.count);
                return False;
        }
 
        printf("\tcalls_in %6d  calls_out %6d\n\tpkts_in  %6d  pkts_out  %6d\n",
-              r.out.statistics->statistics[MGMT_STATS_CALLS_IN],
-              r.out.statistics->statistics[MGMT_STATS_CALLS_OUT],
-              r.out.statistics->statistics[MGMT_STATS_PKTS_IN],
-              r.out.statistics->statistics[MGMT_STATS_PKTS_OUT]);
+              statistics.statistics[MGMT_STATS_CALLS_IN],
+              statistics.statistics[MGMT_STATS_CALLS_OUT],
+              statistics.statistics[MGMT_STATS_PKTS_IN],
+              statistics.statistics[MGMT_STATS_PKTS_OUT]);
 
        return True;
 }
@@ -135,6 +140,7 @@ static BOOL test_is_server_listening(struct dcerpc_pipe *p,
 {
        NTSTATUS status;
        struct mgmt_is_server_listening r;
+       r.out.status = talloc(mem_ctx, uint32_t);
 
        status = dcerpc_mgmt_is_server_listening(p, mem_ctx, &r);
        if (!NT_STATUS_IS_OK(status)) {
@@ -210,27 +216,29 @@ BOOL torture_rpc_mgmt(struct torture_context *torture)
 
                printf("\nTesting pipe '%s'\n", l->table->name);
 
-               if (b->transport == NCACN_IP_TCP) {
-                       status = dcerpc_epm_map_binding(loop_ctx, b, l->table, NULL);
-                       if (!NT_STATUS_IS_OK(status)) {
-                               printf("Failed to map port for uuid %s\n", 
-                                          GUID_string(loop_ctx, &l->table->syntax_id.uuid));
-                               talloc_free(loop_ctx);
-                               continue;
-                       }
-               } else {
-                       b->endpoint = talloc_strdup(b, l->table->name);
+               status = dcerpc_epm_map_binding(loop_ctx, b, l->table, NULL);
+               if (!NT_STATUS_IS_OK(status)) {
+                       printf("Failed to map port for uuid %s\n", 
+                                  GUID_string(loop_ctx, &l->table->syntax_id.uuid));
+                       talloc_free(loop_ctx);
+                       continue;
                }
 
                lp_set_cmdline("torture:binding", dcerpc_binding_string(loop_ctx, b));
 
                status = torture_rpc_connection(loop_ctx, &p, &dcerpc_table_mgmt);
+               if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
+                       printf("Interface not available - skipping\n");
+                       talloc_free(loop_ctx);
+                       continue;
+               }
+
                if (!NT_STATUS_IS_OK(status)) {
                        talloc_free(loop_ctx);
                        ret = False;
                        continue;
                }
-       
+
                if (!test_is_server_listening(p, loop_ctx)) {
                        ret = False;
                }