#include "libcli/smb2/smb2.h"
#include "libcli/smb2/smb2_calls.h"
#include "librpc/rpc/dcerpc.h"
+#include "librpc/rpc/dcerpc_proto.h"
#include "auth/credentials/credentials.h"
#include "param/param.h"
#include "libcli/resolve/resolve.h"
Initiate async open of a rpc connection to a rpc pipe on SMB using
the binding structure to determine the endpoint and options
*/
-static struct composite_context *dcerpc_pipe_connect_ncacn_np_smb_send(TALLOC_CTX *mem_ctx,
- struct dcerpc_pipe_connect *io)
+static struct composite_context *dcerpc_pipe_connect_ncacn_np_smb_send(TALLOC_CTX *mem_ctx, struct dcerpc_pipe_connect *io, struct loadparm_context *lp_ctx)
{
struct composite_context *c;
struct pipe_np_smb_state *s;
/* prepare smb connection parameters: we're connecting to IPC$ share on
remote rpc server */
conn->in.dest_host = s->io.binding->host;
- conn->in.dest_ports = lp_smb_ports(global_loadparm);
+ conn->in.dest_ports = lp_smb_ports(lp_ctx);
if (s->io.binding->target_hostname == NULL)
conn->in.called_name = "*SMBSERVER"; /* FIXME: This is invalid */
else
conn->in.called_name = s->io.binding->target_hostname;
+ conn->in.socket_options = lp_socket_options(lp_ctx);
conn->in.service = "IPC$";
conn->in.service_type = NULL;
- conn->in.workgroup = lp_workgroup(global_loadparm);
+ conn->in.workgroup = lp_workgroup(lp_ctx);
+ conn->in.gensec_settings = lp_gensec_settings(conn, lp_ctx);
+ conn->in.iconv_convenience = lp_iconv_convenience(lp_ctx);
+
+ lp_smbcli_options(lp_ctx, &conn->in.options);
+ lp_smbcli_session_options(lp_ctx, &conn->in.session_options);
/*
* provide proper credentials - user supplied, but allow a
}
/* send smb connect request */
- conn_req = smb_composite_connect_send(conn, s->io.pipe->conn, s->io.pipe->conn->event_ctx);
+ conn_req = smb_composite_connect_send(conn, s->io.pipe->conn,
+ s->io.resolve_ctx,
+ s->io.pipe->conn->event_ctx);
if (composite_nomem(conn_req, c)) return c;
composite_continue(c, conn_req, continue_smb_connect, c);
*/
static struct composite_context *dcerpc_pipe_connect_ncacn_np_smb2_send(
TALLOC_CTX *mem_ctx,
- struct dcerpc_pipe_connect *io)
+ struct dcerpc_pipe_connect *io,
+ struct loadparm_context *lp_ctx)
{
struct composite_context *c;
struct pipe_np_smb2_state *s;
struct composite_context *conn_req;
+ struct smbcli_options options;
/* composite context allocation and setup */
c = composite_create(mem_ctx, io->pipe->conn->event_ctx);
s->io.creds = cli_credentials_init(mem_ctx);
if (composite_nomem(s->io.creds, c)) return c;
- cli_credentials_guess(s->io.creds, global_loadparm);
+ cli_credentials_guess(s->io.creds, lp_ctx);
}
+ lp_smbcli_options(lp_ctx, &options);
+
/* send smb2 connect request */
- conn_req = smb2_connect_send(mem_ctx, s->io.binding->host, "IPC$",
+ conn_req = smb2_connect_send(mem_ctx, s->io.binding->host,
+ lp_parm_string_list(mem_ctx, lp_ctx, NULL, "smb2", "ports", NULL),
+ "IPC$",
s->io.resolve_ctx,
s->io.creds,
- c->event_ctx);
+ c->event_ctx,
+ &options,
+ lp_socket_options(lp_ctx),
+ lp_gensec_settings(mem_ctx, lp_ctx)
+ );
composite_continue(c, conn_req, continue_smb2_connect, c);
return c;
}
the binding structure to determine the endpoint and options
*/
static struct composite_context* dcerpc_pipe_connect_ncalrpc_send(TALLOC_CTX *mem_ctx,
- struct dcerpc_pipe_connect *io)
+ struct dcerpc_pipe_connect *io, struct loadparm_context *lp_ctx)
{
struct composite_context *c;
struct pipe_ncalrpc_state *s;
s->io = *io;
/* send pipe open request */
- pipe_req = dcerpc_pipe_open_pipe_send(s->io.pipe->conn, lp_ncalrpc_dir(global_loadparm),
+ pipe_req = dcerpc_pipe_open_pipe_send(s->io.pipe->conn, lp_ncalrpc_dir(lp_ctx),
s->io.binding->endpoint);
composite_continue(c, pipe_req, continue_pipe_open_ncalrpc, c);
return c;
pc.binding = s->binding;
pc.interface = s->table;
pc.creds = s->credentials;
- pc.resolve_ctx = lp_resolve_context(global_loadparm);
+ pc.resolve_ctx = lp_resolve_context(s->lp_ctx);
/* connect dcerpc pipe depending on required transport */
switch (s->binding->transport) {
case NCACN_NP:
if (pc.binding->flags & DCERPC_SMB2) {
/* new varient of SMB a.k.a. SMB2 */
- ncacn_np_smb2_req = dcerpc_pipe_connect_ncacn_np_smb2_send(c, &pc);
+ ncacn_np_smb2_req = dcerpc_pipe_connect_ncacn_np_smb2_send(c, &pc, s->lp_ctx);
composite_continue(c, ncacn_np_smb2_req, continue_pipe_connect_ncacn_np_smb2, c);
return;
} else {
/* good old ordinary SMB */
- ncacn_np_smb_req = dcerpc_pipe_connect_ncacn_np_smb_send(c, &pc);
+ ncacn_np_smb_req = dcerpc_pipe_connect_ncacn_np_smb_send(c, &pc, s->lp_ctx);
composite_continue(c, ncacn_np_smb_req, continue_pipe_connect_ncacn_np_smb, c);
return;
}
return;
case NCALRPC:
- ncalrpc_req = dcerpc_pipe_connect_ncalrpc_send(c, &pc);
+ ncalrpc_req = dcerpc_pipe_connect_ncalrpc_send(c, &pc, s->lp_ctx);
composite_continue(c, ncalrpc_req, continue_pipe_connect_ncalrpc, c);
return;
start a request to open a rpc connection to a rpc pipe, using
specified binding structure to determine the endpoint and options
*/
-struct composite_context* dcerpc_pipe_connect_b_send(TALLOC_CTX *parent_ctx,
+_PUBLIC_ struct composite_context* dcerpc_pipe_connect_b_send(TALLOC_CTX *parent_ctx,
struct dcerpc_binding *binding,
const struct ndr_interface_table *table,
struct cli_credentials *credentials,
struct pipe_connect_state *s;
struct event_context *new_ev = NULL;
- if (ev == NULL) {
- new_ev = event_context_init(parent_ctx);
- if (new_ev == NULL) return NULL;
- ev = new_ev;
- }
-
/* composite context allocation and setup */
c = composite_create(parent_ctx, ev);
if (c == NULL) {
s->pipe = dcerpc_pipe_init(c, ev, lp_iconv_convenience(lp_ctx));
if (composite_nomem(s->pipe, c)) return c;
+ if (DEBUGLEVEL >= 10)
+ s->pipe->conn->packet_log_dir = lp_lockdir(lp_ctx);
+
/* store parameters in state structure */
s->binding = binding;
s->table = table;
/*
receive result of a request to open a rpc connection to a rpc pipe
*/
-NTSTATUS dcerpc_pipe_connect_b_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
+_PUBLIC_ NTSTATUS dcerpc_pipe_connect_b_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
struct dcerpc_pipe **p)
{
NTSTATUS status;
open a rpc connection to a rpc pipe, using the specified
binding structure to determine the endpoint and options - sync version
*/
-NTSTATUS dcerpc_pipe_connect_b(TALLOC_CTX *parent_ctx,
+_PUBLIC_ NTSTATUS dcerpc_pipe_connect_b(TALLOC_CTX *parent_ctx,
struct dcerpc_pipe **pp,
struct dcerpc_binding *binding,
const struct ndr_interface_table *table,
binding to determine the endpoint and options.
The string is to be parsed to a binding structure first.
*/
-struct composite_context* dcerpc_pipe_connect_send(TALLOC_CTX *parent_ctx,
+_PUBLIC_ struct composite_context* dcerpc_pipe_connect_send(TALLOC_CTX *parent_ctx,
const char *binding,
const struct ndr_interface_table *table,
struct cli_credentials *credentials,
struct pipe_conn_state *s;
struct dcerpc_binding *b;
struct composite_context *pipe_conn_req;
- struct event_context *new_ev = NULL;
-
- if (ev == NULL) {
- new_ev = event_context_init(parent_ctx);
- if (new_ev == NULL) return NULL;
- ev = new_ev;
- }
/* composite context allocation and setup */
c = composite_create(parent_ctx, ev);
if (c == NULL) {
- talloc_free(new_ev);
return NULL;
}
- talloc_steal(c, new_ev);
s = talloc_zero(c, struct pipe_conn_state);
if (composite_nomem(s, c)) return c;
Open a rpc connection to a rpc pipe, using the specified string
binding to determine the endpoint and options - sync version
*/
-NTSTATUS dcerpc_pipe_connect(TALLOC_CTX *parent_ctx,
+_PUBLIC_ NTSTATUS dcerpc_pipe_connect(TALLOC_CTX *parent_ctx,
struct dcerpc_pipe **pp,
const char *binding,
const struct ndr_interface_table *table,