From: Jelmer Vernooij Date: Thu, 3 Jan 2008 23:22:12 +0000 (-0600) Subject: r26654: libcli/smb_composite: Rather than specifying each of the gazillion options... X-Git-Tag: samba-4.0.0alpha6~801^3~789 X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=dcc282590b34537fc1ead61c3300172528273b44;p=samba.git r26654: libcli/smb_composite: Rather than specifying each of the gazillion options for SMB individually, just specify the smbcli_options struct. (This used to be commit 8a97886e24a4b969aa91409c06f423b71a45f6eb) --- diff --git a/source4/client/cifsdd.c b/source4/client/cifsdd.c index 8749a82573c..8e25dab9275 100644 --- a/source4/client/cifsdd.c +++ b/source4/client/cifsdd.c @@ -23,6 +23,7 @@ #include "auth/gensec/gensec.h" #include "lib/cmdline/popt_common.h" #include "libcli/resolve/resolve.h" +#include "libcli/raw/libcliraw.h" #include "cifsdd.h" #include "param/param.h" @@ -353,7 +354,8 @@ static void print_transfer_stats(void) } static struct dd_iohandle * open_file(struct resolve_context *resolve_ctx, - const char * which, const char **ports) + const char * which, const char **ports, + struct smbcli_options *smb_options) { int options = 0; const char * path = NULL; @@ -374,12 +376,14 @@ static struct dd_iohandle * open_file(struct resolve_context *resolve_ctx, if (strcmp(which, "if") == 0) { path = check_arg_pathname("if"); handle = dd_open_path(resolve_ctx, path, ports, - check_arg_numeric("ibs"), options); + check_arg_numeric("ibs"), options, + smb_options); } else if (strcmp(which, "of") == 0) { options |= DD_WRITE; path = check_arg_pathname("of"); handle = dd_open_path(resolve_ctx, path, ports, - check_arg_numeric("obs"), options); + check_arg_numeric("obs"), options, + smb_options); } else { SMB_ASSERT(0); return(NULL); @@ -392,14 +396,6 @@ static struct dd_iohandle * open_file(struct resolve_context *resolve_ctx, return(handle); } -static void set_max_xmit(struct loadparm_context *lp_ctx, uint64_t iomax) -{ - char buf[64]; - - snprintf(buf, sizeof(buf), "%llu", (unsigned long long)iomax); - lp_set_cmdline(lp_ctx, "max xmit", buf); -} - static int copy_files(struct loadparm_context *lp_ctx) { uint8_t * iobuf; /* IO buffer. */ @@ -413,10 +409,14 @@ static int copy_files(struct loadparm_context *lp_ctx) struct dd_iohandle * ifile; struct dd_iohandle * ofile; + struct smbcli_options options; + ibs = check_arg_numeric("ibs"); obs = check_arg_numeric("obs"); count = check_arg_numeric("count"); + lp_smbcli_options(lp_ctx, &options); + /* Allocate IO buffer. We need more than the max IO size because we * could accumulate a remainder if ibs and obs don't match. */ @@ -428,18 +428,18 @@ static int copy_files(struct loadparm_context *lp_ctx) return(EOM_EXIT_CODE); } - set_max_xmit(lp_ctx, MAX(ibs, obs)); + options.max_xmit = MAX(ibs, obs); DEBUG(4, ("IO buffer size is %llu, max xmit is %d\n", - (unsigned long long)iomax, lp_max_xmit(lp_ctx))); + (unsigned long long)iomax, options.max_xmit)); if (!(ifile = open_file(lp_resolve_context(lp_ctx), "if", - lp_smb_ports(lp_ctx)))) { + lp_smb_ports(lp_ctx), &options))) { return(FILESYS_EXIT_CODE); } if (!(ofile = open_file(lp_resolve_context(lp_ctx), "of", - lp_smb_ports(lp_ctx)))) { + lp_smb_ports(lp_ctx), &options))) { return(FILESYS_EXIT_CODE); } @@ -447,7 +447,7 @@ static int copy_files(struct loadparm_context *lp_ctx) ifile->io_seek(ifile, check_arg_numeric("skip") * ibs); ofile->io_seek(ofile, check_arg_numeric("seek") * obs); - DEBUG(4, ("max xmit was negotiated to be %d\n", lp_max_xmit(lp_ctx))); + DEBUG(4, ("max xmit was negotiated to be %d\n", options.max_xmit)); for (data_size = 0;;) { diff --git a/source4/client/cifsdd.h b/source4/client/cifsdd.h index 0c44b915819..810c882ea9a 100644 --- a/source4/client/cifsdd.h +++ b/source4/client/cifsdd.h @@ -88,10 +88,13 @@ struct dd_iohandle #define DD_WRITE 0x00000004 #define DD_OPLOCK 0x00000008 +struct smbcli_options; + struct dd_iohandle * dd_open_path(struct resolve_context *resolve_ctx, const char * path, const char **ports, - uint64_t io_size, int options); + uint64_t io_size, int options, + struct smbcli_options *smb_options); bool dd_fill_block(struct dd_iohandle * h, uint8_t * buf, uint64_t * buf_size, uint64_t need_size, uint64_t block_size); bool dd_flush_block(struct dd_iohandle * h, uint8_t * buf, diff --git a/source4/client/cifsddio.c b/source4/client/cifsddio.c index 2e5aedc4f98..7028e850788 100644 --- a/source4/client/cifsddio.c +++ b/source4/client/cifsddio.c @@ -223,7 +223,8 @@ static bool smb_write_func(void * handle, uint8_t * buf, uint64_t wanted, static struct smbcli_state * init_smb_session(struct resolve_context *resolve_ctx, const char * host, const char **ports, - const char * share) + const char * share, + struct smbcli_options *options) { NTSTATUS ret; struct smbcli_state * cli = NULL; @@ -233,7 +234,7 @@ static struct smbcli_state * init_smb_session(struct resolve_context *resolve_ct */ ret = smbcli_full_connection(NULL, &cli, host, ports, share, NULL /* devtype */, cmdline_credentials, resolve_ctx, - NULL /* events */); + NULL /* events */, options); if (!NT_STATUS_IS_OK(ret)) { fprintf(stderr, "%s: connecting to //%s/%s: %s\n", @@ -297,7 +298,8 @@ static struct dd_iohandle * open_cifs_handle(struct resolve_context *resolve_ctx const char * share, const char * path, uint64_t io_size, - int options) + int options, + struct smbcli_options *smb_options) { struct cifs_handle * smbh; @@ -317,7 +319,8 @@ static struct dd_iohandle * open_cifs_handle(struct resolve_context *resolve_ctx smbh->h.io_write = smb_write_func; smbh->h.io_seek = smb_seek_func; - if ((smbh->cli = init_smb_session(resolve_ctx, host, ports, share)) == NULL) { + if ((smbh->cli = init_smb_session(resolve_ctx, host, ports, share, + smb_options)) == NULL) { return(NULL); } @@ -336,7 +339,8 @@ struct dd_iohandle * dd_open_path(struct resolve_context *resolve_ctx, const char * path, const char **ports, uint64_t io_size, - int options) + int options, + struct smbcli_options *smb_options) { if (file_exist(path)) { return(open_fd_handle(path, io_size, options)); @@ -353,7 +357,7 @@ struct dd_iohandle * dd_open_path(struct resolve_context *resolve_ctx, return(open_cifs_handle(resolve_ctx, host, ports, share, remain, - io_size, options)); + io_size, options, smb_options)); } return(open_fd_handle(path, io_size, options)); diff --git a/source4/client/client.c b/source4/client/client.c index 259966ddaa2..d9478a3a8ad 100644 --- a/source4/client/client.c +++ b/source4/client/client.c @@ -3021,7 +3021,10 @@ return a connection to a server *******************************************************/ static bool do_connect(struct smbclient_context *ctx, struct resolve_context *resolve_ctx, - const char *specified_server, const char **ports, const char *specified_share, struct cli_credentials *cred) + const char *specified_server, const char **ports, + const char *specified_share, + struct cli_credentials *cred, + struct smbcli_options *options) { NTSTATUS status; char *server, *share; @@ -3040,7 +3043,8 @@ static bool do_connect(struct smbclient_context *ctx, status = smbcli_full_connection(ctx, &ctx->cli, server, ports, share, NULL, cred, resolve_ctx, - cli_credentials_get_event_context(cred)); + cli_credentials_get_event_context(cred), + options); if (!NT_STATUS_IS_OK(status)) { d_printf("Connection to \\\\%s\\%s failed - %s\n", server, share, nt_errstr(status)); @@ -3065,7 +3069,7 @@ static int do_host_query(struct loadparm_context *lp_ctx, const char *query_host /**************************************************************************** handle a message operation ****************************************************************************/ -static int do_message_op(const char *netbios_name, const char *desthost, const char **destports, const char *destip, int name_type, struct resolve_context *resolve_ctx, int max_xmit, int max_mux, bool use_spnego, enum smb_signing_state signing) +static int do_message_op(const char *netbios_name, const char *desthost, const char **destports, const char *destip, int name_type, struct resolve_context *resolve_ctx, struct smbcli_options *options) { struct nbt_name called, calling; const char *server_name; @@ -3077,7 +3081,7 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c server_name = destip ? destip : desthost; - if (!(cli=smbcli_state_init(NULL)) || !smbcli_socket_connect(cli, server_name, destports, resolve_ctx, max_xmit, max_mux, use_spnego, signing)) { + if (!(cli=smbcli_state_init(NULL)) || !smbcli_socket_connect(cli, server_name, destports, resolve_ctx, options)) { d_printf("Connection to %s failed\n", server_name); return 1; } @@ -3120,6 +3124,7 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c TALLOC_CTX *mem_ctx; struct smbclient_context *ctx; const char *cmdstr = NULL; + struct smbcli_options smb_options; struct poptOption long_options[] = { POPT_AUTOHELP @@ -3212,6 +3217,8 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c poptFreeContext(pc); + lp_smbcli_options(cmdline_lp_ctx, &smb_options); + DEBUG( 3, ( "Client started (version %s).\n", SAMBA_VERSION_STRING ) ); if (query_host && (p=strchr_m(query_host,'#'))) { @@ -3225,10 +3232,10 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c } if (message) { - return do_message_op(lp_netbios_name(cmdline_lp_ctx), desthost, lp_smb_ports(cmdline_lp_ctx), dest_ip, name_type, lp_resolve_context(cmdline_lp_ctx), lp_max_xmit(cmdline_lp_ctx), lp_maxmux(cmdline_lp_ctx), lp_nt_status_support(cmdline_lp_ctx) && lp_use_spnego(cmdline_lp_ctx), lp_client_signing(cmdline_lp_ctx)); + return do_message_op(lp_netbios_name(cmdline_lp_ctx), desthost, lp_smb_ports(cmdline_lp_ctx), dest_ip, name_type, lp_resolve_context(cmdline_lp_ctx), &smb_options); } - if (!do_connect(ctx, lp_resolve_context(cmdline_lp_ctx), desthost, lp_smb_ports(cmdline_lp_ctx), service, cmdline_credentials)) + if (!do_connect(ctx, lp_resolve_context(cmdline_lp_ctx), desthost, lp_smb_ports(cmdline_lp_ctx), service, cmdline_credentials, &smb_options)) return 1; if (base_directory) diff --git a/source4/client/smbspool.c b/source4/client/smbspool.c index 614e50bb0bf..df867d5fefc 100644 --- a/source4/client/smbspool.c +++ b/source4/client/smbspool.c @@ -270,8 +270,8 @@ smb_connect(const char *workgroup, /* I - Workgroup */ myname = get_myname(); - nt_status = smbcli_full_connection(NULL, &c, myname, server, ports, share, NULL, - username, workgroup, password, NULL); + nt_status = smbcli_full_connection(NULL, &c, myname, server, ports, share, + NULL, username, workgroup, password, NULL); free(myname); if (!NT_STATUS_IS_OK(nt_status)) { diff --git a/source4/dsdb/schema/schema_syntax.c b/source4/dsdb/schema/schema_syntax.c index b956441793c..9bc51c676ee 100644 --- a/source4/dsdb/schema/schema_syntax.c +++ b/source4/dsdb/schema/schema_syntax.c @@ -939,8 +939,7 @@ static WERROR dsdb_syntax_DN_BINARY_drsuapi_to_ldb(const struct dsdb_schema *sch } ndr_err = ndr_pull_struct_blob_all(in->value_ctr.values[i].blob, - out->values, - lp_iconv_convenience(global_loadparm), &id3b, + out->values, NULL, &id3b, (ndr_pull_flags_fn_t)ndr_pull_drsuapi_DsReplicaObjectIdentifier3Binary); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS status = ndr_map_error2ntstatus(ndr_err); @@ -998,7 +997,7 @@ static WERROR dsdb_syntax_DN_BINARY_ldb_to_drsuapi(const struct dsdb_schema *sch id3b.dn = (const char *)in->values[i].data; id3b.binary = data_blob(NULL, 0); - ndr_err = ndr_push_struct_blob(&blobs[i], blobs, lp_iconv_convenience(global_loadparm), &id3b, + ndr_err = ndr_push_struct_blob(&blobs[i], blobs, NULL, &id3b, (ndr_push_flags_fn_t)ndr_push_drsuapi_DsReplicaObjectIdentifier3Binary); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS status = ndr_map_error2ntstatus(ndr_err); diff --git a/source4/libcli/cliconnect.c b/source4/libcli/cliconnect.c index c1fadaa6797..666dfe84460 100644 --- a/source4/libcli/cliconnect.c +++ b/source4/libcli/cliconnect.c @@ -33,8 +33,7 @@ bool smbcli_socket_connect(struct smbcli_state *cli, const char *server, const char **ports, struct resolve_context *resolve_ctx, - int max_xmit, int max_mux, bool use_spnego, - enum smb_signing_state signing) + struct smbcli_options *options) { struct smbcli_socket *sock; @@ -43,8 +42,7 @@ bool smbcli_socket_connect(struct smbcli_state *cli, const char *server, if (sock == NULL) return false; - cli->transport = smbcli_transport_init(sock, cli, true, max_xmit, - max_mux, use_spnego, signing); + cli->transport = smbcli_transport_init(sock, cli, true, options); if (!cli->transport) { return false; } @@ -143,7 +141,8 @@ NTSTATUS smbcli_full_connection(TALLOC_CTX *parent_ctx, const char *devtype, struct cli_credentials *credentials, struct resolve_context *resolve_ctx, - struct event_context *ev) + struct event_context *ev, + struct smbcli_options *options) { struct smbcli_tree *tree; NTSTATUS status; @@ -153,7 +152,8 @@ NTSTATUS smbcli_full_connection(TALLOC_CTX *parent_ctx, status = smbcli_tree_full_connection(parent_ctx, &tree, host, ports, sharename, devtype, - credentials, resolve_ctx, ev); + credentials, resolve_ctx, ev, + options); if (!NT_STATUS_IS_OK(status)) { goto done; } diff --git a/source4/libcli/raw/clitransport.c b/source4/libcli/raw/clitransport.c index 3ca828d46b5..62c32d30584 100644 --- a/source4/libcli/raw/clitransport.c +++ b/source4/libcli/raw/clitransport.c @@ -74,10 +74,7 @@ static NTSTATUS smbcli_transport_finish_recv(void *private, DATA_BLOB blob); struct smbcli_transport *smbcli_transport_init(struct smbcli_socket *sock, TALLOC_CTX *parent_ctx, bool primary, - int max_xmit, - int max_mux, - bool use_spnego, - enum smb_signing_state signing) + struct smbcli_options *options) { struct smbcli_transport *transport; @@ -90,12 +87,7 @@ struct smbcli_transport *smbcli_transport_init(struct smbcli_socket *sock, transport->socket = talloc_reference(transport, sock); } transport->negotiate.protocol = PROTOCOL_NT1; - transport->options.use_spnego = use_spnego; - transport->options.max_xmit = max_xmit; - transport->options.max_mux = max_mux; - transport->options.request_timeout = SMB_REQUEST_TIMEOUT; - transport->options.signing = signing; - + transport->options = *options; transport->negotiate.max_xmit = transport->options.max_xmit; /* setup the stream -> packet parser */ diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 3d8a6760a19..ae63d94acd8 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -175,7 +175,8 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, const char *service, const char *service_type, struct cli_credentials *credentials, struct resolve_context *resolve_ctx, - struct event_context *ev) + struct event_context *ev, + struct smbcli_options *options) { struct smb_composite_connect io; NTSTATUS status; @@ -191,14 +192,7 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, io.in.service_type = service_type; io.in.credentials = credentials; io.in.fallback_to_anonymous = false; - io.in.workgroup = lp_workgroup(global_loadparm); - io.in.max_xmit = lp_max_xmit(global_loadparm); - io.in.max_mux = lp_maxmux(global_loadparm); - io.in.ntstatus_support = lp_nt_status_support(global_loadparm); - io.in.max_protocol = lp_cli_maxprotocol(global_loadparm); - io.in.unicode = lp_unicode(global_loadparm); - io.in.use_spnego = lp_use_spnego(global_loadparm) && lp_nt_status_support(global_loadparm); - io.in.signing = lp_client_signing(global_loadparm); + io.in.options = *options; status = smb_composite_connect(&io, parent_ctx, resolve_ctx, ev); if (NT_STATUS_IS_OK(status)) { diff --git a/source4/libcli/raw/libcliraw.h b/source4/libcli/raw/libcliraw.h index dd6904dec2d..0032eb4e948 100644 --- a/source4/libcli/raw/libcliraw.h +++ b/source4/libcli/raw/libcliraw.h @@ -94,6 +94,9 @@ struct smbcli_options { uint_t use_oplocks:1; uint_t use_level2_oplocks:1; uint_t use_spnego:1; + uint_t unicode:1; + uint_t ntstatus_support:1; + int max_protocol; uint32_t max_xmit; uint16_t max_mux; int request_timeout; diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index e45a8a25f9d..a44765e9809 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -63,7 +63,7 @@ static NTSTATUS connect_send_negprot(struct composite_context *c, { struct connect_state *state = talloc_get_type(c->private_data, struct connect_state); - state->req = smb_raw_negotiate_send(state->transport, io->in.unicode, io->in.max_protocol); + state->req = smb_raw_negotiate_send(state->transport, io->in.options.unicode, io->in.options.max_protocol); NT_STATUS_HAVE_NO_MEMORY(state->req); state->req->async.fn = request_handler; @@ -307,10 +307,7 @@ static NTSTATUS connect_socket(struct composite_context *c, /* the socket is up - we can initialise the smbcli transport layer */ state->transport = smbcli_transport_init(state->sock, state, true, - io->in.max_xmit, - io->in.max_mux, - io->in.use_spnego, - io->in.signing); + &io->in.options); NT_STATUS_HAVE_NO_MEMORY(state->transport); if (is_ipaddress(state->sock->hostname) && diff --git a/source4/libcli/smb_composite/fetchfile.c b/source4/libcli/smb_composite/fetchfile.c index 5fa48b48639..c7d02e323c2 100644 --- a/source4/libcli/smb_composite/fetchfile.c +++ b/source4/libcli/smb_composite/fetchfile.c @@ -147,14 +147,7 @@ struct composite_context *smb_composite_fetchfile_send(struct smb_composite_fetc state->connect->in.fallback_to_anonymous = false; state->connect->in.workgroup = io->in.workgroup; - state->connect->in.max_xmit = lp_max_xmit(global_loadparm); - state->connect->in.max_mux = lp_maxmux(global_loadparm); - state->connect->in.ntstatus_support = lp_nt_status_support(global_loadparm); - state->connect->in.max_protocol = lp_cli_maxprotocol(global_loadparm); - state->connect->in.unicode = lp_unicode(global_loadparm); - state->connect->in.use_spnego = lp_use_spnego(global_loadparm) && - lp_nt_status_support(global_loadparm); - state->connect->in.signing = lp_client_signing(global_loadparm); + lp_smbcli_options(global_loadparm, &state->connect->in.options); state->creq = smb_composite_connect_send(state->connect, state, lp_resolve_context(global_loadparm), event_ctx); diff --git a/source4/libcli/smb_composite/fsinfo.c b/source4/libcli/smb_composite/fsinfo.c index b6a5a5f2cca..26b19e87594 100644 --- a/source4/libcli/smb_composite/fsinfo.c +++ b/source4/libcli/smb_composite/fsinfo.c @@ -153,14 +153,7 @@ struct composite_context *smb_composite_fsinfo_send(struct smbcli_tree *tree, state->connect->in.fallback_to_anonymous = false; state->connect->in.workgroup = io->in.workgroup; - state->connect->in.max_xmit = lp_max_xmit(global_loadparm); - state->connect->in.max_mux = lp_maxmux(global_loadparm); - state->connect->in.ntstatus_support = lp_nt_status_support(global_loadparm); - state->connect->in.max_protocol = lp_cli_maxprotocol(global_loadparm); - state->connect->in.unicode = lp_unicode(global_loadparm); - state->connect->in.use_spnego = lp_use_spnego(global_loadparm) && - lp_nt_status_support(global_loadparm); - state->connect->in.signing = lp_client_signing(global_loadparm); + lp_smbcli_options(global_loadparm, &state->connect->in.options); c->state = COMPOSITE_STATE_IN_PROGRESS; state->stage = FSINFO_CONNECT; diff --git a/source4/libcli/smb_composite/smb_composite.h b/source4/libcli/smb_composite/smb_composite.h index dd193fc8206..a732617f808 100644 --- a/source4/libcli/smb_composite/smb_composite.h +++ b/source4/libcli/smb_composite/smb_composite.h @@ -28,6 +28,7 @@ */ #include "libcli/raw/signing.h" +#include "libcli/raw/libcliraw.h" /* @@ -93,13 +94,7 @@ struct smb_composite_connect { struct cli_credentials *credentials; bool fallback_to_anonymous; const char *workgroup; - bool use_spnego; - bool ntstatus_support; - bool unicode; - int max_xmit; - int max_mux; - int max_protocol; - enum smb_signing_state signing; + struct smbcli_options options; } in; struct { struct smbcli_tree *tree; diff --git a/source4/librpc/rpc/dcerpc_connect.c b/source4/librpc/rpc/dcerpc_connect.c index 9bd503c6258..361be4adcd0 100644 --- a/source4/librpc/rpc/dcerpc_connect.c +++ b/source4/librpc/rpc/dcerpc_connect.c @@ -119,13 +119,7 @@ static struct composite_context *dcerpc_pipe_connect_ncacn_np_smb_send(TALLOC_CT conn->in.service_type = NULL; conn->in.workgroup = lp_workgroup(lp_ctx); - conn->in.max_xmit = lp_max_xmit(lp_ctx); - conn->in.max_mux = lp_maxmux(lp_ctx); - conn->in.ntstatus_support = lp_nt_status_support(lp_ctx); - conn->in.max_protocol = lp_cli_maxprotocol(lp_ctx); - conn->in.unicode = lp_unicode(lp_ctx); - conn->in.use_spnego = lp_use_spnego(lp_ctx) && lp_nt_status_support(lp_ctx); - conn->in.signing = lp_client_signing(lp_ctx); + lp_smbcli_options(lp_ctx, &conn->in.options); /* * provide proper credentials - user supplied, but allow a diff --git a/source4/ntvfs/cifs/vfs_cifs.c b/source4/ntvfs/cifs/vfs_cifs.c index 0b0c9b10372..910401f1576 100644 --- a/source4/ntvfs/cifs/vfs_cifs.c +++ b/source4/ntvfs/cifs/vfs_cifs.c @@ -202,13 +202,7 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, io.in.workgroup = lp_workgroup(ntvfs->ctx->lp_ctx); io.in.service = remote_share; io.in.service_type = "?????"; - io.in.max_xmit = lp_max_xmit(ntvfs->ctx->lp_ctx); - io.in.max_mux = lp_maxmux(ntvfs->ctx->lp_ctx); - io.in.ntstatus_support = lp_nt_status_support(ntvfs->ctx->lp_ctx); - io.in.max_protocol = lp_cli_maxprotocol(ntvfs->ctx->lp_ctx); - io.in.unicode = lp_unicode(ntvfs->ctx->lp_ctx); - io.in.use_spnego = lp_use_spnego(ntvfs->ctx->lp_ctx) && lp_nt_status_support(ntvfs->ctx->lp_ctx); - io.in.signing = lp_client_signing(ntvfs->ctx->lp_ctx); + lp_smbcli_options(ntvfs->ctx->lp_ctx, &io.in.options); creq = smb_composite_connect_send(&io, private, lp_resolve_context(ntvfs->ctx->lp_ctx), diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c index 66bb44dc3cb..2b7b9dd7dac 100644 --- a/source4/param/loadparm.c +++ b/source4/param/loadparm.c @@ -63,6 +63,7 @@ #include "lib/util/dlinklist.h" #include "param/param.h" #include "param/loadparm.h" +#include "libcli/raw/libcliraw.h" #define standard_sub_basic talloc_strdup @@ -2605,3 +2606,18 @@ _PUBLIC_ void reload_charcnv(struct loadparm_context *lp_ctx) talloc_free(lp_ctx->iconv_convenience); lp_ctx->iconv_convenience = smb_iconv_convenience_init_lp(lp_ctx, lp_ctx); } + +void lp_smbcli_options(struct loadparm_context *lp_ctx, + struct smbcli_options *options) +{ + options->max_xmit = lp_max_xmit(lp_ctx); + options->max_mux = lp_maxmux(lp_ctx); + options->use_spnego = lp_nt_status_support(lp_ctx) && lp_use_spnego(lp_ctx); + options->signing = lp_client_signing(lp_ctx); + options->request_timeout = SMB_REQUEST_TIMEOUT; + options->ntstatus_support = lp_nt_status_support(lp_ctx); + options->max_protocol = lp_cli_maxprotocol(lp_ctx); + options->unicode = lp_unicode(lp_ctx); + options->use_oplocks = false; + options->use_level2_oplocks = false; +} diff --git a/source4/param/param.h b/source4/param/param.h index 210b21d9a00..098a73deec5 100644 --- a/source4/param/param.h +++ b/source4/param/param.h @@ -59,6 +59,7 @@ enum announce_as {/* Types of machine we can announce as. */ struct loadparm_context; struct loadparm_service; +struct smbcli_options; #include "param/proto.h" diff --git a/source4/scripting/ejs/smbcalls_cli.c b/source4/scripting/ejs/smbcalls_cli.c index 5e61a4df212..8295a0879fd 100644 --- a/source4/scripting/ejs/smbcalls_cli.c +++ b/source4/scripting/ejs/smbcalls_cli.c @@ -445,13 +445,7 @@ static int ejs_tree_connect(MprVarHandle eid, int argc, char **argv) io.in.credentials = creds; io.in.fallback_to_anonymous = false; io.in.workgroup = lp_workgroup(global_loadparm); - io.in.max_xmit = lp_max_xmit(global_loadparm); - io.in.max_mux = lp_maxmux(global_loadparm); - io.in.ntstatus_support = lp_nt_status_support(global_loadparm); - io.in.max_protocol = lp_cli_maxprotocol(global_loadparm); - io.in.unicode = lp_unicode(global_loadparm); - io.in.use_spnego = lp_use_spnego(global_loadparm) && lp_nt_status_support(global_loadparm); - io.in.signing = lp_client_signing(global_loadparm); + lp_smbcli_options(global_loadparm, &io.in.options); result = smb_composite_connect(&io, mem_ctx, lp_resolve_context(global_loadparm), diff --git a/source4/torture/basic/base.c b/source4/torture/basic/base.c index fcd788481b3..aa729ec0dff 100644 --- a/source4/torture/basic/base.c +++ b/source4/torture/basic/base.c @@ -40,6 +40,7 @@ static struct smbcli_state *open_nbt_connection(struct torture_context *tctx) struct nbt_name called, calling; struct smbcli_state *cli; const char *host = torture_setting_string(tctx, "host", NULL); + struct smbcli_options options; make_nbt_name_client(&calling, lp_netbios_name(tctx->lp_ctx)); @@ -51,7 +52,9 @@ static struct smbcli_state *open_nbt_connection(struct torture_context *tctx) goto failed; } - if (!smbcli_socket_connect(cli, host, lp_smb_ports(tctx->lp_ctx), lp_resolve_context(tctx->lp_ctx), lp_max_xmit(tctx->lp_ctx), lp_maxmux(tctx->lp_ctx), lp_nt_status_support(tctx->lp_ctx) && lp_use_spnego(tctx->lp_ctx), lp_client_signing(tctx->lp_ctx))) { + lp_smbcli_options(tctx->lp_ctx, &options); + + if (!smbcli_socket_connect(cli, host, lp_smb_ports(tctx->lp_ctx), lp_resolve_context(tctx->lp_ctx), &options)) { torture_comment(tctx, "Failed to connect with %s\n", host); goto failed; } diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index 986a4574a9a..d991f117cdc 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -821,13 +821,7 @@ static struct composite_context *torture_connect_async( smb->in.credentials=cmdline_credentials; smb->in.fallback_to_anonymous=false; smb->in.workgroup=workgroup; - smb->in.max_xmit = lp_max_xmit(tctx->lp_ctx); - smb->in.max_mux = lp_maxmux(tctx->lp_ctx); - smb->in.ntstatus_support = lp_nt_status_support(tctx->lp_ctx); - smb->in.max_protocol = lp_cli_maxprotocol(tctx->lp_ctx); - smb->in.unicode = lp_unicode(tctx->lp_ctx); - smb->in.use_spnego = lp_use_spnego(tctx->lp_ctx) && lp_nt_status_support(tctx->lp_ctx); - smb->in.signing = lp_client_signing(tctx->lp_ctx); + lp_smbcli_options(tctx->lp_ctx, &smb->in.options); return smb_composite_connect_send(smb,mem_ctx, lp_resolve_context(tctx->lp_ctx),ev); diff --git a/source4/torture/gentest.c b/source4/torture/gentest.c index 9e5ef73ea6a..c9e36b7e4ed 100644 --- a/source4/torture/gentest.c +++ b/source4/torture/gentest.c @@ -176,6 +176,7 @@ static bool connect_servers(struct loadparm_context *lp_ctx) for (i=0;iin.credentials = cmdline_credentials; io->in.fallback_to_anonymous = false; io->in.workgroup = lp_workgroup(state->tctx->lp_ctx); - io->in.max_xmit = lp_max_xmit(state->tctx->lp_ctx); - io->in.max_mux = lp_maxmux(state->tctx->lp_ctx); - io->in.ntstatus_support = lp_nt_status_support(state->tctx->lp_ctx); - io->in.max_protocol = lp_cli_maxprotocol(state->tctx->lp_ctx); - io->in.unicode = lp_unicode(state->tctx->lp_ctx); - io->in.use_spnego = lp_use_spnego(state->tctx->lp_ctx) && lp_nt_status_support(state->tctx->lp_ctx); - io->in.signing = lp_client_signing(state->tctx->lp_ctx); + lp_smbcli_options(state->tctx->lp_ctx, &io->in.options); /* kill off the remnants of the old connection */ talloc_free(state->tree); diff --git a/source4/torture/raw/openbench.c b/source4/torture/raw/openbench.c index 7f4752cdf7c..87b27d07283 100644 --- a/source4/torture/raw/openbench.c +++ b/source4/torture/raw/openbench.c @@ -131,13 +131,7 @@ static void reopen_connection(struct event_context *ev, struct timed_event *te, io->in.credentials = cmdline_credentials; io->in.fallback_to_anonymous = false; io->in.workgroup = lp_workgroup(state->tctx->lp_ctx); - io->in.max_xmit = lp_max_xmit(state->tctx->lp_ctx); - io->in.max_mux = lp_maxmux(state->tctx->lp_ctx); - io->in.ntstatus_support = lp_nt_status_support(state->tctx->lp_ctx); - io->in.max_protocol = lp_cli_maxprotocol(state->tctx->lp_ctx); - io->in.unicode = lp_unicode(state->tctx->lp_ctx); - io->in.use_spnego = lp_use_spnego(state->tctx->lp_ctx) && lp_nt_status_support(state->tctx->lp_ctx); - io->in.signing = lp_client_signing(state->tctx->lp_ctx); + lp_smbcli_options(state->tctx->lp_ctx, &io->in.options); /* kill off the remnants of the old connection */ talloc_free(state->tree); diff --git a/source4/torture/rpc/join.c b/source4/torture/rpc/join.c index dd2912380d2..849b9fd1e99 100644 --- a/source4/torture/rpc/join.c +++ b/source4/torture/rpc/join.c @@ -18,6 +18,7 @@ bool torture_rpc_join(struct torture_context *torture) struct cli_credentials *machine_account; struct smbcli_state *cli; const char *host = torture_setting_string(torture, "host", NULL); + struct smbcli_options options; /* Join domain as a member server. */ tj = torture_join_domain(torture, @@ -31,12 +32,14 @@ bool torture_rpc_join(struct torture_context *torture) return false; } + lp_smbcli_options(torture->lp_ctx, &options); + status = smbcli_full_connection(tj, &cli, host, lp_smb_ports(torture->lp_ctx), "IPC$", NULL, machine_account, lp_resolve_context(torture->lp_ctx), - NULL); + NULL, &options); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("%s failed to connect to IPC$ with workstation credentials\n", TORTURE_NETBIOS_NAME)); @@ -62,7 +65,7 @@ bool torture_rpc_join(struct torture_context *torture) "IPC$", NULL, machine_account, lp_resolve_context(torture->lp_ctx), - NULL); + NULL, &options); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("%s failed to connect to IPC$ with workstation credentials\n", TORTURE_NETBIOS_NAME)); diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c index fd8236544e5..3b96140fb23 100644 --- a/source4/torture/rpc/samba3rpc.c +++ b/source4/torture/rpc/samba3rpc.c @@ -71,6 +71,7 @@ bool torture_bind_authcontext(struct torture_context *torture) struct dcerpc_pipe *lsa_pipe; struct cli_credentials *anon_creds; struct smb_composite_sesssetup setup; + struct smbcli_options options; mem_ctx = talloc_init("torture_bind_authcontext"); @@ -79,12 +80,14 @@ bool torture_bind_authcontext(struct torture_context *torture) return false; } + lp_smbcli_options(torture->lp_ctx, &options); + status = smbcli_full_connection(mem_ctx, &cli, torture_setting_string(torture, "host", NULL), lp_smb_ports(torture->lp_ctx), "IPC$", NULL, cmdline_credentials, lp_resolve_context(torture->lp_ctx), - NULL); + NULL, &options); if (!NT_STATUS_IS_OK(status)) { d_printf("smbcli_full_connection failed: %s\n", nt_errstr(status)); @@ -282,6 +285,7 @@ bool torture_bind_samba3(struct torture_context *torture) NTSTATUS status; bool ret = false; struct smbcli_state *cli; + struct smbcli_options options; mem_ctx = talloc_init("torture_bind_authcontext"); @@ -290,12 +294,14 @@ bool torture_bind_samba3(struct torture_context *torture) return false; } + lp_smbcli_options(torture->lp_ctx, &options); + status = smbcli_full_connection(mem_ctx, &cli, torture_setting_string(torture, "host", NULL), lp_smb_ports(torture->lp_ctx), "IPC$", NULL, cmdline_credentials, lp_resolve_context(torture->lp_ctx), - NULL); + NULL, &options); if (!NT_STATUS_IS_OK(status)) { d_printf("smbcli_full_connection failed: %s\n", nt_errstr(status)); @@ -1134,6 +1140,7 @@ bool torture_netlogon_samba3(struct torture_context *torture) struct cli_credentials *wks_creds; const char *wks_name; int i; + struct smbcli_options options; wks_name = torture_setting_string(torture, "wksname", NULL); if (wks_name == NULL) { @@ -1152,12 +1159,14 @@ bool torture_netlogon_samba3(struct torture_context *torture) goto done; } + lp_smbcli_options(torture->lp_ctx, &options); + status = smbcli_full_connection(mem_ctx, &cli, torture_setting_string(torture, "host", NULL), lp_smb_ports(torture->lp_ctx), "IPC$", NULL, anon_creds, lp_resolve_context(torture->lp_ctx), - NULL); + NULL, &options); if (!NT_STATUS_IS_OK(status)) { d_printf("smbcli_full_connection failed: %s\n", nt_errstr(status)); @@ -1235,13 +1244,16 @@ static bool test_join3(struct torture_context *tctx, bool ret = false; struct smbcli_state *cli; struct cli_credentials *wks_creds; + struct smbcli_options options; + + lp_smbcli_options(tctx->lp_ctx, &options); status = smbcli_full_connection(tctx, &cli, torture_setting_string(tctx, "host", NULL), lp_smb_ports(tctx->lp_ctx), "IPC$", NULL, smb_creds, lp_resolve_context(tctx->lp_ctx), - NULL); + NULL, &options); if (!NT_STATUS_IS_OK(status)) { d_printf("smbcli_full_connection failed: %s\n", nt_errstr(status)); @@ -1598,17 +1610,20 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture) struct cli_credentials *anon_creds; struct cli_credentials *user_creds; char *domain_name; + struct smbcli_options options; if (!(mem_ctx = talloc_new(torture))) { return false; } + lp_smbcli_options(torture->lp_ctx, &options); + status = smbcli_full_connection( mem_ctx, &cli, torture_setting_string(torture, "host", NULL), lp_smb_ports(torture->lp_ctx), "IPC$", NULL, cmdline_credentials, lp_resolve_context(torture->lp_ctx), - NULL); + NULL, &options); if (!NT_STATUS_IS_OK(status)) { d_printf("(%s) smbcli_full_connection failed: %s\n", __location__, nt_errstr(status)); @@ -1635,7 +1650,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture) lp_smb_ports(torture->lp_ctx), "IPC$", NULL, anon_creds, lp_resolve_context(torture->lp_ctx), - NULL); + NULL, &options); if (!NT_STATUS_IS_OK(status)) { d_printf("(%s) anon smbcli_full_connection failed: %s\n", __location__, nt_errstr(status)); diff --git a/source4/torture/unix/unix_info2.c b/source4/torture/unix/unix_info2.c index 9fa0d55c9ed..c14be9e2d07 100644 --- a/source4/torture/unix/unix_info2.c +++ b/source4/torture/unix/unix_info2.c @@ -55,12 +55,16 @@ static struct smbcli_state *connect_to_server(struct torture_context *tctx) const char *host = torture_setting_string(tctx, "host", NULL); const char *share = torture_setting_string(tctx, "share", NULL); + struct smbcli_options options; + + lp_smbcli_options(tctx->lp_ctx, &options); status = smbcli_full_connection(tctx, &cli, host, lp_smb_ports(tctx->lp_ctx), share, NULL, cmdline_credentials, - lp_resolve_context(tctx->lp_ctx), NULL); + lp_resolve_context(tctx->lp_ctx), NULL, + &options); if (!NT_STATUS_IS_OK(status)) { printf("failed to connect to //%s/%s: %s\n", diff --git a/source4/torture/unix/whoami.c b/source4/torture/unix/whoami.c index 4477713bfed..3203f91bc03 100644 --- a/source4/torture/unix/whoami.c +++ b/source4/torture/unix/whoami.c @@ -75,12 +75,15 @@ static struct smbcli_state *connect_to_server(struct torture_context *tctx, const char *host = torture_setting_string(tctx, "host", NULL); const char *share = torture_setting_string(tctx, "share", NULL); + struct smbcli_options options; + + lp_smbcli_options(tctx->lp_ctx, &options); status = smbcli_full_connection(tctx, &cli, host, lp_smb_ports(tctx->lp_ctx), share, NULL, creds, lp_resolve_context(tctx->lp_ctx), - NULL); + NULL, &options); if (!NT_STATUS_IS_OK(status)) { printf("failed to connect to //%s/%s: %s\n", diff --git a/source4/torture/util_smb.c b/source4/torture/util_smb.c index 7d35b1296e0..6621b68b6e9 100644 --- a/source4/torture/util_smb.c +++ b/source4/torture/util_smb.c @@ -474,12 +474,16 @@ _PUBLIC_ bool torture_open_connection_share(TALLOC_CTX *mem_ctx, { NTSTATUS status; + struct smbcli_options options; + + lp_smbcli_options(tctx->lp_ctx, &options); + status = smbcli_full_connection(mem_ctx, c, hostname, lp_smb_ports(tctx->lp_ctx), sharename, NULL, cmdline_credentials, lp_resolve_context(tctx->lp_ctx), - ev); + ev, &options); if (!NT_STATUS_IS_OK(status)) { printf("Failed to open connection - %s\n", nt_errstr(status)); return false;