summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-01-16 14:44:23 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:43:37 -0500
commit615895332a73ad372bcb5918190cbfff6ba83e05 (patch)
tree2fb83d0261a06e4f154602cc5efc5e074594b8c8 /source4
parent97467edea3cb54994a18896f88dae4c843e6ff7e (diff)
downloadsamba-615895332a73ad372bcb5918190cbfff6ba83e05.tar.gz
samba-615895332a73ad372bcb5918190cbfff6ba83e05.tar.bz2
samba-615895332a73ad372bcb5918190cbfff6ba83e05.zip
r20830: merge mgmt work
(This used to be commit 3cc299dbbe278936281f8e7071e6de8ec1bb219c)
Diffstat (limited to 'source4')
-rw-r--r--source4/librpc/idl/mgmt.idl3
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm14
-rw-r--r--source4/rpc_server/config.mk12
-rw-r--r--source4/rpc_server/dcerpc_server.c13
-rw-r--r--source4/rpc_server/dcesrv_mgmt.c (renamed from source4/rpc_server/mgmt/dcesrv_mgmt.c)33
-rwxr-xr-xsource4/script/tests/test_rpc.sh6
-rw-r--r--source4/torture/rpc/mgmt.c52
7 files changed, 83 insertions, 50 deletions
diff --git a/source4/librpc/idl/mgmt.idl b/source4/librpc/idl/mgmt.idl
index 2f6467af1d..8aae05e953 100644
--- a/source4/librpc/idl/mgmt.idl
+++ b/source4/librpc/idl/mgmt.idl
@@ -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
);
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm
index abc3b786b9..102b0fc769 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm
@@ -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;
}
diff --git a/source4/rpc_server/config.mk b/source4/rpc_server/config.mk
index cc676f9fd5..2f1428d10c 100644
--- a/source4/rpc_server/config.mk
+++ b/source4/rpc_server/config.mk
@@ -35,17 +35,6 @@ PUBLIC_DEPENDENCIES = NDR_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]
INIT_FUNCTION = dcerpc_server_remote_init
@@ -197,6 +186,7 @@ OBJ_FILES = \
dcerpc_server.o \
dcerpc_sock.o \
dcesrv_auth.o \
+ dcesrv_mgmt.o \
handles.o
PUBLIC_DEPENDENCIES = \
LIBCLI_AUTH \
diff --git a/source4/rpc_server/dcerpc_server.c b/source4/rpc_server/dcerpc_server.c
index 6233a2e088..6af4be9cc1 100644
--- a/source4/rpc_server/dcerpc_server.c
+++ b/source4/rpc_server/dcerpc_server.c
@@ -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 */
diff --git a/source4/rpc_server/mgmt/dcesrv_mgmt.c b/source4/rpc_server/dcesrv_mgmt.c
index 2996b7675e..1656050b59 100644
--- a/source4/rpc_server/mgmt/dcesrv_mgmt.c
+++ b/source4/rpc_server/dcesrv_mgmt.c
@@ -31,7 +31,19 @@
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;
}
diff --git a/source4/script/tests/test_rpc.sh b/source4/script/tests/test_rpc.sh
index 918f01b8de..228e5668b4 100755
--- a/source4/script/tests/test_rpc.sh
+++ b/source4/script/tests/test_rpc.sh
@@ -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"
diff --git a/source4/torture/rpc/mgmt.c b/source4/torture/rpc/mgmt.c
index 08804ec557..97b1d0462d 100644
--- a/source4/torture/rpc/mgmt.c
+++ b/source4/torture/rpc/mgmt.c
@@ -30,12 +30,15 @@
/*
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;
}