mirror of
https://github.com/samba-team/samba.git
synced 2024-12-24 21:34:56 +03:00
s3-rpc_server: Use binding vector in rpc_ep_try_register().
This commit is contained in:
parent
498e53c220
commit
0fef6766b9
@ -29,6 +29,7 @@
|
||||
#include "rpc_server/rpc_server.h"
|
||||
#include "rpc_server/rpc_ep_register.h"
|
||||
#include "rpc_server/spoolss/srv_spoolss_nt.h"
|
||||
#include "librpc/rpc/dcerpc_ep.h"
|
||||
|
||||
#define SPOOLSS_PIPE_NAME "spoolss"
|
||||
#define DAEMON_NAME "spoolssd"
|
||||
@ -149,6 +150,8 @@ void start_spoolssd(struct tevent_context *ev_ctx,
|
||||
struct messaging_context *msg_ctx)
|
||||
{
|
||||
struct rpc_srv_callbacks spoolss_cb;
|
||||
struct dcerpc_binding_vector *v;
|
||||
TALLOC_CTX *mem_ctx;
|
||||
pid_t pid;
|
||||
NTSTATUS status;
|
||||
int ret;
|
||||
@ -199,6 +202,11 @@ void start_spoolssd(struct tevent_context *ev_ctx,
|
||||
messaging_register(msg_ctx, ev_ctx,
|
||||
MSG_SMB_CONF_UPDATED, smb_conf_updated);
|
||||
|
||||
mem_ctx = talloc_new(NULL);
|
||||
if (mem_ctx == NULL) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize spoolss with an init function to convert printers first.
|
||||
* static_init_rpc will try to initialize the spoolss server too but you
|
||||
@ -222,17 +230,29 @@ void start_spoolssd(struct tevent_context *ev_ctx,
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!setup_named_pipe_socket(SPOOLSS_PIPE_NAME, ev_ctx, msg_ctx)) {
|
||||
status = dcerpc_binding_vector_new(mem_ctx, &v);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DEBUG(0, ("Failed to create binding vector (%s)\n",
|
||||
nt_errstr(status)));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
status = rpc_ep_register(ev_ctx, msg_ctx, &ndr_table_spoolss, NULL, 0);
|
||||
status = dcerpc_binding_vector_add_np_default(&ndr_table_spoolss, v);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DEBUG(0, ("Failed to add np to binding vector (%s)\n",
|
||||
nt_errstr(status)));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
status = rpc_ep_register(ev_ctx, msg_ctx, &ndr_table_spoolss, v);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DEBUG(0, ("Failed to register spoolss endpoint! (%s)\n",
|
||||
nt_errstr(status)));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
talloc_free(mem_ctx);
|
||||
|
||||
DEBUG(1, ("SPOOLSS Daemon Started (%d)\n", getpid()));
|
||||
|
||||
/* loop forever */
|
||||
|
@ -32,8 +32,7 @@ static NTSTATUS rpc_ep_try_register(TALLOC_CTX *mem_ctx,
|
||||
struct tevent_context *ev_ctx,
|
||||
struct messaging_context *msg_ctx,
|
||||
const struct ndr_interface_table *iface,
|
||||
const char *ncalrpc,
|
||||
uint16_t port,
|
||||
const struct dcerpc_binding_vector *v,
|
||||
struct dcerpc_binding_handle **pbh);
|
||||
|
||||
struct rpc_ep_regsiter_state {
|
||||
@ -44,9 +43,7 @@ struct rpc_ep_regsiter_state {
|
||||
struct messaging_context *msg_ctx;
|
||||
|
||||
const struct ndr_interface_table *iface;
|
||||
|
||||
const char *ncalrpc;
|
||||
uint16_t port;
|
||||
const struct dcerpc_binding_vector *vector;
|
||||
|
||||
uint32_t wait_time;
|
||||
};
|
||||
@ -54,8 +51,7 @@ struct rpc_ep_regsiter_state {
|
||||
NTSTATUS rpc_ep_register(struct tevent_context *ev_ctx,
|
||||
struct messaging_context *msg_ctx,
|
||||
const struct ndr_interface_table *iface,
|
||||
const char *ncalrpc,
|
||||
uint16_t port)
|
||||
const struct dcerpc_binding_vector *v)
|
||||
{
|
||||
struct rpc_ep_regsiter_state *state;
|
||||
struct tevent_req *req;
|
||||
@ -78,8 +74,11 @@ NTSTATUS rpc_ep_register(struct tevent_context *ev_ctx,
|
||||
state->ev_ctx = ev_ctx;
|
||||
state->msg_ctx = msg_ctx;
|
||||
state->iface = iface;
|
||||
state->ncalrpc = talloc_strdup(state, ncalrpc);
|
||||
state->port = port;
|
||||
state->vector = dcerpc_binding_vector_dup(state, v);
|
||||
if (state->vector == NULL) {
|
||||
talloc_free(state);
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
req = tevent_wakeup_send(state->mem_ctx,
|
||||
state->ev_ctx,
|
||||
@ -115,8 +114,7 @@ static void rpc_ep_register_loop(struct tevent_req *subreq)
|
||||
state->ev_ctx,
|
||||
state->msg_ctx,
|
||||
state->iface,
|
||||
state->ncalrpc,
|
||||
state->port,
|
||||
state->vector,
|
||||
&state->h);
|
||||
if (NT_STATUS_IS_OK(status)) {
|
||||
/* endpoint registered, monitor the connnection. */
|
||||
@ -155,22 +153,11 @@ static NTSTATUS rpc_ep_try_register(TALLOC_CTX *mem_ctx,
|
||||
struct tevent_context *ev_ctx,
|
||||
struct messaging_context *msg_ctx,
|
||||
const struct ndr_interface_table *iface,
|
||||
const char *ncalrpc,
|
||||
uint16_t port,
|
||||
const struct dcerpc_binding_vector *v,
|
||||
struct dcerpc_binding_handle **pbh)
|
||||
{
|
||||
struct dcerpc_binding_vector *v = NULL;
|
||||
NTSTATUS status;
|
||||
|
||||
status = dcerpc_binding_vector_create(mem_ctx,
|
||||
iface,
|
||||
port,
|
||||
ncalrpc,
|
||||
&v);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = dcerpc_ep_register(mem_ctx,
|
||||
msg_ctx,
|
||||
iface,
|
||||
@ -178,7 +165,6 @@ static NTSTATUS rpc_ep_try_register(TALLOC_CTX *mem_ctx,
|
||||
&iface->syntax_id.uuid,
|
||||
iface->name,
|
||||
pbh);
|
||||
talloc_free(v);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
return status;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
#ifndef _RPC_EP_REGISTER_H
|
||||
#define _RPC_EP_REGISTER_H
|
||||
|
||||
struct ndr_interface_table;
|
||||
struct dcerpc_binding_vector;
|
||||
|
||||
/**
|
||||
* @brief Register an endpoint at the endpoint mapper.
|
||||
@ -36,17 +36,14 @@ struct ndr_interface_table;
|
||||
*
|
||||
* @param[in] iface The interface table to register.
|
||||
*
|
||||
* @param[in] ncalrpc The name of the ncalrpc pipe or NULL.
|
||||
*
|
||||
* @param[in] port The tcpip port or 0.
|
||||
* @param[in] v The binding vector to register.
|
||||
*
|
||||
* @return NT_STATUS_OK on success or a corresponding error code.
|
||||
*/
|
||||
NTSTATUS rpc_ep_register(struct tevent_context *ev_ctx,
|
||||
struct messaging_context *msg_ctx,
|
||||
const struct ndr_interface_table *iface,
|
||||
const char *ncalrpc,
|
||||
uint16_t port);
|
||||
const struct dcerpc_binding_vector *v);
|
||||
|
||||
#endif /* _RPC_EP_REGISTER_H */
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -129,7 +129,7 @@ bld.SAMBA3_SUBSYSTEM('RPC_EPMAPPER',
|
||||
vars=locals())
|
||||
|
||||
bld.SAMBA3_SUBSYSTEM('RPC_SERVER',
|
||||
source='srv_pipe_hnd.c srv_pipe.c rpc_service_setup.c',
|
||||
source='srv_pipe_hnd.c srv_pipe.c rpc_sock_helper.c rpc_service_setup.c',
|
||||
deps='''RPC_NCACN_NP RPC_SERVICE RPC_CRYPTO
|
||||
RPC_SAMR RPC_LSARPC RPC_WINREG RPC_INITSHUTDOWN
|
||||
RPC_DSSETUP RPC_WKSSVC RPC_SVCCTL RPC_NTSVCS
|
||||
|
Loading…
Reference in New Issue
Block a user