#include "librpc/rpc/dcesrv_core.h"
#include "librpc/gen_ndr/ndr_lsa_scompat.h"
#include "librpc/gen_ndr/ndr_samr_scompat.h"
+#include "librpc/gen_ndr/ndr_winbind_scompat.h"
#include "secrets.h"
#include "rpc_client/cli_netlogon.h"
#include "idmap.h"
exit(1);
}
+ ep_server = winbind_get_ep_server();
+ if (ep_server == NULL) {
+ DBG_ERR("Failed to get 'winbind' endpoint server\n");
+ exit(1);
+ }
+ status = dcerpc_register_ep_server(ep_server);
+ if (!NT_STATUS_IS_OK(status)) {
+ DBG_ERR("Failed to register 'winbind' endpoint "
+ "server: %s\n", nt_errstr(status));
+ exit(1);
+ }
+
dce_ctx = global_dcesrv_context();
DBG_INFO("Initializing DCE/RPC registered endpoint servers\n");
#include "winbindd/winbindd.h"
#include "winbindd/winbindd_proto.h"
#include "ntdomain.h"
-#include "librpc/gen_ndr/srv_winbind.h"
+#include "librpc/rpc/dcesrv_core.h"
+#include "librpc/gen_ndr/ndr_winbind.h"
struct wbint_bh_state {
struct winbindd_domain *domain;
enum winbindd_result winbindd_dual_ndrcmd(struct winbindd_domain *domain,
struct winbindd_cli_state *state)
{
- struct pipes_struct p;
- const struct api_struct *fns;
- int num_fns;
- bool ret;
+ const struct dcesrv_endpoint_server *ep_server = NULL;
+ struct dcesrv_interface iface;
+ const struct ndr_syntax_id *abstract_syntax;
+ bool ok;
+ uint32_t opnum = state->request->data.ndrcmd;
+ struct pipes_struct *p;
+ TALLOC_CTX *mem_ctx;
+ DATA_BLOB in;
+ DATA_BLOB out;
+ NTSTATUS status;
+
+ DBG_DEBUG("Running command %s (domain '%s')\n",
+ ndr_table_winbind.calls[opnum].name,
+ domain ? domain->name : "(null)");
+
+ ep_server = dcesrv_ep_server_byname(ndr_table_winbind.name);
+ if (ep_server == NULL) {
+ DBG_ERR("Failed to get DCE/RPC endpoint server '%s'\n",
+ ndr_table_winbind.name);
+ return WINBINDD_ERROR;
+ }
- fns = winbind_get_pipe_fns(&num_fns);
+ abstract_syntax = &ndr_table_winbind.syntax_id;
+ ok = ep_server->interface_by_uuid(&iface, &abstract_syntax->uuid,
+ abstract_syntax->if_version);
+ if (!ok) {
+ DBG_ERR("Failed to get DCE/RPC interface\n");
+ return WINBINDD_ERROR;
+ }
- if (state->request->data.ndrcmd >= num_fns) {
+ mem_ctx = talloc_stackframe();
+ if (mem_ctx == NULL) {
+ DBG_ERR("No memory");
return WINBINDD_ERROR;
}
- DEBUG(10, ("winbindd_dual_ndrcmd: Running command %s (%s)\n",
- fns[state->request->data.ndrcmd].name,
- domain ? domain->name : "no domain"));
+ p = talloc_zero(mem_ctx, struct pipes_struct);
+ if (p == NULL) {
+ DBG_ERR("No memory\n");
+ return WINBINDD_ERROR;
+ }
+ p->mem_ctx = mem_ctx;
- ZERO_STRUCT(p);
- p.mem_ctx = talloc_stackframe();
- p.in_data.data = data_blob_const(state->request->extra_data.data,
- state->request->extra_len);
+ in = data_blob_const(state->request->extra_data.data,
+ state->request->extra_len);
- ret = fns[state->request->data.ndrcmd].fn(&p);
- if (!ret) {
- TALLOC_FREE(p.mem_ctx);
+ status = iface.local(p, opnum, mem_ctx, &in, &out);
+ if (!NT_STATUS_IS_OK(status)) {
+ TALLOC_FREE(mem_ctx);
return WINBINDD_ERROR;
}
state->response->extra_data.data =
- talloc_move(state->mem_ctx, &p.out_data.rdata.data);
- state->response->length += p.out_data.rdata.length;
- p.out_data.rdata.length = 0;
+ talloc_steal(state->mem_ctx, out.data);
+ state->response->length += out.length;
- TALLOC_FREE(p.mem_ctx);
+ TALLOC_FREE(mem_ctx);
if (state->response->extra_data.data == NULL) {
return WINBINDD_ERROR;
}
+
return WINBINDD_OK;
}