Author: jelmer Date: 2007-01-16 14:44:23 +0000 (Tue, 16 Jan 2007) New Revision: 20830
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=20830 Log: merge mgmt work Added: branches/SAMBA_4_0/source/rpc_server/dcesrv_mgmt.c Removed: branches/SAMBA_4_0/source/rpc_server/mgmt/ Modified: branches/SAMBA_4_0/ branches/SAMBA_4_0/source/librpc/idl/mgmt.idl branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm branches/SAMBA_4_0/source/rpc_server/config.mk branches/SAMBA_4_0/source/rpc_server/dcerpc_server.c branches/SAMBA_4_0/source/script/tests/test_rpc.sh branches/SAMBA_4_0/source/torture/rpc/mgmt.c Changeset: Property changes on: branches/SAMBA_4_0 ___________________________________________________________________ Name: bzr:merge - [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] + [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] Modified: branches/SAMBA_4_0/source/librpc/idl/mgmt.idl =================================================================== --- branches/SAMBA_4_0/source/librpc/idl/mgmt.idl 2007-01-16 14:32:56 UTC (rev 20829) +++ branches/SAMBA_4_0/source/librpc/idl/mgmt.idl 2007-01-16 14:44:23 UTC (rev 20830) @@ -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 @@ /***********************/ /* 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 ); Modified: branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm =================================================================== --- branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm 2007-01-16 14:32:56 UTC (rev 20829) +++ branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm 2007-01-16 14:44:23 UTC (rev 20830) @@ -186,7 +186,7 @@ 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 @@ 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 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_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; } Modified: branches/SAMBA_4_0/source/rpc_server/config.mk =================================================================== --- branches/SAMBA_4_0/source/rpc_server/config.mk 2007-01-16 14:32:56 UTC (rev 20829) +++ branches/SAMBA_4_0/source/rpc_server/config.mk 2007-01-16 14:44:23 UTC (rev 20830) @@ -35,17 +35,6 @@ ################################################ ################################################ -# 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 @@ dcerpc_server.o \ dcerpc_sock.o \ dcesrv_auth.o \ + dcesrv_mgmt.o \ handles.o PUBLIC_DEPENDENCIES = \ LIBCLI_AUTH \ Modified: branches/SAMBA_4_0/source/rpc_server/dcerpc_server.c =================================================================== --- branches/SAMBA_4_0/source/rpc_server/dcerpc_server.c 2007-01-16 14:32:56 UTC (rev 20829) +++ branches/SAMBA_4_0/source/rpc_server/dcerpc_server.c 2007-01-16 14:44:23 UTC (rev 20830) @@ -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 @@ 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 */ Copied: branches/SAMBA_4_0/source/rpc_server/dcesrv_mgmt.c (from rev 20829, branches/SAMBA_4_0/source/rpc_server/mgmt/dcesrv_mgmt.c) =================================================================== --- branches/SAMBA_4_0/source/rpc_server/mgmt/dcesrv_mgmt.c 2007-01-16 14:32:56 UTC (rev 20829) +++ branches/SAMBA_4_0/source/rpc_server/dcesrv_mgmt.c 2007-01-16 14:44:23 UTC (rev 20830) @@ -0,0 +1,103 @@ +/* + Unix SMB/CIFS implementation. + + endpoint server for the mgmt pipe + + Copyright (C) Jelmer Vernooij 2006 + + 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 "rpc_server/dcerpc_server.h" +#include "librpc/gen_ndr/ndr_mgmt.h" +#include "rpc_server/common/common.h" + +/* + mgmt_inq_if_ids +*/ +static WERROR mgmt_inq_if_ids(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, + struct mgmt_inq_if_ids *r) +{ + 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; +} + + +/* + mgmt_inq_stats +*/ +static WERROR mgmt_inq_stats(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, + struct mgmt_inq_stats *r) +{ + 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; +} + + +/* + mgmt_is_server_listening +*/ +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 = 0; + return 1; +} + + +/* + mgmt_stop_server_listening +*/ +static WERROR mgmt_stop_server_listening(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, + struct mgmt_stop_server_listening *r) +{ + return WERR_ACCESS_DENIED; +} + + +/* + mgmt_inq_princ_name +*/ +static WERROR mgmt_inq_princ_name(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, + struct mgmt_inq_princ_name *r) +{ + DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); +} + + +/* include the generated boilerplate */ +#include "librpc/gen_ndr/ndr_mgmt_s.c" Modified: branches/SAMBA_4_0/source/script/tests/test_rpc.sh =================================================================== --- branches/SAMBA_4_0/source/script/tests/test_rpc.sh 2007-01-16 14:32:56 UTC (rev 20829) +++ branches/SAMBA_4_0/source/script/tests/test_rpc.sh 2007-01-16 14:44:23 UTC (rev 20830) @@ -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" Modified: branches/SAMBA_4_0/source/torture/rpc/mgmt.c =================================================================== --- branches/SAMBA_4_0/source/torture/rpc/mgmt.c 2007-01-16 14:32:56 UTC (rev 20829) +++ branches/SAMBA_4_0/source/torture/rpc/mgmt.c 2007-01-16 14:44:23 UTC (rev 20830) @@ -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 @@ 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 @@ { 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 @@ 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 @@ { 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 @@ 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; }