diff options
Diffstat (limited to 'source4/rpc_server')
-rw-r--r-- | source4/rpc_server/browser/dcesrv_browser.c | 172 | ||||
-rw-r--r-- | source4/rpc_server/config.mk | 37 | ||||
-rw-r--r-- | source4/rpc_server/dcerpc_server.c | 157 | ||||
-rw-r--r-- | source4/rpc_server/dcerpc_server.h | 2 | ||||
-rw-r--r-- | source4/rpc_server/netlogon/dcerpc_netlogon.c | 56 | ||||
-rw-r--r-- | source4/rpc_server/samr/dcesrv_samr.c | 21 | ||||
-rw-r--r-- | source4/rpc_server/service_rpc.c | 21 |
7 files changed, 370 insertions, 96 deletions
diff --git a/source4/rpc_server/browser/dcesrv_browser.c b/source4/rpc_server/browser/dcesrv_browser.c new file mode 100644 index 0000000000..33fed50857 --- /dev/null +++ b/source4/rpc_server/browser/dcesrv_browser.c @@ -0,0 +1,172 @@ +/* + Unix SMB/CIFS implementation. + + endpoint server for the browser pipe + + Copyright (C) Stefan Metzmacher 2008 + + 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 3 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, see <http://www.gnu.org/licenses/>. +*/ + +#include "includes.h" +#include "rpc_server/dcerpc_server.h" +#include "librpc/gen_ndr/ndr_browser.h" +#include "rpc_server/common/common.h" + + +/* + BrowserrServerEnum +*/ +static void dcesrv_BrowserrServerEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, + struct BrowserrServerEnum *r) +{ + DCESRV_FAULT_VOID(DCERPC_FAULT_OP_RNG_ERROR); +} + + +/* + BrowserrDebugCall +*/ +static void dcesrv_BrowserrDebugCall(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, + struct BrowserrDebugCall *r) +{ + DCESRV_FAULT_VOID(DCERPC_FAULT_OP_RNG_ERROR); +} + + +/* + BrowserrQueryOtherDomains +*/ +static WERROR dcesrv_BrowserrQueryOtherDomains(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, + struct BrowserrQueryOtherDomains *r) +{ + struct BrowserrSrvInfo100Ctr *ctr100; + + switch (r->in.info->level) { + case 100: + if (!r->in.info->info.info100) { + return WERR_INVALID_PARAM; + } + + ctr100 = talloc(mem_ctx, struct BrowserrSrvInfo100Ctr); + W_ERROR_HAVE_NO_MEMORY(ctr100); + + ctr100->entries_read = 0; + ctr100->entries = talloc_zero_array(ctr100, struct srvsvc_NetSrvInfo100, + ctr100->entries_read); + W_ERROR_HAVE_NO_MEMORY(ctr100->entries); + + r->out.info->info.info100 = ctr100; + *r->out.total_entries = ctr100->entries_read; + return WERR_OK; + default: + return WERR_UNKNOWN_LEVEL; + } + + return WERR_INVALID_PARAM; +} + + +/* + BrowserrResetNetlogonState +*/ +static void dcesrv_BrowserrResetNetlogonState(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, + struct BrowserrResetNetlogonState *r) +{ + DCESRV_FAULT_VOID(DCERPC_FAULT_OP_RNG_ERROR); +} + + +/* + BrowserrDebugTrace +*/ +static void dcesrv_BrowserrDebugTrace(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, + struct BrowserrDebugTrace *r) +{ + DCESRV_FAULT_VOID(DCERPC_FAULT_OP_RNG_ERROR); +} + + +/* + BrowserrQueryStatistics +*/ +static void dcesrv_BrowserrQueryStatistics(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, + struct BrowserrQueryStatistics *r) +{ + DCESRV_FAULT_VOID(DCERPC_FAULT_OP_RNG_ERROR); +} + + +/* + BrowserResetStatistics +*/ +static void dcesrv_BrowserResetStatistics(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, + struct BrowserResetStatistics *r) +{ + DCESRV_FAULT_VOID(DCERPC_FAULT_OP_RNG_ERROR); +} + + +/* + NetrBrowserStatisticsClear +*/ +static void dcesrv_NetrBrowserStatisticsClear(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, + struct NetrBrowserStatisticsClear *r) +{ + DCESRV_FAULT_VOID(DCERPC_FAULT_OP_RNG_ERROR); +} + + +/* + NetrBrowserStatisticsGet +*/ +static void dcesrv_NetrBrowserStatisticsGet(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, + struct NetrBrowserStatisticsGet *r) +{ + DCESRV_FAULT_VOID(DCERPC_FAULT_OP_RNG_ERROR); +} + + +/* + BrowserrSetNetlogonState +*/ +static void dcesrv_BrowserrSetNetlogonState(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, + struct BrowserrSetNetlogonState *r) +{ + DCESRV_FAULT_VOID(DCERPC_FAULT_OP_RNG_ERROR); +} + + +/* + BrowserrQueryEmulatedDomains +*/ +static void dcesrv_BrowserrQueryEmulatedDomains(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, + struct BrowserrQueryEmulatedDomains *r) +{ + DCESRV_FAULT_VOID(DCERPC_FAULT_OP_RNG_ERROR); +} + + +/* + BrowserrServerEnumEx +*/ +static void dcesrv_BrowserrServerEnumEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, + struct BrowserrServerEnumEx *r) +{ + DCESRV_FAULT_VOID(DCERPC_FAULT_OP_RNG_ERROR); +} + + +/* include the generated boilerplate */ +#include "librpc/gen_ndr/ndr_browser_s.c" diff --git a/source4/rpc_server/config.mk b/source4/rpc_server/config.mk index fb697d0c0f..76aa6b938a 100644 --- a/source4/rpc_server/config.mk +++ b/source4/rpc_server/config.mk @@ -17,7 +17,7 @@ PUBLIC_HEADERS += $(rpc_serversrcdir)/common/common.h # Start MODULE dcerpc_rpcecho [MODULE::dcerpc_rpcecho] INIT_FUNCTION = dcerpc_server_rpcecho_init -SUBSYSTEM = DCESRV +SUBSYSTEM = dcerpc_server PRIVATE_DEPENDENCIES = NDR_ECHO # End MODULE dcerpc_rpcecho ################################################ @@ -28,7 +28,7 @@ dcerpc_rpcecho_OBJ_FILES = $(rpc_serversrcdir)/echo/rpc_echo.o # Start MODULE dcerpc_epmapper [MODULE::dcerpc_epmapper] INIT_FUNCTION = dcerpc_server_epmapper_init -SUBSYSTEM = DCESRV +SUBSYSTEM = dcerpc_server PRIVATE_DEPENDENCIES = NDR_EPMAPPER # End MODULE dcerpc_epmapper ################################################ @@ -39,7 +39,7 @@ dcerpc_epmapper_OBJ_FILES = $(rpc_serversrcdir)/epmapper/rpc_epmapper.o # Start MODULE dcerpc_remote [MODULE::dcerpc_remote] INIT_FUNCTION = dcerpc_server_remote_init -SUBSYSTEM = DCESRV +SUBSYSTEM = dcerpc_server PRIVATE_DEPENDENCIES = \ LIBCLI_SMB NDR_TABLE # End MODULE dcerpc_remote @@ -51,7 +51,7 @@ dcerpc_remote_OBJ_FILES = $(rpc_serversrcdir)/remote/dcesrv_remote.o # Start MODULE dcerpc_srvsvc [MODULE::dcerpc_srvsvc] INIT_FUNCTION = dcerpc_server_srvsvc_init -SUBSYSTEM = DCESRV +SUBSYSTEM = dcerpc_server PRIVATE_DEPENDENCIES = \ DCERPC_COMMON NDR_SRVSVC share # End MODULE dcerpc_srvsvc @@ -66,7 +66,7 @@ $(eval $(call proto_header_template,$(rpc_serversrcdir)/srvsvc/proto.h,$(dcerpc_ # Start MODULE dcerpc_wkssvc [MODULE::dcerpc_wkssvc] INIT_FUNCTION = dcerpc_server_wkssvc_init -SUBSYSTEM = DCESRV +SUBSYSTEM = dcerpc_server PRIVATE_DEPENDENCIES = \ DCERPC_COMMON NDR_WKSSVC # End MODULE dcerpc_wkssvc @@ -78,7 +78,7 @@ dcerpc_wkssvc_OBJ_FILES = $(rpc_serversrcdir)/wkssvc/dcesrv_wkssvc.o # Start MODULE dcerpc_unixinfo [MODULE::dcerpc_unixinfo] INIT_FUNCTION = dcerpc_server_unixinfo_init -SUBSYSTEM = DCESRV +SUBSYSTEM = dcerpc_server PRIVATE_DEPENDENCIES = \ DCERPC_COMMON \ SAMDB \ @@ -94,7 +94,7 @@ dcerpc_unixinfo_OBJ_FILES = $(rpc_serversrcdir)/unixinfo/dcesrv_unixinfo.o # Start MODULE dcesrv_samr [MODULE::dcesrv_samr] INIT_FUNCTION = dcerpc_server_samr_init -SUBSYSTEM = DCESRV +SUBSYSTEM = dcerpc_server PRIVATE_DEPENDENCIES = \ SAMDB \ DCERPC_COMMON \ @@ -110,7 +110,7 @@ $(eval $(call proto_header_template,$(rpc_serversrcdir)/samr/proto.h,$(dcesrv_sa # Start MODULE dcerpc_winreg [MODULE::dcerpc_winreg] INIT_FUNCTION = dcerpc_server_winreg_init -SUBSYSTEM = DCESRV +SUBSYSTEM = dcerpc_server OUTPUT_TYPE = MERGED_OBJ PRIVATE_DEPENDENCIES = \ registry NDR_WINREG @@ -123,7 +123,7 @@ dcerpc_winreg_OBJ_FILES = $(rpc_serversrcdir)/winreg/rpc_winreg.o # Start MODULE dcerpc_netlogon [MODULE::dcerpc_netlogon] INIT_FUNCTION = dcerpc_server_netlogon_init -SUBSYSTEM = DCESRV +SUBSYSTEM = dcerpc_server PRIVATE_DEPENDENCIES = \ DCERPC_COMMON \ SCHANNELDB \ @@ -138,7 +138,7 @@ dcerpc_netlogon_OBJ_FILES = $(rpc_serversrcdir)/netlogon/dcerpc_netlogon.o # Start MODULE dcerpc_lsa [MODULE::dcerpc_lsarpc] INIT_FUNCTION = dcerpc_server_lsa_init -SUBSYSTEM = DCESRV +SUBSYSTEM = dcerpc_server PRIVATE_DEPENDENCIES = \ SAMDB \ DCERPC_COMMON \ @@ -157,7 +157,7 @@ $(eval $(call proto_header_template,$(rpc_serversrcdir)/lsa/proto.h,$(dcerpc_lsa # Start MODULE dcerpc_spoolss [MODULE::dcerpc_spoolss] INIT_FUNCTION = dcerpc_server_spoolss_init -SUBSYSTEM = DCESRV +SUBSYSTEM = dcerpc_server OUTPUT_TYPE = MERGED_OBJ PRIVATE_DEPENDENCIES = \ DCERPC_COMMON \ @@ -173,7 +173,7 @@ dcerpc_spoolss_OBJ_FILES = $(rpc_serversrcdir)/spoolss/dcesrv_spoolss.o # Start MODULE dcerpc_drsuapi [MODULE::dcerpc_drsuapi] INIT_FUNCTION = dcerpc_server_drsuapi_init -SUBSYSTEM = DCESRV +SUBSYSTEM = dcerpc_server PRIVATE_DEPENDENCIES = \ SAMDB \ DCERPC_COMMON \ @@ -184,6 +184,19 @@ PRIVATE_DEPENDENCIES = \ dcerpc_drsuapi_OBJ_FILES = $(rpc_serversrcdir)/drsuapi/dcesrv_drsuapi.o ################################################ +# Start MODULE dcerpc_browser +[MODULE::dcerpc_browser] +INIT_FUNCTION = dcerpc_server_browser_init +SUBSYSTEM = dcerpc_server +PRIVATE_DEPENDENCIES = \ + DCERPC_COMMON \ + NDR_BROWSER +# End MODULE dcerpc_browser +################################################ + +dcerpc_browser_OBJ_FILES = $(rpc_serversrcdir)/browser/dcesrv_browser.o + +################################################ # Start SUBSYSTEM dcerpc_server [SUBSYSTEM::dcerpc_server] PRIVATE_DEPENDENCIES = \ diff --git a/source4/rpc_server/dcerpc_server.c b/source4/rpc_server/dcerpc_server.c index 6e888e5259..5f055ae342 100644 --- a/source4/rpc_server/dcerpc_server.c +++ b/source4/rpc_server/dcerpc_server.c @@ -36,7 +36,7 @@ #include "libcli/security/security.h" #include "param/param.h" -#define SAMBA_ACCOC_GROUP 0x12345678 +#define SAMBA_ASSOC_GROUP 0x12345678 extern const struct dcesrv_interface dcesrv_mgmt_interface; @@ -288,26 +288,6 @@ _PUBLIC_ NTSTATUS dcesrv_fetch_session_key(struct dcesrv_connection *p, return NT_STATUS_OK; } - -/* - destroy a link to an endpoint -*/ -static int dcesrv_endpoint_destructor(struct dcesrv_connection *p) -{ - while (p->contexts) { - struct dcesrv_connection_context *c = p->contexts; - - DLIST_REMOVE(p->contexts, c); - - if (c->iface) { - c->iface->unbind(c, c->iface); - } - } - - return 0; -} - - /* connect to a dcerpc endpoint */ @@ -355,8 +335,6 @@ _PUBLIC_ NTSTATUS dcesrv_endpoint_connect(struct dcesrv_context *dce_ctx, p->state_flags = state_flags; ZERO_STRUCT(p->transport); - talloc_set_destructor(p, dcesrv_endpoint_destructor); - *_p = p; return NT_STATUS_OK; } @@ -531,6 +509,16 @@ static NTSTATUS dcesrv_bind_nak(struct dcesrv_call_state *call, uint32_t reason) return NT_STATUS_OK; } +static int dcesrv_connection_context_destructor(struct dcesrv_connection_context *c) +{ + DLIST_REMOVE(c->conn->contexts, c); + + if (c->iface) { + c->iface->unbind(c, c->iface); + } + + return 0; +} /* handle a bind request @@ -558,7 +546,8 @@ static NTSTATUS dcesrv_bind(struct dcesrv_call_state *call) * assoc_group_id back to the clients */ if (call->pkt.u.bind.assoc_group_id != 0 && - call->pkt.u.bind.assoc_group_id != SAMBA_ACCOC_GROUP) { + lp_parm_bool(call->conn->dce_ctx->lp_ctx, NULL, "dcesrv","assoc group checking", true) && + call->pkt.u.bind.assoc_group_id != SAMBA_ASSOC_GROUP) { return dcesrv_bind_nak(call, 0); } @@ -609,10 +598,29 @@ static NTSTATUS dcesrv_bind(struct dcesrv_call_state *call) context->conn = call->conn; context->iface = iface; context->context_id = context_id; + /* + * we need to send a non zero assoc_group_id here to make longhorn happy, + * it also matches samba3 + */ + context->assoc_group_id = SAMBA_ASSOC_GROUP; context->private = NULL; context->handles = NULL; DLIST_ADD(call->conn->contexts, context); call->context = context; + talloc_set_destructor(context, dcesrv_connection_context_destructor); + + status = iface->bind(call, iface); + if (!NT_STATUS_IS_OK(status)) { + char *uuid_str = GUID_string(call, &uuid); + DEBUG(2,("Request for dcerpc interface %s/%d rejected: %s\n", + uuid_str, if_version, nt_errstr(status))); + talloc_free(uuid_str); + /* we don't want to trigger the iface->unbind() hook */ + context->iface = NULL; + talloc_free(call->context); + call->context = NULL; + return dcesrv_bind_nak(call, 0); + } } if (call->conn->cli_max_recv_frag == 0) { @@ -627,6 +635,8 @@ static NTSTATUS dcesrv_bind(struct dcesrv_call_state *call) /* handle any authentication that is being requested */ if (!dcesrv_auth_bind(call)) { + talloc_free(call->context); + call->context = NULL; return dcesrv_bind_nak(call, DCERPC_BIND_REASON_INVALID_AUTH_TYPE); } @@ -638,8 +648,7 @@ static NTSTATUS dcesrv_bind(struct dcesrv_call_state *call) pkt.pfc_flags = DCERPC_PFC_FLAG_FIRST | DCERPC_PFC_FLAG_LAST | extra_flags; pkt.u.bind_ack.max_xmit_frag = 0x2000; pkt.u.bind_ack.max_recv_frag = 0x2000; - /* we need to send a non zero assoc_group_id here to make longhorn happy, it also matches samba3 */ - pkt.u.bind_ack.assoc_group_id = SAMBA_ACCOC_GROUP; + pkt.u.bind_ack.assoc_group_id = iface?call->context->assoc_group_id:0; if (iface) { /* FIXME: Use pipe name as specified by endpoint instead of interface name */ pkt.u.bind_ack.secondary_address = talloc_asprintf(call, "\\PIPE\\%s", iface->name); @@ -649,6 +658,8 @@ static NTSTATUS dcesrv_bind(struct dcesrv_call_state *call) pkt.u.bind_ack.num_results = 1; pkt.u.bind_ack.ctx_list = talloc(call, struct dcerpc_ack_ctx); if (!pkt.u.bind_ack.ctx_list) { + talloc_free(call->context); + call->context = NULL; return NT_STATUS_NO_MEMORY; } pkt.u.bind_ack.ctx_list[0].result = result; @@ -658,27 +669,22 @@ static NTSTATUS dcesrv_bind(struct dcesrv_call_state *call) status = dcesrv_auth_bind_ack(call, &pkt); if (!NT_STATUS_IS_OK(status)) { + talloc_free(call->context); + call->context = NULL; return dcesrv_bind_nak(call, 0); } - if (iface) { - status = iface->bind(call, iface); - if (!NT_STATUS_IS_OK(status)) { - char *uuid_str = GUID_string(call, &uuid); - DEBUG(2,("Request for dcerpc interface %s/%d rejected: %s\n", - uuid_str, if_version, nt_errstr(status))); - talloc_free(uuid_str); - return dcesrv_bind_nak(call, 0); - } - } - rep = talloc(call, struct data_blob_list_item); if (!rep) { + talloc_free(call->context); + call->context = NULL; return NT_STATUS_NO_MEMORY; } status = ncacn_push_auth(&rep->blob, call, lp_iconv_convenience(call->conn->dce_ctx->lp_ctx), &pkt, call->conn->auth_state.auth_info); if (!NT_STATUS_IS_OK(status)) { + talloc_free(call->context); + call->context = NULL; return status; } @@ -747,16 +753,20 @@ static NTSTATUS dcesrv_alter_new_context(struct dcesrv_call_state *call, uint32_ context->conn = call->conn; context->iface = iface; context->context_id = context_id; + context->assoc_group_id = SAMBA_ASSOC_GROUP; context->private = NULL; context->handles = NULL; DLIST_ADD(call->conn->contexts, context); call->context = context; + talloc_set_destructor(context, dcesrv_connection_context_destructor); - if (iface) { - status = iface->bind(call, iface); - if (!NT_STATUS_IS_OK(status)) { - return status; - } + status = iface->bind(call, iface); + if (!NT_STATUS_IS_OK(status)) { + /* we don't want to trigger the iface->unbind() hook */ + context->iface = NULL; + talloc_free(context); + call->context = NULL; + return status; } return NT_STATUS_OK; @@ -784,15 +794,26 @@ static NTSTATUS dcesrv_alter(struct dcesrv_call_state *call) context_id = call->pkt.u.alter.ctx_list[0].context_id; /* see if they are asking for a new interface */ - if (result == 0 && - dcesrv_find_context(call->conn, context_id) == NULL) { - status = dcesrv_alter_new_context(call, context_id); - if (!NT_STATUS_IS_OK(status)) { - result = DCERPC_BIND_PROVIDER_REJECT; - reason = DCERPC_BIND_REASON_ASYNTAX; + if (result == 0) { + call->context = dcesrv_find_context(call->conn, context_id); + if (!call->context) { + status = dcesrv_alter_new_context(call, context_id); + if (!NT_STATUS_IS_OK(status)) { + result = DCERPC_BIND_PROVIDER_REJECT; + reason = DCERPC_BIND_REASON_ASYNTAX; + } } } + if (result == 0 && + call->pkt.u.alter.assoc_group_id != 0 && + lp_parm_bool(call->conn->dce_ctx->lp_ctx, NULL, "dcesrv","assoc group checking", true) && + call->pkt.u.alter.assoc_group_id != call->context->assoc_group_id) { + /* TODO: work out what to return here */ + result = DCERPC_BIND_PROVIDER_REJECT; + reason = DCERPC_BIND_REASON_ASYNTAX; + } + /* setup a alter_resp */ dcesrv_init_hdr(&pkt, lp_rpc_big_endian(call->conn->dce_ctx->lp_ctx)); pkt.auth_length = 0; @@ -801,7 +822,11 @@ static NTSTATUS dcesrv_alter(struct dcesrv_call_state *call) pkt.pfc_flags = DCERPC_PFC_FLAG_FIRST | DCERPC_PFC_FLAG_LAST; pkt.u.alter_resp.max_xmit_frag = 0x2000; pkt.u.alter_resp.max_recv_frag = 0x2000; - pkt.u.alter_resp.assoc_group_id = call->pkt.u.alter.assoc_group_id; + if (result == 0) { + pkt.u.alter_resp.assoc_group_id = call->context->assoc_group_id; + } else { + pkt.u.alter_resp.assoc_group_id = 0; + } pkt.u.alter_resp.num_results = 1; pkt.u.alter_resp.ctx_list = talloc_array(call, struct dcerpc_ack_ctx, 1); if (!pkt.u.alter_resp.ctx_list) { @@ -1398,6 +1423,38 @@ const struct dcesrv_endpoint_server *dcesrv_ep_server_byname(const char *name) return NULL; } +void dcerpc_server_init(struct loadparm_context *lp_ctx) +{ + static bool initialized; + extern NTSTATUS dcerpc_server_wkssvc_init(void); + extern NTSTATUS dcerpc_server_drsuapi_init(void); + extern NTSTATUS dcerpc_server_winreg_init(void); + extern NTSTATUS dcerpc_server_spoolss_init(void); + extern NTSTATUS dcerpc_server_epmapper_init(void); + extern NTSTATUS dcerpc_server_srvsvc_init(void); + extern NTSTATUS dcerpc_server_netlogon_init(void); + extern NTSTATUS dcerpc_server_rpcecho_init(void); + extern NTSTATUS dcerpc_server_unixinfo_init(void); + extern NTSTATUS dcerpc_server_samr_init(void); + extern NTSTATUS dcerpc_server_remote_init(void); + extern NTSTATUS dcerpc_server_lsa_init(void); + extern NTSTATUS dcerpc_server_browser_init(void); + init_module_fn static_init[] = { STATIC_dcerpc_server_MODULES }; + init_module_fn *shared_init; + + if (initialized) { + return; + } + initialized = true; + + shared_init = load_samba_modules(NULL, lp_ctx, "dcerpc_server"); + + run_init_functions(static_init); + run_init_functions(shared_init); + + talloc_free(shared_init); +} + /* return the DCERPC module version, and the size of some critical types This can be used by endpoint server modules to either detect compilation errors, or provide @@ -1430,6 +1487,8 @@ _PUBLIC_ NTSTATUS dcesrv_init_ipc_context(TALLOC_CTX *mem_ctx, struct loadparm_c NTSTATUS status; struct dcesrv_context *dce_ctx; + dcerpc_server_init(lp_ctx); + status = dcesrv_init_context(mem_ctx, lp_ctx, lp_dcerpc_endpoint_servers(lp_ctx), &dce_ctx); NT_STATUS_NOT_OK_RETURN(status); diff --git a/source4/rpc_server/dcerpc_server.h b/source4/rpc_server/dcerpc_server.h index 4788fb3a51..bcd3d61f13 100644 --- a/source4/rpc_server/dcerpc_server.h +++ b/source4/rpc_server/dcerpc_server.h @@ -153,6 +153,8 @@ struct dcesrv_connection_context { struct dcesrv_connection_context *next, *prev; uint32_t context_id; + uint32_t assoc_group_id; + /* the connection this is on */ struct dcesrv_connection *conn; diff --git a/source4/rpc_server/netlogon/dcerpc_netlogon.c b/source4/rpc_server/netlogon/dcerpc_netlogon.c index ccc1fc515f..a2367c8a9b 100644 --- a/source4/rpc_server/netlogon/dcerpc_netlogon.c +++ b/source4/rpc_server/netlogon/dcerpc_netlogon.c @@ -803,7 +803,40 @@ static NTSTATUS dcesrv_netr_AccountSync(struct dcesrv_call_state *dce_call, TALL static WERROR dcesrv_netr_GetDcName(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct netr_GetDcName *r) { - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); + const char * const attrs[] = { NULL }; + void *sam_ctx; + struct ldb_message **res; + struct ldb_dn *domain_dn; + int ret; + const char *dcname; + + sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, + dce_call->conn->dce_ctx->lp_ctx, + dce_call->conn->auth_state.session_info); + if (sam_ctx == NULL) { + return WERR_DS_SERVICE_UNAVAILABLE; + } + + domain_dn = samdb_domain_to_dn(sam_ctx, mem_ctx, + r->in.domainname); + if (domain_dn == NULL) { + return WERR_DS_SERVICE_UNAVAILABLE; + } + + ret = gendb_search_dn(sam_ctx, mem_ctx, domain_dn, &res, attrs); + if (ret != 1) { + return WERR_NO_SUCH_DOMAIN; + } + + /* TODO: - return real IP address + * - check all r->in.* parameters (server_unc is ignored by w2k3!) + */ + dcname = talloc_asprintf(mem_ctx, "\\\\%s", + lp_netbios_name(dce_call->conn->dce_ctx->lp_ctx)); + W_ERROR_HAVE_NO_MEMORY(dcname); + + *r->out.dcname = dcname; + return WERR_OK; } @@ -823,7 +856,18 @@ static WERROR dcesrv_netr_LogonControl(struct dcesrv_call_state *dce_call, TALLO static WERROR dcesrv_netr_GetAnyDCName(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct netr_GetAnyDCName *r) { - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); + struct netr_GetDcName r2; + WERROR werr; + + ZERO_STRUCT(r2); + + r2.in.logon_server = r->in.logon_server; + r2.in.domainname = r->in.domainname; + r2.out.dcname = r->out.dcname; + + werr = dcesrv_netr_GetDcName(dce_call, mem_ctx, &r2); + + return werr; } @@ -1383,11 +1427,11 @@ static WERROR dcesrv_netr_GetForestTrustInformation(struct dcesrv_call_state *dc } -/* - netr_NETRSERVERGETTRUSTINFO +/* + netr_ServerGetTrustInfo */ -static WERROR dcesrv_netr_NETRSERVERGETTRUSTINFO(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct netr_NETRSERVERGETTRUSTINFO *r) +static NTSTATUS dcesrv_netr_ServerGetTrustInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, + struct netr_ServerGetTrustInfo *r) { DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); } diff --git a/source4/rpc_server/samr/dcesrv_samr.c b/source4/rpc_server/samr/dcesrv_samr.c index e1fb187c52..df23e11a67 100644 --- a/source4/rpc_server/samr/dcesrv_samr.c +++ b/source4/rpc_server/samr/dcesrv_samr.c @@ -140,11 +140,13 @@ #define SET_PARAMETERS(msg, field, attr) do { \ struct ldb_message_element *set_el; \ - if (samdb_msg_add_parameters(sam_ctx, mem_ctx, msg, attr, &r->in.info->field) != 0) { \ - return NT_STATUS_NO_MEMORY; \ + if (r->in.info->field.length != 0) { \ + if (samdb_msg_add_parameters(sam_ctx, mem_ctx, msg, attr, &r->in.info->field) != 0) { \ + return NT_STATUS_NO_MEMORY; \ + } \ + set_el = ldb_msg_find_element(msg, attr); \ + set_el->flags = LDB_FLAG_MOD_REPLACE; \ } \ - set_el = ldb_msg_find_element(msg, attr); \ - set_el->flags = LDB_FLAG_MOD_REPLACE; \ } while (0) @@ -763,8 +765,7 @@ static NTSTATUS dcesrv_samr_info_DomInfo13(struct samr_domain_state *state, info->domain_create_time = ldb_msg_find_attr_as_uint(dom_msgs[0], "creationTime", 0x0LL); - info->unknown1 = 0; - info->unknown2 = 0; + info->modified_count_at_last_promotion = 0; return NT_STATUS_OK; } @@ -3512,14 +3513,14 @@ static NTSTATUS dcesrv_samr_SetUserInfo(struct dcesrv_call_state *dce_call, TALL SET_UINT (msg, info23.info.country_code, "countryCode"); IFSET(SAMR_FIELD_CODE_PAGE) SET_UINT (msg, info23.info.code_page, "codePage"); - IFSET(SAMR_FIELD_PASSWORD) { + IFSET(SAMR_FIELD_NT_PASSWORD_PRESENT) { status = samr_set_password(dce_call, a_state->sam_ctx, a_state->account_dn, a_state->domain_state->domain_dn, mem_ctx, msg, &r->in.info->info23.password); - } else IFSET(SAMR_FIELD_PASSWORD2) { + } else IFSET(SAMR_FIELD_LM_PASSWORD_PRESENT) { status = samr_set_password(dce_call, a_state->sam_ctx, a_state->account_dn, @@ -3568,14 +3569,14 @@ static NTSTATUS dcesrv_samr_SetUserInfo(struct dcesrv_call_state *dce_call, TALL SET_UINT (msg, info25.info.country_code, "countryCode"); IFSET(SAMR_FIELD_CODE_PAGE) SET_UINT (msg, info25.info.code_page, "codePage"); - IFSET(SAMR_FIELD_PASSWORD) { + IFSET(SAMR_FIELD_NT_PASSWORD_PRESENT) { status = samr_set_password_ex(dce_call, a_state->sam_ctx, a_state->account_dn, a_state->domain_state->domain_dn, mem_ctx, msg, &r->in.info->info25.password); - } else IFSET(SAMR_FIELD_PASSWORD2) { + } else IFSET(SAMR_FIELD_LM_PASSWORD_PRESENT) { status = samr_set_password_ex(dce_call, a_state->sam_ctx, a_state->account_dn, diff --git a/source4/rpc_server/service_rpc.c b/source4/rpc_server/service_rpc.c index bb4d6bdaf2..6c19b2346b 100644 --- a/source4/rpc_server/service_rpc.c +++ b/source4/rpc_server/service_rpc.c @@ -425,25 +425,8 @@ static void dcesrv_task_init(struct task_server *task) NTSTATUS status; struct dcesrv_context *dce_ctx; struct dcesrv_endpoint *e; - extern NTSTATUS dcerpc_server_wkssvc_init(void); - extern NTSTATUS dcerpc_server_drsuapi_init(void); - extern NTSTATUS dcerpc_server_winreg_init(void); - extern NTSTATUS dcerpc_server_spoolss_init(void); - extern NTSTATUS dcerpc_server_epmapper_init(void); - extern NTSTATUS dcerpc_server_srvsvc_init(void); - extern NTSTATUS dcerpc_server_netlogon_init(void); - extern NTSTATUS dcerpc_server_rpcecho_init(void); - extern NTSTATUS dcerpc_server_unixinfo_init(void); - extern NTSTATUS dcerpc_server_samr_init(void); - extern NTSTATUS dcerpc_server_remote_init(void); - extern NTSTATUS dcerpc_server_lsa_init(void); - init_module_fn static_init[] = { STATIC_DCESRV_MODULES }; - init_module_fn *shared_init = load_samba_modules(NULL, task->lp_ctx, "dcerpc_server"); - - run_init_functions(static_init); - run_init_functions(shared_init); - - talloc_free(shared_init); + + dcerpc_server_init(task->lp_ctx); task_server_set_title(task, "task[dcesrv]"); |