#include "includes.h"
#include "dlinklist.h"
#include "auth/auth.h"
+#include "lib/events/events.h"
/***************************************************************************
Set a fixed challenge
/***************************************************************************
Make a auth_info struct for the auth subsystem
***************************************************************************/
-NTSTATUS auth_context_create(TALLOC_CTX *mem_ctx, const char **methods, struct auth_context **auth_ctx)
+NTSTATUS auth_context_create(TALLOC_CTX *mem_ctx, const char **methods,
+ struct auth_context **auth_ctx,
+ struct event_context *ev)
{
int i;
struct auth_context *ctx;
ctx->challenge.may_be_modified = False;
ctx->challenge.data = data_blob(NULL, 0);
ctx->methods = NULL;
+
+ if (ev == NULL) {
+ ev = event_context_init(ctx);
+ if (ev == NULL) {
+ talloc_free(ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
+ }
+
+ ctx->event_ctx = ev;
for (i=0; methods[i] ; i++) {
struct auth_method_context *method;
/* methods, in the order they should be called */
struct auth_method_context *methods;
+
+ /* the event context to use for calls that can block */
+ struct event_context *event_ctx;
};
/* this structure is used by backends to determine the size of some critical types */
status = dcerpc_pipe_connect_b(mem_ctx, &p, b,
DCERPC_NETLOGON_UUID,
DCERPC_NETLOGON_VERSION,
- credentials);
+ credentials, ctx->auth_ctx->event_ctx);
if (!NT_STATUS_IS_OK(status)) {
return status;
#include "includes.h"
#include "auth/auth.h"
+#include "lib/events/events.h"
/* the list of currently registered GENSEC backends */
const static struct gensec_security_ops **generic_security_ops;
@param gensec_security Returned GENSEC context pointer.
@note The mem_ctx is only a parent and may be NULL.
*/
-static NTSTATUS gensec_start(TALLOC_CTX *mem_ctx, struct gensec_security **gensec_security)
+static NTSTATUS gensec_start(TALLOC_CTX *mem_ctx,
+ struct gensec_security **gensec_security,
+ struct event_context *ev)
{
(*gensec_security) = talloc(mem_ctx, struct gensec_security);
- if (!(*gensec_security)) {
- return NT_STATUS_NO_MEMORY;
- }
+ NT_STATUS_HAVE_NO_MEMORY(*gensec_security);
(*gensec_security)->ops = NULL;
(*gensec_security)->subcontext = False;
(*gensec_security)->want_features = 0;
+
+ if (ev == NULL) {
+ ev = event_context_init(*gensec_security);
+ if (ev == NULL) {
+ talloc_free(*gensec_security);
+ return NT_STATUS_NO_MEMORY;
+ }
+ }
+
+ (*gensec_security)->event_ctx = ev;
+
return NT_STATUS_OK;
}
struct gensec_security **gensec_security)
{
(*gensec_security) = talloc(mem_ctx, struct gensec_security);
- if (!(*gensec_security)) {
- return NT_STATUS_NO_MEMORY;
- }
+ NT_STATUS_HAVE_NO_MEMORY(*gensec_security);
(**gensec_security) = *parent;
(*gensec_security)->ops = NULL;
(*gensec_security)->private_data = NULL;
(*gensec_security)->subcontext = True;
+ (*gensec_security)->event_ctx = parent->event_ctx;
return NT_STATUS_OK;
}
@param gensec_security Returned GENSEC context pointer.
@note The mem_ctx is only a parent and may be NULL.
*/
-NTSTATUS gensec_client_start(TALLOC_CTX *mem_ctx, struct gensec_security **gensec_security)
+NTSTATUS gensec_client_start(TALLOC_CTX *mem_ctx,
+ struct gensec_security **gensec_security,
+ struct event_context *ev)
{
NTSTATUS status;
- status = gensec_start(mem_ctx, gensec_security);
+ status = gensec_start(mem_ctx, gensec_security, ev);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
@param gensec_security Returned GENSEC context pointer.
@note The mem_ctx is only a parent and may be NULL.
*/
-NTSTATUS gensec_server_start(TALLOC_CTX *mem_ctx, struct gensec_security **gensec_security)
+NTSTATUS gensec_server_start(TALLOC_CTX *mem_ctx,
+ struct gensec_security **gensec_security,
+ struct event_context *ev)
{
NTSTATUS status;
- status = gensec_start(mem_ctx, gensec_security);
+ status = gensec_start(mem_ctx, gensec_security, ev);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
enum gensec_role gensec_role;
BOOL subcontext;
uint32_t want_features;
+ struct event_context *event_ctx;
};
/* this structure is used by backends to determine the size of some critical types */
gensec_ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_SEAL;
}
- nt_status = auth_context_create(gensec_ntlmssp_state, lp_auth_methods(), &gensec_ntlmssp_state->auth_context);
+ nt_status = auth_context_create(gensec_ntlmssp_state, lp_auth_methods(),
+ &gensec_ntlmssp_state->auth_context,
+ gensec_security->event_ctx);
NT_STATUS_NOT_OK_RETURN(nt_status);
gensec_ntlmssp_state->get_challenge = auth_ntlmssp_get_challenge;
status = dcerpc_pipe_connect(mem_ctx, &p, binding,
DCERPC_SRVSVC_UUID,
DCERPC_SRVSVC_VERSION,
- cmdline_credentials);
+ cmdline_credentials, NULL);
if (!NT_STATUS_IS_OK(status)) {
d_printf("Failed to connect to %s - %s\n",
binding, nt_errstr(status));
}
status = smbcli_full_connection(NULL, &c, server,
- share, NULL, cred);
+ share, NULL, cred, NULL);
if (!NT_STATUS_IS_OK(status)) {
d_printf("Connection to \\\\%s\\%s failed - %s\n",
server, share, nt_errstr(status));
myname = get_myname();
nt_status = smbcli_full_connection(NULL, &c, myname, server, 0, share, NULL,
- username, workgroup, password);
+ username, workgroup, password, NULL);
free(myname);
if (!NT_STATUS_IS_OK(nt_status)) {
status = dcerpc_pipe_connect(talloc_autofree_context(), &epmapper_pipe, bs,
DCERPC_EPMAPPER_UUID, DCERPC_EPMAPPER_VERSION,
- credentials);
+ credentials, NULL);
if (NT_STATUS_IS_ERR(status)) {
gtk_show_ntstatus(mainwin, "Error connecting to endpoint mapper", status);
cli_credentials_set_gtk_callbacks(creds);
error = reg_open_remote(®istry,
- creds,
- gtk_rpc_binding_dialog_get_binding_string(GTK_RPC_BINDING_DIALOG(rpcwin), mem_ctx));
+ creds,
+ gtk_rpc_binding_dialog_get_binding_string(GTK_RPC_BINDING_DIALOG(rpcwin), mem_ctx),
+ NULL);
if(!W_ERROR_IS_OK(error)) {
gtk_show_werror(mainwin, "Error while opening remote registry", error);
gtk_rpc_binding_dialog_get_binding(d, mem_ctx),
DCERPC_ATSVC_UUID,
DCERPC_ATSVC_VERSION,
- credentials);
+ credentials, NULL);
if(!NT_STATUS_IS_OK(status)) {
gtk_show_ntstatus(mainwin, "Error while connecting to at service", status);
/* If connected, get list of jobs */
status = dcerpc_pipe_connect_b(mem_ctx, &sam_pipe,
gtk_rpc_binding_dialog_get_binding(d, mem_ctx),
- DCERPC_SAMR_UUID, DCERPC_SAMR_VERSION, cred );
+ DCERPC_SAMR_UUID, DCERPC_SAMR_VERSION, cred, NULL);
if(!NT_STATUS_IS_OK(status)) {
gtk_show_ntstatus(mainwin, "While connecting to SAMR interface", status);
#include "ldap_server/ldap_server.h"
#include "auth/auth.h"
#include "libcli/ldap/ldap.h"
+#include "smbd/service_stream.h"
static NTSTATUS ldapsrv_BindSimple(struct ldapsrv_call *call)
{
if (!call->conn->gensec) {
call->conn->session_info = NULL;
- status = gensec_server_start(call->conn, &call->conn->gensec);
+ status = gensec_server_start(call->conn, &call->conn->gensec,
+ call->conn->connection->event.ctx);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("Failed to start GENSEC server code: %s\n", nt_errstr(status)));
return status;
struct com_context
{
struct dcom_client_context *dcom;
+ struct event_context *event_ctx;
};
typedef struct IUnknown *(*get_class_object_function) (const struct GUID *clsid);
return dcerpc_pipe_connect(ctx, p, "ncalrpc",
DCERPC_IREMOTEACTIVATION_UUID,
DCERPC_IREMOTEACTIVATION_VERSION,
- ctx->dcom->credentials);
+ ctx->dcom->credentials, ctx->event_ctx);
}
/* Allow server name to contain a binding string */
status = dcerpc_pipe_connect_b(ctx, p, bd,
DCERPC_IREMOTEACTIVATION_UUID,
DCERPC_IREMOTEACTIVATION_VERSION,
- ctx->dcom->credentials);
+ ctx->dcom->credentials, ctx->event_ctx);
talloc_free(mem_ctx);
return status;
status = dcerpc_pipe_connect(ctx, p, binding,
DCERPC_IREMOTEACTIVATION_UUID,
DCERPC_IREMOTEACTIVATION_VERSION,
- ctx->dcom->credentials);
+ ctx->dcom->credentials, ctx->event_ctx);
if (NT_STATUS_IS_OK(status)) {
talloc_free(mem_ctx);
return WERR_OK;
}
-NTSTATUS dcom_get_pipe (struct IUnknown *iface, struct dcerpc_pipe **pp)
+NTSTATUS dcom_get_pipe(struct IUnknown *iface, struct dcerpc_pipe **pp)
{
struct dcerpc_binding *binding;
struct GUID iid;
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("Error parsing string binding"));
} else {
+ /* TODO: jelmer, please look at this. The
+ "NULL" here should be a real event
+ context */
status = dcerpc_pipe_connect_b(NULL, &p, binding,
uuid, 0.0,
- iface->ctx->dcom->credentials);
+ iface->ctx->dcom->credentials,
+ NULL);
}
talloc_free(binding);
i++;
#include "includes.h"
#include "dlinklist.h"
#include "lib/com/com.h"
+#include "lib/events/events.h"
#include "librpc/gen_ndr/com_dcom.h"
-WERROR com_init(struct com_context **ctx)
+WERROR com_init(struct com_context **ctx, struct event_context *event_ctx)
{
*ctx = talloc(NULL, struct com_context);
+ if (event_ctx == NULL) {
+ event_ctx = event_context_init(*ctx);
+ }
+ (*ctx)->event_ctx = event_ctx;
return WERR_OK;
}
.num_values = rpc_num_values,
};
-WERROR reg_open_remote (struct registry_context **ctx, struct cli_credentials *credentials, const char *location)
+WERROR reg_open_remote(struct registry_context **ctx, struct cli_credentials *credentials,
+ const char *location, struct event_context *ev)
{
NTSTATUS status;
struct dcerpc_pipe *p;
&p, location,
DCERPC_WINREG_UUID,
DCERPC_WINREG_VERSION,
- credentials);
+ credentials, ev);
(*ctx)->backend_data = p;
if(NT_STATUS_IS_ERR(status)) {
break;
case 'R':
if (!h1 && !from_null)
- error = reg_open_remote(&h1, cmdline_credentials, poptGetOptArg(pc));
- else if (!h2) error = reg_open_remote(&h2, cmdline_credentials, poptGetOptArg(pc));
+ error = reg_open_remote(&h1, cmdline_credentials,
+ poptGetOptArg(pc), NULL);
+ else if (!h2) error = reg_open_remote(&h2, cmdline_credentials,
+ poptGetOptArg(pc), NULL);
break;
}
}
if (remote) {
- error = reg_open_remote (&h, cmdline_credentials, remote);
+ error = reg_open_remote (&h, cmdline_credentials, remote, NULL);
} else {
error = reg_open_local (&h);
}
}
if (remote) {
- error = reg_open_remote (&h, cmdline_credentials, remote);
+ error = reg_open_remote (&h, cmdline_credentials, remote, NULL);
} else if (backend) {
error = reg_open_hive(NULL, backend, poptGetArg(pc), NULL, &curkey);
} else {
}
if (remote) {
- error = reg_open_remote(&h, cmdline_credentials, remote);
+ error = reg_open_remote(&h, cmdline_credentials, remote, NULL);
} else if (backend) {
error = reg_open_hive(NULL, backend, poptGetArg(pc), NULL, &root);
} else {
const char *host,
const char *sharename,
const char *devtype,
- struct cli_credentials *credentials)
+ struct cli_credentials *credentials,
+ struct event_context *ev)
{
struct smbcli_tree *tree;
NTSTATUS status;
status = smbcli_tree_full_connection(parent_ctx,
&tree, host, 0, sharename, devtype,
- credentials);
+ credentials, ev);
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
/*
sync version of smb_composite_connect
*/
-NTSTATUS smb_composite_connect(struct smb_composite_connect *io, TALLOC_CTX *mem_ctx)
+NTSTATUS smb_composite_connect(struct smb_composite_connect *io, TALLOC_CTX *mem_ctx,
+ struct event_context *ev)
{
- struct composite_context *c = smb_composite_connect_send(io, NULL);
+ struct composite_context *c = smb_composite_connect_send(io, ev);
return smb_composite_connect_recv(c, mem_ctx);
}
smbcli_temp_set_signing(session->transport);
- status = gensec_client_start(session, &session->gensec);
+ status = gensec_client_start(session, &session->gensec, c->event_ctx);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("Failed to start GENSEC client mode: %s\n", nt_errstr(status)));
return NULL;
DATA_BLOB input = data_blob(NULL, 0);
DATA_BLOB output = data_blob(NULL, 0);
- status = gensec_client_start(conn, &conn->gensec);
+ status = gensec_client_start(conn, &conn->gensec, NULL);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("Failed to start GENSEC engine (%s)\n", nt_errstr(status)));
goto failed;
struct smbcli_tree **ret_tree,
const char *dest_host, int port,
const char *service, const char *service_type,
- struct cli_credentials *credentials)
+ struct cli_credentials *credentials,
+ struct event_context *ev)
{
struct smb_composite_connect io;
NTSTATUS status;
io.in.credentials = credentials;
io.in.workgroup = lp_workgroup();
- status = smb_composite_connect(&io, parent_ctx);
+ status = smb_composite_connect(&io, parent_ctx, ev);
if (NT_STATUS_IS_OK(status)) {
*ret_tree = io.out.tree;
}
}
lsa->ipc_tree->tid = tcon.tconx.out.tid;
- lsa->pipe = dcerpc_pipe_init(lsa);
+ lsa->pipe = dcerpc_pipe_init(lsa, cli->transport->socket->event.ctx);
if (lsa->pipe == NULL) {
talloc_free(lsa);
return NT_STATUS_NO_MEMORY;
#include "includes.h"
#include "libnet/libnet.h"
+#include "lib/events/events.h"
-struct libnet_context *libnet_context_init(void)
+struct libnet_context *libnet_context_init(struct event_context *ev)
{
- TALLOC_CTX *mem_ctx;
struct libnet_context *ctx;
- mem_ctx = talloc_init("libnet_context");
-
- ctx = talloc(mem_ctx, struct libnet_context);
+ ctx = talloc(NULL, struct libnet_context);
if (!ctx) {
return NULL;
}
- ctx->mem_ctx = mem_ctx;
+ if (ev == NULL) {
+ ev = event_context_init(ctx);
+ if (ev == NULL) {
+ talloc_free(ctx);
+ return NULL;
+ }
+ }
+ ctx->event_ctx = ev;
return ctx;
}
-void libnet_context_destroy(struct libnet_context **libnetctx)
-{
- talloc_free((*libnetctx)->mem_ctx);
-
- (*libnetctx) = NULL;
-}
*/
struct libnet_context {
- TALLOC_CTX *mem_ctx;
-
/* here we need:
* a client env context
* a user env context
/* opened handles */
struct policy_handle domain_handle;
struct policy_handle user_handle;
+
+ struct event_context *event_ctx;
};
binding,
r->standard.in.dcerpc_iface_uuid,
r->standard.in.dcerpc_iface_version,
- ctx->cred);
+ ctx->cred, ctx->event_ctx);
if (!NT_STATUS_IS_OK(status)) {
r->standard.out.error_string = talloc_asprintf(mem_ctx,
nt_status = dcerpc_pipe_connect_b(mem_ctx, &p, b,
DCERPC_NETLOGON_UUID,
DCERPC_NETLOGON_VERSION,
- machine_account);
+ machine_account, ctx->event_ctx);
if (!NT_STATUS_IS_OK(nt_status)) {
return nt_status;
}
-/* initialise a dcerpc connection. */
-struct dcerpc_connection *dcerpc_connection_init(TALLOC_CTX *mem_ctx)
+/* initialise a dcerpc connection.
+ the event context is optional
+*/
+struct dcerpc_connection *dcerpc_connection_init(TALLOC_CTX *mem_ctx,
+ struct event_context *ev)
{
struct dcerpc_connection *c;
return NULL;
}
+ if (ev == NULL) {
+ ev = event_context_init(c);
+ if (ev == NULL) {
+ talloc_free(c);
+ return NULL;
+ }
+ }
+
+ c->event_ctx = ev;
c->call_id = 1;
c->security_state.auth_info = NULL;
c->security_state.session_key = dcerpc_generic_session_key;
}
/* initialise a dcerpc pipe. */
-struct dcerpc_pipe *dcerpc_pipe_init(TALLOC_CTX *mem_ctx)
+struct dcerpc_pipe *dcerpc_pipe_init(TALLOC_CTX *mem_ctx, struct event_context *ev)
{
struct dcerpc_pipe *p;
return NULL;
}
- p->conn = dcerpc_connection_init(p);
+ p->conn = dcerpc_connection_init(p, ev);
if (p->conn == NULL) {
talloc_free(p);
return NULL;
return status;
}
- event_add_timed(c->transport.event_context(c), state,
+ event_add_timed(c->event_ctx, state,
timeval_current_ofs(DCERPC_REQUEST_TIMEOUT, 0),
dcerpc_full_timeout_handler, state);
while (NT_STATUS_IS_OK(state->status) && state->reply_blob) {
- struct event_context *ctx = c->transport.event_context(c);
- if (event_loop_once(ctx) != 0) {
+ if (event_loop_once(c->event_ctx) != 0) {
return NT_STATUS_CONNECTION_DISCONNECTED;
}
}
handle timeouts of individual dcerpc requests
*/
static void dcerpc_timeout_handler(struct event_context *ev, struct timed_event *te,
- struct timeval t, void *private)
+ struct timeval t, void *private)
{
struct rpc_request *req = talloc_get_type(private, struct rpc_request);
*/
struct event_context *dcerpc_event_context(struct dcerpc_pipe *p)
{
- return p->conn->transport.event_context(p->conn);
+ return p->conn->event_ctx;
}
uint_t flags;
struct dcerpc_security security_state;
const char *binding_string;
+ struct event_context *event_ctx;
struct dcerpc_transport {
enum dcerpc_transport_t transport;
/* send a read request to the server */
NTSTATUS (*send_read)(struct dcerpc_connection *);
- /* get an event context for the connection */
- struct event_context *(*event_context)(struct dcerpc_connection *);
-
/* a callback to the dcerpc code when a full fragment
has been received */
void (*recv_data)(struct dcerpc_connection *, DATA_BLOB *, NTSTATUS status);
DATA_BLOB null_data_blob = data_blob(NULL, 0);
if (!p->conn->security_state.generic_state) {
- status = gensec_client_start(p, &p->conn->security_state.generic_state);
+ status = gensec_client_start(p, &p->conn->security_state.generic_state,
+ p->conn->event_ctx);
if (!NT_STATUS_IS_OK(status)) goto done;
status = gensec_start_mech_by_authtype(p->conn->security_state.generic_state,
p->conn->flags |= DCERPC_CONNECT;
}
- status = gensec_client_start(p, &p->conn->security_state.generic_state);
+ status = gensec_client_start(p, &p->conn->security_state.generic_state,
+ p->conn->event_ctx);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("Failed to start GENSEC client mode: %s\n", nt_errstr(status)));
return status;
}
/* Make binding string for netlogon, not the other pipe */
- status = dcerpc_epm_map_binding(tmp_ctx, b, DCERPC_NETLOGON_UUID, DCERPC_NETLOGON_VERSION);
+ status = dcerpc_epm_map_binding(tmp_ctx, b,
+ DCERPC_NETLOGON_UUID, DCERPC_NETLOGON_VERSION,
+ p->conn->event_ctx);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("Failed to map DCERPC/TCP NCACN_NP pipe for '%s' - %s\n",
DCERPC_NETLOGON_UUID, nt_errstr(status)));
return NT_STATUS_OK;
}
-/*
- return the event context for the pipe, so the caller can wait
- for events asynchronously
-*/
-static struct event_context *smb_event_context(struct dcerpc_connection *c)
-{
- struct smb_private *smb = c->transport.private;
-
- return smb->tree->session->transport->socket->event.ctx;
-}
-
-
/*
shutdown SMB pipe connection
*/
c->transport.send_request = smb_send_request;
c->transport.send_read = send_read_request;
- c->transport.event_context = smb_event_context;
c->transport.recv_data = NULL;
/* Over-ride the default session key with the SMB session key */
/* transport private information used by general socket pipe transports */
struct sock_private {
- struct event_context *event_ctx;
struct fd_event *fde;
struct socket_context *sock;
char *server_name;
return NT_STATUS_OK;
}
-/*
- return the event context so the caller can process asynchronously
-*/
-static struct event_context *sock_event_context(struct dcerpc_connection *p)
-{
- struct sock_private *sock = p->transport.private;
-
- return sock->event_ctx;
-}
-
/*
shutdown sock pipe connection
*/
c->transport.send_request = sock_send_request;
c->transport.send_read = sock_send_read;
- c->transport.event_context = sock_event_context;
c->transport.recv_data = NULL;
c->transport.shutdown_pipe = sock_shutdown_pipe;
sock->sock = socket_ctx;
sock->server_name = strupper_talloc(sock, server);
- sock->event_ctx = event_context_init(sock);
sock->pending_send = NULL;
sock->recv.received = 0;
sock->recv.data = data_blob(NULL, 0);
sock->recv.pending_count = 0;
- sock->fde = event_add_fd(sock->event_ctx, sock, socket_get_fd(sock->sock),
+ sock->fde = event_add_fd(c->event_ctx, sock, socket_get_fd(sock->sock),
0, sock_io_handler, c);
c->transport.private = sock;
}
NTSTATUS dcerpc_epm_map_binding(TALLOC_CTX *mem_ctx, struct dcerpc_binding *binding,
- const char *uuid, uint_t version)
+ const char *uuid, uint_t version, struct event_context *ev)
{
struct dcerpc_pipe *p;
NTSTATUS status;
epmapper_binding,
DCERPC_EPMAPPER_UUID,
DCERPC_EPMAPPER_VERSION,
- anon_creds);
+ anon_creds, ev);
if (!NT_STATUS_IS_OK(status)) {
return status;
status = smbcli_full_connection(p->conn, &cli,
binding->host,
"IPC$", NULL,
- anon_creds);
+ anon_creds, p->conn->event_ctx);
} else {
status = smbcli_full_connection(p->conn, &cli,
binding->host,
"IPC$", NULL,
- credentials);
+ credentials, p->conn->event_ctx);
}
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("Failed to connect to %s - %s\n", binding->host, nt_errstr(status)));
/* Look up identifier using the epmapper */
if (!binding->endpoint) {
- status = dcerpc_epm_map_binding(tmp_ctx, binding, pipe_uuid, pipe_version);
+ status = dcerpc_epm_map_binding(tmp_ctx, binding,
+ pipe_uuid, pipe_version,
+ p->conn->event_ctx);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("Failed to map DCERPC/TCP NCACN_NP pipe for '%s' - %s\n",
pipe_uuid, nt_errstr(status)));
/* Look up identifier using the epmapper */
if (!binding->endpoint) {
- status = dcerpc_epm_map_binding(tmp_ctx, binding, pipe_uuid, pipe_version);
+ status = dcerpc_epm_map_binding(tmp_ctx, binding,
+ pipe_uuid, pipe_version,
+ p->conn->event_ctx);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("Failed to map DCERPC/TCP NCALRPC identifier for '%s' - %s\n",
pipe_uuid, nt_errstr(status)));
if (!binding->endpoint) {
status = dcerpc_epm_map_binding(tmp_ctx, binding,
- pipe_uuid, pipe_version);
+ pipe_uuid, pipe_version,
+ p->conn->event_ctx);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("Failed to map DCERPC/TCP port for '%s' - %s\n",
pipe_uuid, nt_errstr(status)));
struct dcerpc_binding *binding,
const char *pipe_uuid,
uint32_t pipe_version,
- struct cli_credentials *credentials)
+ struct cli_credentials *credentials,
+ struct event_context *ev)
{
NTSTATUS status = NT_STATUS_INVALID_PARAMETER;
struct dcerpc_pipe *p;
(*pp) = NULL;
- p = dcerpc_pipe_init(parent_ctx);
+ p = dcerpc_pipe_init(parent_ctx, ev);
if (p == NULL) {
return NT_STATUS_NO_MEMORY;
}
const char *binding,
const char *pipe_uuid,
uint32_t pipe_version,
- struct cli_credentials *credentials)
+ struct cli_credentials *credentials,
+ struct event_context *ev)
{
struct dcerpc_binding *b;
NTSTATUS status;
DEBUG(3,("Using binding %s\n", dcerpc_binding_string(tmp_ctx, b)));
status = dcerpc_pipe_connect_b(tmp_ctx,
- pp, b, pipe_uuid, pipe_version, credentials);
+ pp, b, pipe_uuid, pipe_version,
+ credentials, ev);
if (NT_STATUS_IS_OK(status)) {
*pp = talloc_reference(parent_ctx, *pp);
struct smbcli_tree *tree;
NTSTATUS status = NT_STATUS_INVALID_PARAMETER;
- (*p2) = dcerpc_pipe_init(p);
+ (*p2) = dcerpc_pipe_init(p, p->conn->event_ctx);
if (*p2 == NULL) {
return NT_STATUS_NO_MEMORY;
}
return False;
}
- status = gensec_server_start(dce_conn, &auth->gensec_security);
+ status = gensec_server_start(dce_conn, &auth->gensec_security, call->event_ctx);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("Failed to start GENSEC server code: %s\n", nt_errstr(status)));
return False;
}
/* TODO: we need to deny anonymous access here */
- nt_status = auth_context_create(mem_ctx, lp_auth_methods(), &auth_context);
+ nt_status = auth_context_create(mem_ctx, lp_auth_methods(), &auth_context,
+ dce_call->event_ctx);
NT_STATUS_NOT_OK_RETURN(nt_status);
nt_status = auth_get_challenge(auth_context, &chal);
case 2:
case 6:
/* TODO: we need to deny anonymous access here */
- nt_status = auth_context_create(mem_ctx, lp_auth_methods(), &auth_context);
+ nt_status = auth_context_create(mem_ctx, lp_auth_methods(), &auth_context,
+ dce_call->event_ctx);
NT_STATUS_NOT_OK_RETURN(nt_status);
nt_status = auth_context_set_challenge(auth_context, r->in.logon.network->challenge, "netr_LogonSamLogonWithFlags");
status = dcerpc_pipe_connect(private,
&(private->c_pipe), binding,
iface->uuid, iface->if_version,
- credentials);
+ credentials, dce_call->event_ctx);
talloc_free(credentials);
if (!NT_STATUS_IS_OK(status)) {
NTSTATUS nt_status;
DATA_BLOB pw_blob;
- nt_status = auth_context_create(tmp_ctx, auth_unix, &auth_context);
+ /*
+ darn, we need some way to get the right event_context here
+ */
+ nt_status = auth_context_create(tmp_ctx, auth_unix, &auth_context, NULL);
if (!NT_STATUS_IS_OK(nt_status)) {
mprSetPropertyValue(auth, "result", mprCreateBoolVar(False));
mprSetPropertyValue(auth, "report", mprCreateStringVar("Auth System Failure", 1));
union smb_tcon tcon;
TALLOC_CTX *mem_ctx;
NTSTATUS status;
- char *password = "";
+ const char *password = "";
/* Argument parsing */
DEBUG(10, ("get challenge: creating negprot_global_auth_context\n"));
- nt_status = auth_context_create(smb_conn, lp_auth_methods(), &smb_conn->negotiate.auth_context);
+ nt_status = auth_context_create(smb_conn, lp_auth_methods(),
+ &smb_conn->negotiate.auth_context,
+ smb_conn->connection->event.ctx);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0, ("auth_context_create() returned %s", nt_errstr(nt_status)));
return nt_status;
struct gensec_security *gensec_security;
DATA_BLOB null_data_blob = data_blob(NULL, 0);
DATA_BLOB blob;
- NTSTATUS nt_status = gensec_server_start(req->smb_conn, &gensec_security);
+ NTSTATUS nt_status = gensec_server_start(req->smb_conn,
+ &gensec_security,
+ req->smb_conn->connection->event.ctx);
if (req->smb_conn->negotiate.auth_context) {
smbsrv_terminate_connection(req->smb_conn, "reply_nt1: is this a secondary negprot? auth_context is non-NULL!\n");
}
/* TODO: should we use just "anonymous" here? */
- status = auth_context_create(req->smb_conn, lp_auth_methods(), &auth_context);
+ status = auth_context_create(req->smb_conn, lp_auth_methods(),
+ &auth_context,
+ req->smb_conn->connection->event.ctx);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(mem_ctx);
return status;
gensec_ctx = smb_sess->gensec_ctx;
status = gensec_update(gensec_ctx, req, sess->spnego.in.secblob, &sess->spnego.out.secblob);
} else {
- status = gensec_server_start(req->smb_conn, &gensec_ctx);
+ status = gensec_server_start(req->smb_conn, &gensec_ctx,
+ req->smb_conn->connection->event.ctx);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("Failed to start GENSEC server code: %s\n", nt_errstr(status)));
return status;
DATA_BLOB sig, expected_sig;
NTSTATUS status;
- status = gensec_client_start(NULL, &gensec_security);
+ status = gensec_client_start(NULL, &gensec_security, NULL);
if (!NT_STATUS_IS_OK(status)) {
return False;
talloc_free(gensec_security);
- status = gensec_client_start(NULL, &gensec_security);
+ status = gensec_client_start(NULL, &gensec_security, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to start GENSEC for NTLMSSP\n");
char test_data[5];
int i;
- com_init(&ctx);
+ com_init(&ctx, NULL);
dcom_client_init(ctx, cmdline_credentials);
GUID_from_string(COM_ISTREAM_UUID, &IID[0]);
status = smbcli_full_connection(NULL, &servers[i].cli[j],
servers[i].server_name,
servers[i].share_name, NULL,
- servers[i].credentials);
+ servers[i].credentials, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to connect to \\\\%s\\%s - %s\n",
servers[i].server_name, servers[i].share_name,
mem_ctx = talloc_init("test_createuser");
binding = lp_parm_string(-1, "torture", "binding");
- ctx = libnet_context_init();
+ ctx = libnet_context_init(NULL);
ctx->cred = cmdline_credentials;
req.in.user_name = TEST_USERNAME;
status = smbcli_full_connection(NULL, &c,
server,
share, NULL,
- servers[snum]);
+ servers[snum], NULL);
if (!NT_STATUS_IS_OK(status)) {
sleep(2);
}
nt_status = smbcli_full_connection(NULL,
&c, myname, server_n, 0, share, NULL,
- username, lp_workgroup(), password);
+ username, lp_workgroup(), password, NULL);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0, ("smbcli_full_connection failed with error %s\n", nt_errstr(nt_status)));
return NULL;
status = smbcli_full_connection(NULL, &c,
server,
share, NULL,
- credentials);
+ credentials, NULL);
if (!NT_STATUS_IS_OK(status)) {
return NULL;
if (b->transport == NCACN_IP_TCP) {
status = dcerpc_epm_map_binding(loop_ctx, b,
l->table->uuid,
- l->table->if_version);
+ l->table->if_version, NULL);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(loop_ctx);
printf("Failed to map port for uuid %s\n", l->table->uuid);
status = dcerpc_pipe_connect_b(mem_ctx, &p, b,
DCERPC_NETLOGON_UUID,
DCERPC_NETLOGON_VERSION,
- credentials);
+ credentials, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("RPC pipe connect as domain member failed: %s\n", nt_errstr(status));
&samsync_state->p, b,
DCERPC_NETLOGON_UUID,
DCERPC_NETLOGON_VERSION,
- credentials);
+ credentials, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to connect to server as a BDC: %s\n", nt_errstr(status));
b_netlogon_wksta,
DCERPC_NETLOGON_UUID,
DCERPC_NETLOGON_VERSION,
- credentials_wksta);
+ credentials_wksta, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to connect to server as a Workstation: %s\n", nt_errstr(status));
if (b->transport == NCACN_IP_TCP) {
status = dcerpc_epm_map_binding(mem_ctx, b,
l->table->uuid,
- l->table->if_version);
+ l->table->if_version, NULL);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(loop_ctx);
printf("Failed to map port for uuid %s\n", l->table->uuid);
&p, b,
DCERPC_SAMR_UUID,
DCERPC_SAMR_VERSION,
- credentials);
+ credentials, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to connect with schannel: %s\n", nt_errstr(status));
goto failed;
/* Swap the binding details from SAMR to NETLOGON */
status = dcerpc_epm_map_binding(test_ctx, b, DCERPC_NETLOGON_UUID,
- DCERPC_NETLOGON_VERSION);
+ DCERPC_NETLOGON_VERSION, NULL);
if (!NT_STATUS_IS_OK(status)) {
goto failed;
}
/* Look up identifier using the epmapper */
if (!b->endpoint) {
- status = dcerpc_epm_map_binding(tmp_ctx, b, pipe_uuid, pipe_version);
+ status = dcerpc_epm_map_binding(tmp_ctx, b, pipe_uuid, pipe_version,
+ NULL);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("Failed to map DCERPC/TCP NCACN_NP pipe for '%s' - %s\n",
pipe_uuid, nt_errstr(status)));
status = smbcli_full_connection(NULL,
c, hostname,
sharename, NULL,
- cmdline_credentials);
+ cmdline_credentials, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to open connection - %s\n", nt_errstr(status));
return False;
status = dcerpc_pipe_connect(parent_ctx,
p, binding, pipe_uuid, pipe_version,
- cmdline_credentials);
+ cmdline_credentials, NULL);
return status;
}
b->transport = transport;
status = dcerpc_pipe_connect_b(mem_ctx, p, b, pipe_uuid, pipe_version,
- cmdline_credentials);
+ cmdline_credentials, NULL);
if (NT_STATUS_IS_OK(status)) {
*p = talloc_reference(parent_ctx, *p);
status = smbcli_full_connection(NULL,
&cli1, host,
share, NULL,
- cmdline_credentials);
+ cmdline_credentials, NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("could not open connection\n");
domain_name = tmp;
- libnetctx = libnet_context_init();
+ libnetctx = libnet_context_init(NULL);
if (!libnetctx) {
return -1;
}
return -1;
}
- libnet_context_destroy(&libnetctx);
+ talloc_free(libnetctx);
return 0;
}
new_password = getpass(password_prompt);
}
- libnetctx = libnet_context_init();
+ libnetctx = libnet_context_init(NULL);
if (!libnetctx) {
return -1;
}
return -1;
}
- libnet_context_destroy(&libnetctx);
+ talloc_free(libnetctx);
return 0;
}
new_password = getpass(password_prompt);
}
- libnetctx = libnet_context_init();
+ libnetctx = libnet_context_init(NULL);
if (!libnetctx) {
return -1;
}
return -1;
}
- libnet_context_destroy(&libnetctx);
+ talloc_free(libnetctx);
return 0;
}
return net_time_usage(ctx, argc, argv);
}
- libnetctx = libnet_context_init();
+ libnetctx = libnet_context_init(NULL);
if (!libnetctx) {
return -1;
}
printf("%s\n",timestr);
- libnet_context_destroy(&libnetctx);
+ talloc_free(libnetctx);
return 0;
}
}
/* libnet context init and its params */
- lnet_ctx = libnet_context_init();
+ lnet_ctx = libnet_context_init(NULL);
if (!lnet_ctx) return -1;
lnet_ctx->cred = ctx->credentials;
return -1;
}
- libnet_context_destroy(&lnet_ctx);
+ talloc_free(lnet_ctx);
return 0;
}
struct libnet_context *libnetctx;
union libnet_SamDump r;
- libnetctx = libnet_context_init();
+ libnetctx = libnet_context_init(NULL);
if (!libnetctx) {
return -1;
}
return -1;
}
- libnet_context_destroy(&libnetctx);
+ talloc_free(libnetctx);
return 0;
}
case GSS_SPNEGO_CLIENT:
case NTLMSSP_CLIENT_1:
/* setup the client side */
-
- if (!NT_STATUS_IS_OK(gensec_client_start(NULL, gensec_state))) {
+
+ nt_status = gensec_client_start(NULL, gensec_state, NULL);
+ if (!NT_STATUS_IS_OK(nt_status)) {
exit(1);
}
break;
case GSS_SPNEGO_SERVER:
case SQUID_2_5_NTLMSSP:
- if (!NT_STATUS_IS_OK(gensec_server_start(NULL, gensec_state))) {
+ if (!NT_STATUS_IS_OK(gensec_server_start(NULL, gensec_state, NULL))) {
exit(1);
}
break;